Encapsulates MPI Rank/Communicator information.
Every process has two ranks/communicators: World: This communicator/rank is valid after calling activateMPI, usually at the beginning of the program. This communicator never changes.
Custom: Can be adapted to the block structure. During the block structure setup, either the Cartesian setup has to be chosen using createCartesianComm() or the world communicator has to be used: useWorldComm()
#include <MPIManager.h>
Public Member Functions | |
~MPIManager () | |
void | initializeMPI (int *argc, char ***argv, bool abortOnException=true) |
Configures the class, initializes numProcesses, worldRank the rank and comm variables are still invalid, until custom communicator is set up. More... | |
void | finalizeMPI () |
void | resetMPI () |
void | abort () |
Cartesian Communicator | |
void | createCartesianComm (int numberOfProcessors[3], int periodicity[3]) |
void | createCartesianComm (const uint_t xProcesses, const uint_t yProcesses, const uint_t zProcesses, const bool xPeriodic=false, const bool yPeriodic=false, const bool zPeriodic=false) |
void | cartesianCoord (int coordOut[3]) const |
Cartesian coordinates of own rank. More... | |
void | cartesianCoord (int rank, int coordOut[3]) const |
Cartesian coordinates of given rank. More... | |
int | cartesianRank (int coords[3]) const |
translates Cartesian coordinates to rank More... | |
int | cartesianRank (const uint_t x, const uint_t y, const uint_t z) const |
translates Cartesian coordinates to rank More... | |
World Communicator | |
void | useWorldComm () |
Public Attributes | |
WALBERLA_BEFRIEND_SINGLETON | |
Getter Function | |
int | worldRank_ {0} |
Rank in MPI_COMM_WORLD. More... | |
int | rank_ {-1} |
Rank in the custom communicator. More... | |
int | numProcesses_ {1} |
Total number of processes. More... | |
MPI_Comm | comm_ |
Use this communicator for all MPI calls this is in general not equal to MPI_COMM_WORLD this may change during domain setup, where a custom communicator adapted to the domain is created. More... | |
bool | isMPIInitialized_ {false} |
Indicates whether initializeMPI has been called. If true, MPI_Finalize is called upon destruction. More... | |
bool | cartesianSetup_ {false} |
Indicates whether a Cartesian communicator has been created. More... | |
bool | currentlyAborting_ {false} |
bool | finalizeOnDestruction_ {false} |
int | worldRank () const |
int | numProcesses () const |
int | rank () const |
MPI_Comm | comm () const |
uint_t | bitsNeededToRepresentRank () const |
bool | isMPIInitialized () const |
bool | hasCartesianSetup () const |
bool | rankValid () const |
Rank is valid after calling createCartesianComm() or useWorldComm() More... | |
bool | hasWorldCommSetup () const |
bool | isCommMPIIOValid () const |
Indicates whether MPI-IO can be used with the current MPI communicator; certain versions of OpenMPI produce segmentation faults when using MPI-IO with a 3D Cartesian MPI communicator (see waLBerla issue #73) More... | |
static std::string | getMPIErrorString (int errorCode) |
static std::string | getMPICommName (MPI_Comm comm) |
MPIManager () | |
walberla::mpi::MPIManager::~MPIManager | ( | ) |
|
inlineprivate |
void walberla::mpi::MPIManager::abort | ( | ) |
|
inline |
void walberla::mpi::MPIManager::cartesianCoord | ( | int | coordOut[3] | ) | const |
Cartesian coordinates of own rank.
void walberla::mpi::MPIManager::cartesianCoord | ( | int | rank, |
int | coordOut[3] | ||
) | const |
Cartesian coordinates of given rank.
int walberla::mpi::MPIManager::cartesianRank | ( | const uint_t | x, |
const uint_t | y, | ||
const uint_t | z | ||
) | const |
translates Cartesian coordinates to rank
int walberla::mpi::MPIManager::cartesianRank | ( | int | coords[3] | ) | const |
translates Cartesian coordinates to rank
|
inline |
void walberla::mpi::MPIManager::createCartesianComm | ( | const uint_t | xProcesses, |
const uint_t | yProcesses, | ||
const uint_t | zProcesses, | ||
const bool | xPeriodic = false , |
||
const bool | yPeriodic = false , |
||
const bool | zPeriodic = false |
||
) |
void walberla::mpi::MPIManager::createCartesianComm | ( | int | numberOfProcessors[3], |
int | periodicity[3] | ||
) |
void walberla::mpi::MPIManager::finalizeMPI | ( | ) |
|
static |
|
static |
|
inline |
|
inline |
void walberla::mpi::MPIManager::initializeMPI | ( | int * | argc, |
char *** | argv, | ||
bool | abortOnException = true |
||
) |
Configures the class, initializes numProcesses, worldRank the rank and comm variables are still invalid, until custom communicator is set up.
abortOnException | if true, MPI_Abort is called in case of an uncaught exception |
bool walberla::mpi::MPIManager::isCommMPIIOValid | ( | ) | const |
Indicates whether MPI-IO can be used with the current MPI communicator; certain versions of OpenMPI produce segmentation faults when using MPI-IO with a 3D Cartesian MPI communicator (see waLBerla issue #73)
|
inline |
|
inline |
|
inline |
|
inline |
Rank is valid after calling createCartesianComm() or useWorldComm()
void walberla::mpi::MPIManager::resetMPI | ( | ) |
|
inline |
|
inline |
|
private |
Indicates whether a Cartesian communicator has been created.
|
private |
Use this communicator for all MPI calls this is in general not equal to MPI_COMM_WORLD this may change during domain setup, where a custom communicator adapted to the domain is created.
|
private |
|
private |
|
private |
Indicates whether initializeMPI has been called. If true, MPI_Finalize is called upon destruction.
|
private |
Total number of processes.
|
private |
Rank in the custom communicator.
walberla::mpi::MPIManager::WALBERLA_BEFRIEND_SINGLETON |
|
private |
Rank in MPI_COMM_WORLD.