KaMPIng 0.1.1
Flexible and (near) zero-overhead C++ bindings for MPI
|
Wrapper for MPI functions that don't require a communicator. If the template parameter init_finalize_mode
is set to InitMPIMode::InitFinalize (default), MPI_Init
is called in the constructor, and MPI_Finalize
is called in the destructor.
More...
#include <environment.hpp>
Public Member Functions | |
Environment (int &argc, char **&argv) | |
Calls MPI_Init with arguments. | |
Environment () | |
Calls MPI_Init without arguments. | |
void | init_unchecked () const |
Calls MPI_Init without arguments and doesn't check whether MPI_Init has already been called. | |
void | init_unchecked (int &argc, char **&argv) const |
Calls MPI_Init with arguments and doesn't check whether MPI_Init has already been called. | |
void | init () const |
Calls MPI_Init without arguments. Checks whether MPI_Init has already been called first. | |
void | init (int &argc, char **&argv) const |
Calls MPI_Init with arguments. Checks whether MPI_Init has already been called first. | |
void | finalize () const |
Calls MPI_Finalize and frees all registered MPI data types. | |
bool | initialized () const |
Checks whether MPI_Init has been called. | |
bool | finalized () const |
Checks whether MPI_Finalize has been called. | |
template<typename T > | |
void | buffer_attach (Span< T > buffer) |
Attach a buffer to use for buffered send operations to the environment. | |
template<typename T = std::byte> | |
Span< T > | buffer_detach () |
Detach a buffer attached via buffer_attach(). | |
~Environment () | |
Calls MPI_Finalize if finalize() has not been called before. Also frees all registered MPI data types. | |
Static Public Member Functions | |
static double | wtime () |
Returns the elapsed time since an arbitrary time in the past. | |
static double | wtick () |
Returns the resolution of Environment::wtime(). | |
static int | tag_upper_bound () |
The upper bound on message tags defined by the MPI implementation. | |
static bool | is_valid_tag (int tag) |
Checks if the given tag is a valid message tag. | |
static void | register_mpi_type (MPI_Datatype type) |
Register a new MPI data type to KaMPIng that will be freed when using Environment to finalize MPI. | |
static void | commit (MPI_Datatype type) |
Commit an MPI data type (without registering it with KaMPIng). | |
static void | free (MPI_Datatype type) |
Free an MPI data type. | |
static void | commit_and_register (MPI_Datatype type) |
Commit an MPI data type and register it with KaMPIng. | |
static void | free_registered_mpi_types () |
Free all registered MPI data types. | |
Static Public Attributes | |
static size_t const | bsend_overhead = MPI_BSEND_OVERHEAD |
Wrapper for MPI functions that don't require a communicator. If the template parameter init_finalize_mode
is set to InitMPIMode::InitFinalize (default), MPI_Init
is called in the constructor, and MPI_Finalize
is called in the destructor.
Note that MPI_Init
and MPI_Finalize
are global, meaning that if they are called on an Environment object they must not be called again in any Environment object (or directly vie the MPI_*
calls).
|
inline |
Calls MPI_Init with arguments.
argc | Number of arguments. |
argv | The arguments. |
|
inline |
Attach a buffer to use for buffered send operations to the environment.
T | The type of the buffer. |
buffer | The buffer. The user is responsible for allocating the buffer, attaching it, detaching it and freeing the memory after detaching. For convenience, the buffer may be a span of any type, but the type is ignored by MPI. |
|
inline |
Detach a buffer attached via buffer_attach().
T | The type of the span to return. Defaults to std::byte . |
T
. The pointer to the buffer stored internally by MPI is reinterpreted accordingly.
|
inlinestatic |
Commit an MPI data type and register it with KaMPIng.
|
inline |
Calls MPI_Finalize and frees all registered MPI data types.
Even if you chose InitMPIMode::InitFinalize, you might want to call this function: As MPI_Finalize could potentially return an error, this function can be used if you want to be able to handle that error. Otherwise the destructor will call MPI_Finalize and not throw on any errors returned.
|
inline |
Checks whether MPI_Finalize has been called.
true
if MPI_Finalize has been called, false
otherwise.
|
inlinestatic |
Free all registered MPI data types.
Only call this when you no longer want to use any MPI data types created by KaMPIng as other KaMPIng functions will assume the created types still exist.
|
inline |
Calls MPI_Init with arguments. Checks whether MPI_Init has already been called first.
argc | Number of arguments. |
argv | The arguments. |
|
inline |
Calls MPI_Init with arguments and doesn't check whether MPI_Init has already been called.
argc | Number of arguments. |
argv | The arguments. |
|
inline |
Checks whether MPI_Init has been called.
true
if MPI_Init has been called, false
otherwise.
|
inlinestatic |
Checks if the given tag is a valid message tag.
|
inlinestatic |
Register a new MPI data type to KaMPIng that will be freed when using Environment to finalize MPI.
type | The MPI data type to register. |
|
inlinestatic |
The upper bound on message tags defined by the MPI implementation.
|
inlinestatic |
Returns the resolution of Environment::wtime().
|
inlinestatic |
Returns the elapsed time since an arbitrary time in the past.
|
inlinestatic |
Provides an upper bound on the additional memory required by buffered send operations.