Skip to content

Commit

Permalink
Made runTask a static method in ParallelTaskManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Gareth Aneurin Tribello committed Feb 5, 2025
1 parent 4125913 commit c4f20aa
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/core/ParallelTaskManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <class T>
Expand Down Expand Up @@ -128,6 +130,10 @@ void ParallelTaskManager<T>::runAllTasks( const unsigned& natoms ) {
myinput.noderiv = true;
action->getInputData( myinput.inputdata );

// Check if this is an actionWithMatrix object
const ActionWithMatrix* am = dynamic_cast<const ActionWithMatrix*>(action);
bool ismatrix=false; if(am) ismatrix=true;

#pragma omp parallel num_threads(nt)
{
std::vector<double> omp_buffer;
Expand All @@ -144,6 +150,9 @@ void ParallelTaskManager<T>::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();
}
Expand All @@ -158,15 +167,16 @@ void ParallelTaskManager<T>::runAllTasks( const unsigned& natoms ) {
}

template <class T>
void ParallelTaskManager<T>::runTask( const ParallelActionsInput& locinp, MultiValue& myvals ) const {
const ActionWithMatrix* am = dynamic_cast<const ActionWithMatrix*>(action);
void ParallelTaskManager<T>::runTask( const ParallelActionsInput& locinp, MultiValue& myvals ) {
myvals.setTaskIndex(locinp.task_index); T::performTask( locinp, myvals );
if( am ) return ;
}

template <class T>
void ParallelTaskManager<T>::transferToValue( const unsigned& task_index, const MultiValue& myvals ) const {
for(unsigned i=0; i<action->getNumberOfComponents(); ++i) {
const Value* myval = action->getConstPntrToComponent(i);
if( myval->hasDerivatives() || (action->getName()=="RMSD_VECTOR" && myval->getRank()==2) ) continue;
Value* myv = const_cast<Value*>( myval ); myv->set( locinp.task_index, myvals.get( i ) );
Value* myv = const_cast<Value*>( myval ); myv->set( task_index, myvals.get( i ) );
}
}

Expand Down

1 comment on commit c4f20aa

@PlumedBot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found broken examples in automatic/ANGLES.tmp
Found broken examples in automatic/ANN.tmp
Found broken examples in automatic/CAVITY.tmp
Found broken examples in automatic/CLASSICAL_MDS.tmp
Found broken examples in automatic/CLUSTER_DIAMETER.tmp
Found broken examples in automatic/CLUSTER_DISTRIBUTION.tmp
Found broken examples in automatic/CLUSTER_PROPERTIES.tmp
Found broken examples in automatic/CONSTANT.tmp
Found broken examples in automatic/CONTACT_MATRIX.tmp
Found broken examples in automatic/CONTACT_MATRIX_PROPER.tmp
Found broken examples in automatic/COORDINATIONNUMBER.tmp
Found broken examples in automatic/DFSCLUSTERING.tmp
Found broken examples in automatic/DISTANCE_FROM_CONTOUR.tmp
Found broken examples in automatic/EDS.tmp
Found broken examples in automatic/EMMI.tmp
Found broken examples in automatic/ENVIRONMENTSIMILARITY.tmp
Found broken examples in automatic/FIND_CONTOUR.tmp
Found broken examples in automatic/FIND_CONTOUR_SURFACE.tmp
Found broken examples in automatic/FIND_SPHERICAL_CONTOUR.tmp
Found broken examples in automatic/FOURIER_TRANSFORM.tmp
Found broken examples in automatic/FUNCPATHGENERAL.tmp
Found broken examples in automatic/FUNCPATHMSD.tmp
Found broken examples in automatic/FUNNEL.tmp
Found broken examples in automatic/FUNNEL_PS.tmp
Found broken examples in automatic/GHBFIX.tmp
Found broken examples in automatic/GPROPERTYMAP.tmp
Found broken examples in automatic/HBOND_MATRIX.tmp
Found broken examples in automatic/INCLUDE.tmp
Found broken examples in automatic/INCYLINDER.tmp
Found broken examples in automatic/INENVELOPE.tmp
Found broken examples in automatic/INTERPOLATE_GRID.tmp
Found broken examples in automatic/LOCAL_AVERAGE.tmp
Found broken examples in automatic/MAZE_OPTIMIZER_BIAS.tmp
Found broken examples in automatic/MAZE_RANDOM_ACCELERATION_MD.tmp
Found broken examples in automatic/MAZE_SIMULATED_ANNEALING.tmp
Found broken examples in automatic/MAZE_STEERED_MD.tmp
Found broken examples in automatic/METATENSOR.tmp
Found broken examples in automatic/MULTICOLVARDENS.tmp
Found broken examples in automatic/OUTPUT_CLUSTER.tmp
Found broken examples in automatic/PAMM.tmp
Found broken examples in automatic/PCA.tmp
Found broken examples in automatic/PCAVARS.tmp
Found broken examples in automatic/PIV.tmp
Found broken examples in automatic/PLUMED.tmp
Found broken examples in automatic/PYCVINTERFACE.tmp
Found broken examples in automatic/PYTHONFUNCTION.tmp
Found broken examples in automatic/Q3.tmp
Found broken examples in automatic/Q4.tmp
Found broken examples in automatic/Q6.tmp
Found broken examples in automatic/QUATERNION.tmp
Found broken examples in automatic/SIZESHAPE_POSITION_LINEAR_PROJ.tmp
Found broken examples in automatic/SIZESHAPE_POSITION_MAHA_DIST.tmp
Found broken examples in automatic/SPRINT.tmp
Found broken examples in automatic/TETRAHEDRALPORE.tmp
Found broken examples in automatic/TORSIONS.tmp
Found broken examples in automatic/WHAM_WEIGHTS.tmp
Found broken examples in AnalysisPP.md
Found broken examples in CollectiveVariablesPP.md
Found broken examples in MiscelaneousPP.md

Please sign in to comment.