diff --git a/src/core/ParallelTaskManager.h b/src/core/ParallelTaskManager.h index a9231d6145..c37bb909a3 100644 --- a/src/core/ParallelTaskManager.h +++ b/src/core/ParallelTaskManager.h @@ -69,7 +69,9 @@ class ParallelTaskManager { /// This runs all the tasks void runAllTasks( const unsigned& natoms=0 ); /// This runs each of the tasks - void runTask( const ParallelActionsInput& locinp, MultiValue& myvals ) const ; + static void runTask( const ParallelActionsInput& locinp, MultiValue& myvals ); +/// Transfer the data to the Value + void transferToValue( const unsigned& task_index, const MultiValue& myvals ) const ; }; template @@ -128,6 +130,10 @@ void ParallelTaskManager::runAllTasks( const unsigned& natoms ) { myinput.noderiv = true; action->getInputData( myinput.inputdata ); + // Check if this is an actionWithMatrix object + const ActionWithMatrix* am = dynamic_cast(action); + bool ismatrix=false; if(am) ismatrix=true; + #pragma omp parallel num_threads(nt) { std::vector omp_buffer; @@ -144,6 +150,9 @@ void ParallelTaskManager::runAllTasks( const unsigned& natoms ) { myinput.task_index = partialTaskList[i]; runTask( myinput, myvals[t] ); + // Transfer the data to the values + if( !ismatrix ) transferToValue( partialTaskList[i], myvals[t] ); + // Clear the value myvals[t].clearAll(); } @@ -158,15 +167,16 @@ void ParallelTaskManager::runAllTasks( const unsigned& natoms ) { } template -void ParallelTaskManager::runTask( const ParallelActionsInput& locinp, MultiValue& myvals ) const { - const ActionWithMatrix* am = dynamic_cast(action); +void ParallelTaskManager::runTask( const ParallelActionsInput& locinp, MultiValue& myvals ) { myvals.setTaskIndex(locinp.task_index); T::performTask( locinp, myvals ); - if( am ) return ; +} +template +void ParallelTaskManager::transferToValue( const unsigned& task_index, const MultiValue& myvals ) const { for(unsigned i=0; igetNumberOfComponents(); ++i) { const Value* myval = action->getConstPntrToComponent(i); if( myval->hasDerivatives() || (action->getName()=="RMSD_VECTOR" && myval->getRank()==2) ) continue; - Value* myv = const_cast( myval ); myv->set( locinp.task_index, myvals.get( i ) ); + Value* myv = const_cast( myval ); myv->set( task_index, myvals.get( i ) ); } }