Fixing assignment algorithm, who gave too many assignments by worker. Now, when using static assignment, the optimal size of packet (so as each worker has to process only one packet of data) is sent.
This commit is contained in:
parent
d711369f12
commit
f963a15fbe
3 changed files with 16 additions and 11 deletions
|
|
@ -35,6 +35,9 @@
|
|||
#include <mpi/eoTerminateJob.h>
|
||||
#include <mpi/eoMpiAssignmentAlgorithm.h>
|
||||
#include <mpi/eoParallelApply.h>
|
||||
#include <utils/eoParallel.h>
|
||||
|
||||
#include <cmath> // ceil
|
||||
# endif // WITH_MPI
|
||||
|
||||
/** eoPopEvalFunc: This abstract class is for GLOBAL evaluators
|
||||
|
|
@ -192,7 +195,12 @@ class eoParallelPopLoopEval : public eoPopEvalFunc<EOT>
|
|||
(void)_parents;
|
||||
// Reinits the store and the scheduling algorithm
|
||||
store->data( _offspring );
|
||||
assignAlgo.reinit( _offspring.size() );
|
||||
// For static scheduling, it's mandatory to reinit attributions
|
||||
int nbWorkers = assignAlgo.availableWorkers();
|
||||
assignAlgo.reinit( nbWorkers );
|
||||
if( ! eo::parallel.isDynamic() ) {
|
||||
store->data()->packetSize = ceil( static_cast<double>( _offspring.size() ) / nbWorkers );
|
||||
}
|
||||
// Effectively launches the job.
|
||||
eo::mpi::ParallelApply<EOT> job( assignAlgo, masterRank, *store );
|
||||
job.run();
|
||||
|
|
|
|||
|
|
@ -137,7 +137,10 @@ namespace eo
|
|||
{
|
||||
unsigned int nbWorkers = workers.size();
|
||||
freeWorkers = nbWorkers;
|
||||
|
||||
attributions.clear();
|
||||
attributions.reserve( nbWorkers );
|
||||
busy.clear();
|
||||
busy.resize( nbWorkers, false );
|
||||
|
||||
// Let be the euclidean division of runs by nbWorkers :
|
||||
|
|
|
|||
|
|
@ -37,8 +37,6 @@ namespace eo
|
|||
{
|
||||
size = _pop->size();
|
||||
}
|
||||
|
||||
tempArray = new EOT[ _packetSize ];
|
||||
}
|
||||
|
||||
void init( std::vector<EOT>& _pop )
|
||||
|
|
@ -49,11 +47,6 @@ namespace eo
|
|||
assignedTasks.clear();
|
||||
}
|
||||
|
||||
~ParallelApplyData()
|
||||
{
|
||||
delete [] tempArray;
|
||||
}
|
||||
|
||||
std::vector<EOT>& data()
|
||||
{
|
||||
return *_data;
|
||||
|
|
@ -65,7 +58,7 @@ namespace eo
|
|||
int size;
|
||||
std::map< int /* worker rank */, ParallelApplyAssignment /* min indexes in vector */> assignedTasks;
|
||||
int packetSize;
|
||||
EOT* tempArray;
|
||||
std::vector<EOT> tempArray;
|
||||
|
||||
int masterRank;
|
||||
bmpi::communicator& comm;
|
||||
|
|
@ -140,14 +133,15 @@ namespace eo
|
|||
int recvSize;
|
||||
|
||||
d->comm.recv( d->masterRank, 1, recvSize );
|
||||
d->comm.recv( d->masterRank, 1, d->tempArray, recvSize );
|
||||
d->tempArray.resize( recvSize );
|
||||
d->comm.recv( d->masterRank, 1, & d->tempArray[0] , recvSize );
|
||||
timerStat.start("worker_processes");
|
||||
for( int i = 0; i < recvSize ; ++i )
|
||||
{
|
||||
d->func( d->tempArray[ i ] );
|
||||
}
|
||||
timerStat.stop("worker_processes");
|
||||
d->comm.send( d->masterRank, 1, d->tempArray, recvSize );
|
||||
d->comm.send( d->masterRank, 1, & d->tempArray[0], recvSize );
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Reference in a new issue