Xmipp
v3.23.11-Nereus
|
#include <xmipp_threads.h>
Public Member Functions | |
ParallelTaskDistributor (size_t nTasks, size_t bSize) | |
virtual | ~ParallelTaskDistributor () |
void | clear () |
void | setBlockSize (size_t bSize) |
int | getBlockSize () const |
bool | getTasks (size_t &first, size_t &last) |
bool | setAssignedTasks (size_t tasks) |
Public Attributes | |
size_t | numberOfTasks |
Protected Member Functions | |
virtual void | lock ()=0 |
virtual void | unlock ()=0 |
virtual bool | distribute (size_t &first, size_t &last)=0 |
Protected Attributes | |
size_t | blockSize |
size_t | assignedTasks |
This class distributes dynamically N tasks between parallel workers.
This class is a generalization of a common task in a parallel environment of dynamically distribute N tasks between workers(threads or mpi process). Each worker will ask for a group of tasks, process it and ask for more tasks until there is not more task to process.
This class is abstract and only serves as base for concrete implementations, which will provides the specific lock mechanisms and the way of distribution.
Definition at line 366 of file xmipp_threads.h.
ParallelTaskDistributor::ParallelTaskDistributor | ( | size_t | nTasks, |
size_t | bSize | ||
) |
Constructor. The number of jobs and block size should be provided.Constructor for Master node.
Definition at line 289 of file xmipp_threads.cpp.
|
inlinevirtual |
void ParallelTaskDistributor::clear | ( | ) |
Restart the number of assigned tasks and distribution again. This method should only be called in the main thread before start distributing the tasks between the workers threads.
Definition at line 299 of file xmipp_threads.cpp.
|
protectedpure virtual |
Implemented in ThreadTaskDistributor, and MpiTaskDistributor.
int ParallelTaskDistributor::getBlockSize | ( | ) | const |
Return the number of tasks assigned in each request
Definition at line 313 of file xmipp_threads.cpp.
bool ParallelTaskDistributor::getTasks | ( | size_t & | first, |
size_t & | last | ||
) |
Gets parallel tasks.
This function will be called by workers for asking tasks until there are not more tasks to process. Example:
Definition at line 318 of file xmipp_threads.cpp.
|
protectedpure virtual |
Implemented in ThreadTaskDistributor.
bool ParallelTaskDistributor::setAssignedTasks | ( | size_t | tasks | ) |
Definition at line 326 of file xmipp_threads.cpp.
void ParallelTaskDistributor::setBlockSize | ( | size_t | bSize | ) |
Set the number of tasks assigned in each request
Definition at line 306 of file xmipp_threads.cpp.
|
protectedpure virtual |
Implemented in ThreadTaskDistributor.
|
protected |
Definition at line 372 of file xmipp_threads.h.
|
protected |
Definition at line 370 of file xmipp_threads.h.
size_t ParallelTaskDistributor::numberOfTasks |
Definition at line 376 of file xmipp_threads.h.