The TIMPIInit
class, when constructed, initializes any dependent libraries (e.g.
More...
#include <timpi_init.h>
Public Member Functions | |
TIMPIInit (int argc, const char *const *argv, int mpi_thread_requested=0, bool handle_mpi_errors=false, MPI_Comm COMM_WORLD_IN=MPI_COMM_WORLD) | |
Initialize the library for use, with the command line options provided. More... | |
TIMPIInit (int argc, const char *const *argv, int mpi_thread_requested=0, bool handle_mpi_errors=false) | |
virtual | ~TIMPIInit () |
Destructor. More... | |
const Communicator & | comm () const |
Returns the Communicator created by this object, which will be a compatibility shim if MPI is not enabled, or a wrapper for the user-input MPI_Comm if we were constructed with one, or a wrapper for MPI_COMM_WORLD by default. More... | |
Communicator & | comm () |
Private Attributes | |
std::unique_ptr< Communicator > | _comm |
std::unique_ptr< SemiPermanent::Ref > | _ref |
bool | i_initialized_mpi |
MPI_Errhandler | my_errhandler |
bool | err_handler_set |
The TIMPIInit
class, when constructed, initializes any dependent libraries (e.g.
MPI).
For many users, a single TIMPIInit object should be created at the start of your main() function.
Since "it is best not to perform much more than a return rc after calling MPI_Finalize", applications which want to do anything after TIMPIInit destruction should manage MPI initialization and finalization manually.
Definition at line 57 of file timpi_init.h.
TIMPI::TIMPIInit::TIMPIInit | ( | int | argc, |
const char *const * | argv, | ||
int | mpi_thread_requested = 0 , |
||
bool | handle_mpi_errors = false , |
||
MPI_Comm | COMM_WORLD_IN = MPI_COMM_WORLD |
||
) |
Initialize the library for use, with the command line options provided.
This will e.g. call MPI_Init_thread if MPI is available and enabled and has not already been initialized.
mpi_thread_requested should be set to 0 when MPI_THREAD_SINGLE is desired, 1 when MPI_THREAD_FUNNELED initialization is desired, 2 when MPI_THREAD_SERIALIZED is desaired, and 3 when MPI_THREAD_MULTIPLE is desired
handle_mpi_errors should be set to true to use the "timpi_not_implemented()" behavior (e.g. throwing an exception) as an MPI error handler, which can aid in debugging.
When building with MPI, this method may take an optional parameter to use a user-specified MPI communicator.
Definition at line 41 of file timpi_init.C.
References _comm, _ref, err_handler_set, i_initialized_mpi, my_errhandler, and TIMPI_MPI_Handler().
TIMPI::TIMPIInit::TIMPIInit | ( | int | argc, |
const char *const * | argv, | ||
int | mpi_thread_requested = 0 , |
||
bool | handle_mpi_errors = false |
||
) |
Definition at line 122 of file timpi_init.C.
|
virtual |
Destructor.
Finalizes MPI if that was initialized by TIMPIInit.
Definition at line 133 of file timpi_init.C.
References _comm, _ref, TIMPI::Communicator::barrier(), comm(), err_handler_set, i_initialized_mpi, and my_errhandler.
|
inline |
Returns the Communicator created by this object, which will be a compatibility shim if MPI is not enabled, or a wrapper for the user-input MPI_Comm if we were constructed with one, or a wrapper for MPI_COMM_WORLD by default.
Definition at line 100 of file timpi_init.h.
References _comm.
Referenced by main(), and ~TIMPIInit().
|
inline |
|
private |
Definition at line 105 of file timpi_init.h.
Referenced by comm(), TIMPIInit(), and ~TIMPIInit().
|
private |
Definition at line 108 of file timpi_init.h.
Referenced by TIMPIInit(), and ~TIMPIInit().
|
private |
Definition at line 114 of file timpi_init.h.
Referenced by TIMPIInit(), and ~TIMPIInit().
|
private |
Definition at line 111 of file timpi_init.h.
Referenced by TIMPIInit(), and ~TIMPIInit().
|
private |
Definition at line 113 of file timpi_init.h.
Referenced by TIMPIInit(), and ~TIMPIInit().