Tomographer
v5.3
Tomographer C++ Framework Documentation
|
Handles parallel execution of tasks using MPI. More...
#include <tomographer/mpi/multiprocmpi.h>
Public Types | |
typedef TaskType_ | TaskType |
typedef TaskType::StatusReportType | TaskStatusReportType |
typedef TaskCData_ | TaskCData |
typedef BaseLoggerType_ | BaseLoggerType |
typedef TaskCountIntType_ | TaskCountIntType |
typedef TaskType::ResultType | TaskResultType |
typedef FullStatusReport< TaskStatusReportType, TaskCountIntType > | FullStatusReportType |
typedef std::function< void(const FullStatusReportType &)> | FullStatusReportCallbackType |
Public Member Functions | |
TaskDispatcher (TaskCData *pcdata_, mpi::communicator &comm_, BaseLoggerType &logger_, int num_task_runs) | |
Construct the task dispatcher around the given MPI communicator. More... | |
void | run () |
Run the tasks. More... | |
bool | isMaster () const |
Whether we are the master process. More... | |
TaskCountIntType | numTaskRuns () const |
The total number of task instances that were run. More... | |
const std::vector< TaskResultType * > & | collectedTaskResults () const |
Returns the results of all the tasks. More... | |
const TaskResultType & | collectedTaskResult (std::size_t k) const |
Returns the result of the given task. More... | |
template<typename Fn > | |
void | setStatusReportHandler (Fn fnstatus) |
assign a callable to be called whenever a status report is requested More... | |
void | requestStatusReport () |
Request a status report. More... | |
template<typename IntType > | |
void | requestPeriodicStatusReport (IntType milliseconds) |
Request a status report periodically. More... | |
void | requestInterrupt () |
Interrupt all tasks as soon as possible. More... | |
Friends | |
struct | TaskMgrIface |
Handles parallel execution of tasks using MPI.
Plug into a given MPI environment to run our tasks.
The master process, i.e., the one with comm.rank()==0
, is very special. Only this process has to provide the input data (the TaskCData instance), and only that one will be able to retrieve the results at the end. It's also the only one which can request interrupts, as well as request and receive status reports.
TaskCountIntType should be a type to use to count the number of tasks. Usually there's no reason not to use an int
.
NOTE: TaskCountIntType must be a signed integer type, because we might need to use the special value -1
Definition at line 99 of file multiprocmpi.h.
|
inline |
Construct the task dispatcher around the given MPI communicator.
The const data structure must have been initialized ONLY BY THE MASTER PROCESS (defined as the one with comm_.rank()==0
), and all other processes are required to pass NULL to the pcdata_ argument here.
Definition at line 318 of file multiprocmpi.h.
|
inline |
Returns the result of the given task.
Definition at line 966 of file multiprocmpi.h.
|
inline |
Returns the results of all the tasks.
Definition at line 955 of file multiprocmpi.h.
|
inline |
Whether we are the master process.
Only the master process can query the task results.
Definition at line 937 of file multiprocmpi.h.
|
inline |
The total number of task instances that were run.
Definition at line 943 of file multiprocmpi.h.
|
inline |
Interrupt all tasks as soon as possible.
As soon as the tasks notice this request, they will quit. Any computation performed until then is undefined, and the run() function throws a TasksInterruptedException.
Definition at line 1039 of file multiprocmpi.h.
|
inline |
Request a status report periodically.
After this function is called, a status report will be automatically deliviered every milliseconds milliseconds to the handler set by setStatusReportHandler().
Pass -1 to cancel the periodic status reporting.
Definition at line 1024 of file multiprocmpi.h.
|
inline |
Request a status report.
This function makes a note that a status report has been requested. Subsequently, the currently running task should notice it (provided it regularly queries for status report requests as described on the page Task Interface), and provides a status report. This status report, along with some additional information such as overall progress in number of task forms the full status report which is passed on to the callback set with setStatusReportHandler().
Definition at line 1007 of file multiprocmpi.h.
|
inline |
Run the tasks.
Definition at line 349 of file multiprocmpi.h.
|
inline |
assign a callable to be called whenever a status report is requested
This function remembers the given fnstatus callable, so that each time that requestStatusReport() is called at any later point, then this callback will be invoked.
The callback, when invoked, will be called with a single parameter of type FullStatusReport<TaskStatusReportType>.
Definition at line 988 of file multiprocmpi.h.