OpenMPCD
|
Wraps MPI functionality. More...
#include <MPI.hpp>
Public Member Functions | |
MPI () | |
The constructor. More... | |
~MPI () | |
The destructor. More... | |
std::size_t | getNumberOfProcesses () const |
Returns the total number of processes. More... | |
std::size_t | getRank () const |
Returns the rank of the current process. More... | |
template<typename T > | |
void | broadcast (T *const buffer, const std::size_t count, const std::size_t root) const |
Implements the MPI_BCAST functionality. More... | |
void | barrier () |
Implements the MPI_BARRIER functionality. More... | |
bool | test (MPI_Request *const request, std::size_t *const sender=NULL) const |
Calls MPI_TEST on the given request. More... | |
Wraps MPI functionality.
The first instance of this class that is constructed in a program will initialize the MPI library, and will also finalize it once it is destructed. After that point, no new instances of this class may be constructed, and at that point, no other instances of this class may exist.
All functions can throw OpenMPCD::Exception
in case of an MPI error.
void OpenMPCD::MPI::barrier | ( | ) |
void OpenMPCD::MPI::broadcast | ( | T *const | buffer, |
const std::size_t | count, | ||
const std::size_t | root | ||
) | const |
Implements the MPI_BCAST
functionality.
The MPI communicator used is MPI_COMM_WORLD
.
OpenMPCD::NULLPointerException | If OPENMPCD_DEBUG is defined, throws if count != 0 && buffer == nullptr . |
OpenMPCD::OutOfBoundsException | If OPENMPCD_DEBUG is defined, throws if root >= getNumberOfProcesses() . |
T | The type of elements to broadcast. |
[in,out] | buffer | If root == getRank() , this designates the buffer to send from; otherwise, this designates the buffer to receive into. In either case, the buffer must be able to hold at least count elements, unless count == 0 . |
[in] | count | The number of elements to broadcast. May be 0 , in which case this function does nothing. |
[in] | root | The root process rank. |
Definition at line 19 of file ImplementationDetails/MPI.hpp.
std::size_t OpenMPCD::MPI::getNumberOfProcesses | ( | ) | const |
std::size_t OpenMPCD::MPI::getRank | ( | ) | const |
bool OpenMPCD::MPI::test | ( | MPI_Request *const | request, |
std::size_t *const | sender = NULL |
||
) | const |
Calls MPI_TEST
on the given request.
OpenMPCD::NULLPointerException | If OPENMPCD_DEBUG is defined, throws if request == nullptr . |
OpenMPCD::InvalidArgumentException | If OPENMPCD_DEBUG is defined, throws if *request == MPI_REQUEST_NULL . |
[in,out] | request | The request to test; if completed, the pointee will be set MPI_REQUEST_NULL . |
[out] | sender | If not nullptr and if the request is completed, the pointee is set to the rank of the sender of the received message, if such information is available. |