Пример #1
0
 virtual void vRun(void* threadData) override
 {
     MGPExecutor::ThreadData* data = (MGPExecutor::ThreadData*)threadData;
     auto function = data->get();
     GPContents* oldContent = mCollector->lock();
     GPContents* input = NULL;
     GPContents* mergeInput = NULL;
     {
         MGPAutoMutex __m(mInputMutex);
         auto tempMergeInput = new GPContents;
         input = _loadContent(mInputNum, mInput, mInputKeys);
         for (int i=0; i<mVariableKey.size(); ++i)
         {
             auto v = mVariableKey[i];
             MGPASSERT(v.first<=1);
             if (v.first == 1)
             {
                 tempMergeInput->pushContent(oldContent->getContent(v.second));
             }
             else
             {
                 tempMergeInput->pushContent(input->getContent(v.second));
             }
         }
         mergeInput = tempMergeInput->copyAsNoOwner();
         tempMergeInput->decRef();
     }
     GPContents* tempOutput = function->vRun(mergeInput);
     {
         MGPAutoMutex __m(mInputMutex);
         mergeInput->decRef();
         input->decRef();
     }
     {
         oldContent->setContent(0, tempOutput->getContent(0));
         tempOutput->decRef();
         mCollector->unlock(oldContent);
     }
 }
Пример #2
0
 virtual void vRun(void* threadData) override
 {
     //GPCLOCK;
     MGPExecutor::ThreadData* data = (MGPExecutor::ThreadData*)threadData;
     auto function = data->get();
     GPContents* orderedInput = NULL;
     GPContents* orderedOriginInput = NULL;
     {
         //GPCLOCK;
         MGPAutoMutex __m(mInputMutex);
         GPContents* totalInput = _loadContent(mInputNum, mInput, mInputKeys);
         orderedOriginInput = new GPContents;
         for (int i=0; i<mVariableKey.size(); ++i)
         {
             orderedOriginInput->pushContent(totalInput->getContent(mVariableKey[i].second));
         }
         totalInput->decRef();
         orderedInput = orderedOriginInput->copyAsNoOwner();
     }
     GPContents* output = NULL;
     {
         //GPCLOCK;
         output = function->vRun(orderedInput);
     }
     {
         //GPCLOCK;
         MGPAutoMutex __m(mInputMutex);
         orderedInput->decRef();
         orderedOriginInput->decRef();
     }
     {
         //GPCLOCK;
         MGPAutoMutex __m(mOutputMutex);
         mOutput->vSave(mOutputKeys, mOutput->nKeyNumber, output);
         output->decRef();
     }
 }
Пример #3
0
void
SolverUnconstrained<Data,Problem>::makeStep( vector_type & _x, vector_type & _s, value_type _Delta,
        f_type& __fx,
        vector_type & _Tgrad_fx,
        banded_matrix_type & _Hg,
        symmetric_matrix_type & _Thess_fxT, symmetric_matrix_type & _Htil )
{
    M_theta.update( _Delta, _x, _s );

    _Tgrad_fx = prod( M_theta(),  __fx.gradient( 0 ) );

    banded_matrix_type __diag_grad_fx( _E_n, _E_n, 0, 0 );

    matrix<value_type> __m( outer_prod( _Tgrad_fx,
                                        scalar_vector<value_type>( _Tgrad_fx.size(), 1 ) ) );
    __diag_grad_fx = banded_adaptor<matrix<value_type> >( __m, 0, 0 );

    _Hg = prod( M_theta.jacobian(), __diag_grad_fx );

    _Thess_fxT = prod( M_theta(), prod( __fx.hessian( 0 ), M_theta() ) );
    _Htil = _Thess_fxT + _Hg;
}