diff --git a/eo/src/mpi/assignmentAlgorithm.h b/eo/src/mpi/assignmentAlgorithm.h index 58fc09c0..a27e8289 100644 --- a/eo/src/mpi/assignmentAlgorithm.h +++ b/eo/src/mpi/assignmentAlgorithm.h @@ -3,6 +3,12 @@ # include # include "MpiNode.h" + +namespace eo +{ + const int REST_OF_THE_WORLD = -1; +} + struct AssignmentAlgorithm { virtual int get( ) = 0; @@ -35,6 +41,11 @@ struct DynamicAssignmentAlgorithm : public AssignmentAlgorithm DynamicAssignmentAlgorithm( int first, int last ) { + if( last == eo::REST_OF_THE_WORLD ) + { + last = MpiNode::comm().size() - 1; + } + for( int i = first; i <= last; ++i) { availableWrk.push_back( i ); @@ -82,6 +93,12 @@ struct StaticAssignmentAlgorithm : public AssignmentAlgorithm StaticAssignmentAlgorithm( int first, int last, int runs ) { std::vector workers; + + if( last == eo::REST_OF_THE_WORLD ) + { + last = MpiNode::comm().size() - 1; + } + for(int i = first; i <= last; ++i) { workers.push_back( i ); diff --git a/eo/test/mpi/multipleRoles.cpp b/eo/test/mpi/multipleRoles.cpp index a374def5..6fa930d1 100644 --- a/eo/test/mpi/multipleRoles.cpp +++ b/eo/test/mpi/multipleRoles.cpp @@ -24,7 +24,7 @@ struct plusOne : public eoUF< int&, void > void subtask( vector& v ) { - DynamicAssignmentAlgorithm algo( 2, MpiNode::comm().size()-1 ); + DynamicAssignmentAlgorithm algo( 2, eo::REST_OF_THE_WORLD ); plusOne plusOneInstance; ParallelApply job( plusOneInstance, v, algo, 1 ); job.run(); diff --git a/eo/test/mpi/parallelApply.cpp b/eo/test/mpi/parallelApply.cpp index 3fd77dc1..5a6b64f2 100644 --- a/eo/test/mpi/parallelApply.cpp +++ b/eo/test/mpi/parallelApply.cpp @@ -44,7 +44,7 @@ int main(int argc, char** argv) const int ALL = MpiNode::comm().size(); Test tIntervalStatic; - tIntervalStatic.assign = new StaticAssignmentAlgorithm( 1, MpiNode::comm().size()-1, v.size() ); + tIntervalStatic.assign = new StaticAssignmentAlgorithm( 1, eo::REST_OF_THE_WORLD, v.size() ); tIntervalStatic.description = "Correct static assignment with interval."; tIntervalStatic.requiredNodesNumber = ALL; tests.push_back( tIntervalStatic ); @@ -77,26 +77,26 @@ int main(int argc, char** argv) tests.push_back( tVectorStatic ); Test tIntervalDynamic; - tIntervalDynamic.assign = new StaticAssignmentAlgorithm( 1, MpiNode::comm().size()-1, v.size() ); - tIntervalDynamic.description = "Correct static assignment with interval."; + tIntervalDynamic.assign = new StaticAssignmentAlgorithm( 1, eo::REST_OF_THE_WORLD, v.size() ); + tIntervalDynamic.description = "Dynamic assignment with interval."; tIntervalDynamic.requiredNodesNumber = ALL; tests.push_back( tIntervalDynamic ); Test tUniqueDynamic; tUniqueDynamic.assign = new StaticAssignmentAlgorithm( 1, v.size() ); - tUniqueDynamic.description = "Correct static assignment with unique worker."; + tUniqueDynamic.description = "Dynamic assignment with unique worker."; tUniqueDynamic.requiredNodesNumber = 2; tests.push_back( tUniqueDynamic ); Test tVectorDynamic; tVectorDynamic.assign = new StaticAssignmentAlgorithm( workers, v.size() ); - tVectorDynamic.description = "Correct static assignment with precise workers specified."; + tVectorDynamic.description = "Dynamic assignment with precise workers specified."; tVectorDynamic.requiredNodesNumber = tVectorStatic.requiredNodesNumber; tests.push_back( tVectorDynamic ); Test tWorldDynamic; tWorldDynamic.assign = new StaticAssignmentAlgorithm( v.size() ); - tWorldDynamic.description = "Correct static assignment with whole world as workers."; + tWorldDynamic.description = "Dynamic assignment with whole world as workers."; tWorldDynamic.requiredNodesNumber = ALL; tests.push_back( tWorldDynamic );