EvolvingObjects
eo::mpi::Job< JobData > Class Template Reference

Class implementing the centralized job algorithm. More...

#include <eoMpi.h>

Inheritance diagram for eo::mpi::Job< JobData >:
eo::mpi::MultiJob< JobData > eo::mpi::OneShotJob< JobData >

List of all members.

Classes

struct  FinallyBlock
 Finally block of the main algorithm. More...

Public Member Functions

 Job (AssignmentAlgorithm &_algo, int _masterRank, int _workerStopCondition, JobStore< JobData > &_store)
 Main constructor for Job.
void run ()
 Launches the job algorithm, according to the role of the host (roles are deduced from the master rank indicated in the constructor).
bool isMaster ()
 Returns true if the current host is the master, false otherwise.

Protected Member Functions

void master ()
 Master part of the job.
void worker ()
 Worker part of the algorithm.

Protected Attributes

AssignmentAlgorithmassignmentAlgo
int masterRank
const int workerStopCondition
bmpi::communicator & comm
JobStore< JobData > & store
SendTaskFunction< JobData > & sendTask
HandleResponseFunction< JobData > & handleResponse
ProcessTaskFunction< JobData > & processTask
IsFinishedFunction< JobData > & isFinished
bool _isMaster

Detailed Description

template<class JobData>
class eo::mpi::Job< JobData >

Class implementing the centralized job algorithm.

This class handles all the job algorithm. With its store and its assignment (scheduling) algorithm, it executes the general algorithm described above, adding some networking, so as to make the global process work. It initializes all the functors with the data, then launches the main loop, indicating to workers when they will have to work and when they will finish, by sending them a termination message (integer that can be customized). As the algorithm is centralized, it is also mandatory to indicate what is the MPI rank of the master process, hence the workers will know from who they should receive their commands.

Any of the 3 master functors can launch exception, it will be catched and rethrown as a std::runtime_exception to the higher layers.

Definition at line 533 of file eoMpi.h.


Constructor & Destructor Documentation

template<class JobData>
eo::mpi::Job< JobData >::Job ( AssignmentAlgorithm _algo,
int  _masterRank,
int  _workerStopCondition,
JobStore< JobData > &  _store 
) [inline]

Main constructor for Job.

Parameters:
_algoThe used assignment (scheduling) algorithm. It has to be initialized, with its maximum possible number of workers (some workers referenced in this algorithm shouldn't be busy). See AssignmentAlgorithm for more details.
_masterRankThe MPI rank of the master.
_workerStopConditionNumber of the message which will cause the workers to terminate. It could be one of the constants defined in eo::mpi::Commands, or any other integer. The user has to be sure that a message containing this integer will be sent to each worker on the Commands channel, otherwise deadlock will happen. Master sends Finish messages at the end of a simple job, but as a job can happen multiples times (multi job), workers don't have to really finish on these messages but on another message. This is here where you can configurate it. See also OneShotJob and MultiJob.
storeThe JobStore containing functors and data for this job.

Definition at line 554 of file eoMpi.h.


Member Function Documentation

template<class JobData>
void eo::mpi::Job< JobData >::master ( ) [inline, protected]

Master part of the job.

Launches the parallelized job algorithm : while there is something to do (! IsFinished ), get a worker who will be the assignee ; if no worker is available, wait for a response, handle it and reask for an assignee. Then send the command and the task. Once there is no more to do (IsFinished), indicate to all available workers that they're free, wait for all the responses and send termination messages (see also FinallyBlock).

Definition at line 658 of file eoMpi.h.

Referenced by eo::mpi::Job< void >::run().

template<class JobData>
void eo::mpi::Job< JobData >::worker ( ) [inline, protected]

Worker part of the algorithm.

The algorithm is more much simpler: wait for an order; if it's termination message, leave. Otherwise, prepare to work.

Definition at line 709 of file eoMpi.h.

Referenced by eo::mpi::Job< void >::run().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Friends