EvolvingObjects
eo::mpi::DynamicAssignmentAlgorithm Struct Reference

Assignment (scheduling) algorithm which handles workers in a queue. More...

#include <eoMpiAssignmentAlgorithm.h>

Inheritance diagram for eo::mpi::DynamicAssignmentAlgorithm:
eo::mpi::AssignmentAlgorithm

List of all members.

Public Member Functions

 DynamicAssignmentAlgorithm ()
 Uses all the hosts whose rank is higher to 1, inclusive, as workers.
 DynamicAssignmentAlgorithm (int unique)
 Uses the unique host with given rank as a worker.
 DynamicAssignmentAlgorithm (const std::vector< int > &workers)
 Uses the workers whose ranks are present in the argument as workers.
 DynamicAssignmentAlgorithm (int first, int last)
 Uses a range of ranks as workers.
virtual 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.
void confirm (int rank)
 Reinject the worker of indicated rank in the available state.
std::vector< int > idles ()
 Indicates who are the workers which do nothing.
void reinit (int _)
 Reinitializes the assignment algorithm with the right number of runs.

Protected Attributes

std::vector< int > availableWrk

Detailed Description

Assignment (scheduling) algorithm which handles workers in a queue.

With this assignment algorithm, workers are put in a queue and may be called an unlimited number of times. Whenever a worker returns, it is added to the queue, and it becomes available for the next call to get(). The available workers are all located in the queue at any time, so the number of available workers is directly equal to the size of the queue.

This kind of assignment is adapted for tasks whose execution time is stochastic or unknown, but without any warranty to be faster than other assignments.

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

Definition at line 111 of file eoMpiAssignmentAlgorithm.h.


Constructor & Destructor Documentation

Uses the unique host with given rank as a worker.

Parameters:
uniqueMPI rank of the unique worker.

Definition at line 131 of file eoMpiAssignmentAlgorithm.h.

eo::mpi::DynamicAssignmentAlgorithm::DynamicAssignmentAlgorithm ( const std::vector< int > &  workers) [inline]

Uses the workers whose ranks are present in the argument as workers.

Parameters:
workersstd::vector containing MPI ranks of workers.

Definition at line 141 of file eoMpiAssignmentAlgorithm.h.

Uses a range of ranks as workers.

Parameters:
firstThe first worker to be included (inclusive)
lastThe last worker to be included (inclusive). If last == eo::mpi::REST_OF_THE_WORLD, all hosts whose rank is higher than first are taken.

Definition at line 153 of file eoMpiAssignmentAlgorithm.h.

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


Member Function Documentation

virtual int eo::mpi::DynamicAssignmentAlgorithm::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 166 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 177 of file eoMpiAssignmentAlgorithm.h.

void eo::mpi::DynamicAssignmentAlgorithm::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 182 of file eoMpiAssignmentAlgorithm.h.

std::vector<int> eo::mpi::DynamicAssignmentAlgorithm::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 187 of file eoMpiAssignmentAlgorithm.h.

void eo::mpi::DynamicAssignmentAlgorithm::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 192 of file eoMpiAssignmentAlgorithm.h.


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