|
Pakman
|
#include <PakmanMPIWorker.hpp>
Public Member Functions | |
| PakmanMPIWorker (std::function< int(int argc, char **argv, const std::string &input_string, std::string &output_string)> simulator) | |
| ~PakmanMPIWorker ()=default | |
| int | run (int argc, char *argv[]) |
Static Public Attributes | |
| static constexpr int | PAKMAN_EXIT_SUCCESS = 0 |
| static constexpr int | PAKMAN_EXIT_FAILURE = 1 |
A class for implementing Pakman MPI Workers.
Since MPI simulators cannot be forked directly when using MPIMaster, the MPI function MPI_Comm_spawn is used instead to spawn MPI Workers. As a consequence, the communication between Pakman and MPI Workers does not happen through system pipes, but through the MPI intercommunicator obtained with MPI_Comm_get_parent.
Most importantly, the MPI simulator can no longer be considered a black box at the systems-level. Instead, the simulator must be implemented as a function or function object in C++ (see pakman_mpi_worker.h for C), and passed to the constructor of this class. The run() method will then communicate with Pakman and execute the simulator function to perform the received simulation tasks.
Note that MPI_Init() should be called before calling run(). Also, after run() returns, MPI_Finalize() should be called.
For more information, see Implementing an MPI simulator.
Definition at line 31 of file PakmanMPIWorker.hpp.
| PakmanMPIWorker::PakmanMPIWorker | ( | std::function< int(int argc, char **argv, const std::string &input_string, std::string &output_string)> | simulator | ) |
Constructor from simulator function.
The simulator function must accept four arguments;
In addition, the simulator function must return an error code.
| simulator | simulator function |
Definition at line 104 of file PakmanMPIWorker.hpp.
|
default |
Default destructor does nothing.
| int PakmanMPIWorker::run | ( | int | argc, |
| char * | argv[] | ||
| ) |
Run the Pakman MPI Worker with the given simulator function.
| argc | number of command-line arguments. |
| argv | array of command-line arguments. |
Definition at line 111 of file PakmanMPIWorker.hpp.
|
static |
Exit code indicating Worker encountered an error.
Definition at line 67 of file PakmanMPIWorker.hpp.
|
static |
Exit code indicating Worker ran successfully.
Definition at line 64 of file PakmanMPIWorker.hpp.