EvolvingObjects
|
Assignment (scheduling) algorithm which handles workers in a queue. More...
#include <eoMpiAssignmentAlgorithm.h>
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 |
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.
Definition at line 111 of file eoMpiAssignmentAlgorithm.h.
eo::mpi::DynamicAssignmentAlgorithm::DynamicAssignmentAlgorithm | ( | int | unique | ) | [inline] |
Uses the unique host with given rank as a worker.
unique | MPI 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.
workers | std::vector containing MPI ranks of workers. |
Definition at line 141 of file eoMpiAssignmentAlgorithm.h.
eo::mpi::DynamicAssignmentAlgorithm::DynamicAssignmentAlgorithm | ( | int | first, |
int | last | ||
) | [inline] |
Uses a range of ranks as workers.
first | The first worker to be included (inclusive) |
last | The 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.
virtual int eo::mpi::DynamicAssignmentAlgorithm::get | ( | ) | [inline, virtual] |
Gets the rank of an available worker, so as to send it a task.
Implements eo::mpi::AssignmentAlgorithm.
Definition at line 166 of file eoMpiAssignmentAlgorithm.h.
int eo::mpi::DynamicAssignmentAlgorithm::availableWorkers | ( | ) | [inline, virtual] |
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.
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.
wrkRank | The 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.
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.
Implements eo::mpi::AssignmentAlgorithm.
Definition at line 192 of file eoMpiAssignmentAlgorithm.h.