PaGMO
1.1.5
|
MPI environment class. More...
#include <mpi_environment.h>
Inherits noncopyable.
Public Member Functions | |
mpi_environment () | |
Default constructor. More... | |
~mpi_environment () | |
Destructor. More... | |
Static Public Member Functions | |
static bool | is_multithread () |
Thread-safety of the MPI implementation. More... | |
static int | get_size () |
MPI world size. More... | |
static int | get_rank () |
MPI rank. More... | |
template<class T > | |
static void | recv (T &retval, int source) |
Receive MPI payload. More... | |
template<class T > | |
static void | send (const T &payload, int destination) |
Send MPI payload. More... | |
static bool | iprobe (int) |
Probe for message. More... | |
MPI environment class.
This class is used to initialise the PaGMO MPI environment: an instance of this class should be created before using any MPI feature in PaGMO. Apart from this kind of usage, regular users should never need to access any method from this class. See the MPI page for a usage example.
NOTE: this class is available only if PaGMO was compiled with MPI support.
Definition at line 174 of file mpi_environment.h.
pagmo::mpi_environment::mpi_environment | ( | ) |
Default constructor.
Initialises the MPI environment with MPI_Init_thread. pagmo::mpi_environment objects should be created only in the main thread of execution.
std::runtime_error | if another instance of this class has already been created, or if the MPI implementation does not support at least the MPI_THREAD_SERIALIZED thread level and this is the root node, or if the world size is not at least 2. |
Definition at line 51 of file mpi_environment.cpp.
pagmo::mpi_environment::~mpi_environment | ( | ) |
Destructor.
Will send a shutdown signal to all processes with nonzero rank and call MPI_Finalize().
Definition at line 81 of file mpi_environment.cpp.
|
static |
MPI rank.
This method is thread-safe only if mpi_environment::is_multithread returns true.
std::runtime_error | if the MPI environment has not been initialised. |
Definition at line 145 of file mpi_environment.cpp.
|
static |
MPI world size.
This method is thread-safe only if mpi_environment::is_multithread returns true.
std::runtime_error | if the MPI environment has not been initialised. |
Definition at line 129 of file mpi_environment.cpp.
|
static |
Probe for message.
This method is thread-safe only if mpi_environment::is_multithread returns true.
[in] | source | rank of the processor that will be probed. |
std::runtime_error | if the MPI environment has not been initialised. |
Definition at line 112 of file mpi_environment.cpp.
|
static |
Thread-safety of the MPI implementation.
This method is always thread-safe.
std::runtime_error | if the MPI environment has not been initialised. |
Definition at line 162 of file mpi_environment.cpp.
|
inlinestatic |
Receive MPI payload.
Receive an instance of class T from the processor with ID source and store it into retval. This method is thread-safe only if mpi_environment::is_multithread returns true.
[out] | retval | instance of class T that will contain the payload. |
[in] | source | rank of the processor from which the message will be received. |
Definition at line 191 of file mpi_environment.h.
|
inlinestatic |
Send MPI payload.
Send an instance of class T to the processor with ID destination. This method is thread-safe only if mpi_environment::is_multithread returns true.
[in] | payload | instance of class T that will be sent to destination. |
[in] | destination | rank of the processor to which the message will be sent. |
Definition at line 218 of file mpi_environment.h.