EvolvingObjects
eo::mpi::StaticAssignmentAlgorithm Struct Reference

Assignment algorithm which gives to each worker a precise number of tasks to do, in a round robin fashion. More...

#include <eoMpiAssignmentAlgorithm.h>

Inheritance diagram for eo::mpi::StaticAssignmentAlgorithm:
eo::mpi::AssignmentAlgorithm

List of all members.

Public Member Functions

 StaticAssignmentAlgorithm (std::vector< int > &workers, int runs)
 Uses a given precise set of workers.
 StaticAssignmentAlgorithm (int first, int last, int runs)
 Uses a range of workers.
 StaticAssignmentAlgorithm (int runs=0)
 Uses all the hosts whose rank is higher than 1 (inclusive) as workers.
 StaticAssignmentAlgorithm (int unique, int runs)
 Uses an unique host as worker.
int get ()
 Gets the rank of an available worker, so as to send it a task.
int availableWorkers ()
 Gets the number of total available workers.
std::vector< int > idles ()
 Indicates who are the workers which do nothing.
void confirm (int rank)
 Reinject the worker of indicated rank in the available state.
void reinit (int runs)
 Reinitializes the assignment algorithm with the right number of runs.

Private Member Functions

void init (std::vector< int > &workers, int runs)
 Initializes the static scheduling.

Private Attributes

std::vector< int > attributions
std::vector< int > realRank
std::vector< bool > busy
unsigned int freeWorkers

Detailed Description

Assignment algorithm which gives to each worker a precise number of tasks to do, in a round robin fashion.

This scheduling algorithm attributes, at initialization or when calling reinit(), a fixed amount of runs to distribute to the workers. The amount of runs is then equally distributed between all workers ; if total number of runs is not a direct multiple of workers number, then remainding unaffected runs are distributed to workers from the first to the last, in a round-robin fashion.

This scheduling should be used when the amount of runs can be computed or is fixed and when we guess that the duration of processing task will be the same for each run. There is no warranty that this algorithm is more or less efficient that another one. When having a doubt, use DynamicAssignmentAlgorithm.

Examples:
t-mpi-parallelApply.cpp, and t-mpi-wrapper.cpp.

Definition at line 217 of file eoMpiAssignmentAlgorithm.h.


Constructor & Destructor Documentation

eo::mpi::StaticAssignmentAlgorithm::StaticAssignmentAlgorithm ( std::vector< int > &  workers,
int  runs 
) [inline]

Uses a given precise set of workers.

Parameters:
workersstd::vector of MPI ranks of workers which will be used.
runsFixed amount of runs, strictly positive.

Definition at line 226 of file eoMpiAssignmentAlgorithm.h.

References init().

eo::mpi::StaticAssignmentAlgorithm::StaticAssignmentAlgorithm ( int  first,
int  last,
int  runs 
) [inline]

Uses a range of workers.

Parameters:
firstThe first MPI rank of worker to use
lastThe last MPI rank of worker to use. If it's equal to REST_OF_THE_WORLD, then all the workers from the first one are taken as workers.
runsFixed amount of runs, strictly positive.

Definition at line 239 of file eoMpiAssignmentAlgorithm.h.

References eo::mpi::Node::comm(), init(), and eo::mpi::REST_OF_THE_WORLD.

Uses all the hosts whose rank is higher than 1 (inclusive) as workers.

Parameters:
runsFixed amount of runs, strictly positive. If it's not set, you'll have to call reinit() later.

Definition at line 261 of file eoMpiAssignmentAlgorithm.h.

References eo::mpi::Node::comm(), and init().

eo::mpi::StaticAssignmentAlgorithm::StaticAssignmentAlgorithm ( int  unique,
int  runs 
) [inline]

Uses an unique host as worker.

Parameters:
uniqueThe MPI rank of the host which will be the worker.
runsFixed amount of runs, strictly positive.

Definition at line 278 of file eoMpiAssignmentAlgorithm.h.

References init().


Member Function Documentation

void eo::mpi::StaticAssignmentAlgorithm::init ( std::vector< int > &  workers,
int  runs 
) [inline, private]

Initializes the static scheduling.

Gives to each worker an equal attribution number, equal to runs / workers.size(), eventually plus one if number of workers is not a divisor of runs.

Parameters:
workersVector of hosts' ranks
runsFixed amount of runs, strictly positive.

Definition at line 295 of file eoMpiAssignmentAlgorithm.h.

Referenced by reinit(), and StaticAssignmentAlgorithm().

int eo::mpi::StaticAssignmentAlgorithm::get ( ) [inline, virtual]

Gets the rank of an available worker, so as to send it a task.

Returns:
The MPI rank of an available worker, or -1 if there is no available worker.

Implements eo::mpi::AssignmentAlgorithm.

Definition at line 323 of file eoMpiAssignmentAlgorithm.h.

Gets the number of total available workers.

Before the first call, it is equal to the total number of present workers, as specified in the specific assignment algorithm constructor. It allows the Job class to know when all the responses have been received, by comparing this number to the total number of workers.

Returns:
Integer indicating how many workers are available.

Implements eo::mpi::AssignmentAlgorithm.

Definition at line 339 of file eoMpiAssignmentAlgorithm.h.

std::vector<int> eo::mpi::StaticAssignmentAlgorithm::idles ( ) [inline, virtual]

Indicates who are the workers which do nothing.

At the end of the algorithm, the master has to warn all the workers that it's done. All the workers mean, the workers which are currently processing data, and the other ones who could be waiting : the idles. This function indicates to the master which worker aren't doing anything.

Returns:
A std::vector containing all the MPI ranks of the idles workers.

Implements eo::mpi::AssignmentAlgorithm.

Definition at line 344 of file eoMpiAssignmentAlgorithm.h.

void eo::mpi::StaticAssignmentAlgorithm::confirm ( int  wrkRank) [inline, virtual]

Reinject the worker of indicated rank in the available state.

Parameters:
wrkRankThe MPI rank of the worker who has finished its job.

Implements eo::mpi::AssignmentAlgorithm.

Definition at line 357 of file eoMpiAssignmentAlgorithm.h.

void eo::mpi::StaticAssignmentAlgorithm::reinit ( int  runs) [inline, virtual]

Reinitializes the assignment algorithm with the right number of runs.

In fact, this is only useful for static assignment algorithm, which has to be reinitialized every time it's used, in the case of a Multi Job. It's the user's responsability to call this function.

Todo:
Not really clean. Find a better way to do it.

Implements eo::mpi::AssignmentAlgorithm.

Definition at line 374 of file eoMpiAssignmentAlgorithm.h.

References init().


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