MultiJob and OneShotJob allow to choose job's way of termination (Kill for multi, Finish for one shot).
This commit is contained in:
parent
6600f1db51
commit
008f2571b2
3 changed files with 37 additions and 5 deletions
|
|
@ -199,10 +199,12 @@ namespace eo
|
|||
public:
|
||||
Job( AssignmentAlgorithm& _algo,
|
||||
int _masterRank,
|
||||
int _workerStopCondition,
|
||||
JobStore<JobData> & store
|
||||
) :
|
||||
assignmentAlgo( _algo ),
|
||||
masterRank( _masterRank ),
|
||||
workerStopCondition( _workerStopCondition ),
|
||||
comm( Node::comm() ),
|
||||
// Functors
|
||||
sendTask( store.sendTask() ),
|
||||
|
|
@ -339,7 +341,7 @@ namespace eo
|
|||
# ifndef NDEBUG
|
||||
eo::log << "[W" << comm.rank() << "] Waiting for an order..." << std::endl;
|
||||
# endif
|
||||
if ( order == Message::Kill )
|
||||
if ( order == workerStopCondition )
|
||||
{
|
||||
# ifndef NDEBUG
|
||||
eo::log << "[W" << comm.rank() << "] Leaving worker task." << std::endl;
|
||||
|
|
@ -375,6 +377,7 @@ namespace eo
|
|||
|
||||
AssignmentAlgorithm& assignmentAlgo;
|
||||
int masterRank;
|
||||
const int workerStopCondition;
|
||||
bmpi::communicator& comm;
|
||||
|
||||
SendTaskFunction<JobData> & sendTask;
|
||||
|
|
@ -383,6 +386,35 @@ namespace eo
|
|||
IsFinishedFunction<JobData> & isFinished;
|
||||
|
||||
bool _isMaster;
|
||||
|
||||
};
|
||||
|
||||
template< class JobData >
|
||||
class OneShotJob : public Job< JobData >
|
||||
{
|
||||
// TODO commentaire : ce job s'arrête sur message terminate
|
||||
public:
|
||||
OneShotJob( AssignmentAlgorithm& algo,
|
||||
int masterRank,
|
||||
JobStore<JobData> & store )
|
||||
: Job<JobData>( algo, masterRank, Message::Finish, store )
|
||||
{
|
||||
// empty
|
||||
}
|
||||
};
|
||||
|
||||
template< class JobData >
|
||||
class MultiJob : public Job< JobData >
|
||||
{
|
||||
public:
|
||||
// TODO commentaire : ce job s'arrête sur message kill
|
||||
MultiJob ( AssignmentAlgorithm& algo,
|
||||
int masterRank,
|
||||
JobStore<JobData> & store )
|
||||
: Job<JobData>( algo, masterRank, Message::Kill, store )
|
||||
{
|
||||
// empty
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ namespace eo
|
|||
// TODO commentaire : impossible de faire un typedef sur un template sans passer
|
||||
// par un traits => complique la tâche de l'utilisateur pour rien.
|
||||
template< typename EOT >
|
||||
class ParallelApply : public Job< ParallelApplyData<EOT> >
|
||||
class ParallelApply : public MultiJob< ParallelApplyData<EOT> >
|
||||
{
|
||||
public:
|
||||
|
||||
|
|
@ -216,7 +216,7 @@ namespace eo
|
|||
int _masterRank,
|
||||
ParallelApplyStore<EOT> & store
|
||||
) :
|
||||
Job< ParallelApplyData<EOT> >( algo, _masterRank, store )
|
||||
MultiJob< ParallelApplyData<EOT> >( algo, _masterRank, store )
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,10 +65,10 @@ namespace eo
|
|||
void* data() { return 0; }
|
||||
};
|
||||
|
||||
struct EmptyJob : public Job<void>
|
||||
struct EmptyJob : public OneShotJob<void>
|
||||
{
|
||||
EmptyJob( AssignmentAlgorithm& algo, int masterRank ) :
|
||||
Job<void>( algo, masterRank, *(new DummyJobStore) )
|
||||
OneShotJob<void>( algo, masterRank, *(new DummyJobStore) )
|
||||
// FIXME memory leak => will be corrected by using const correctness
|
||||
{
|
||||
// empty
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue