TRIQS/mpi 2.0.0
C++ interface to MPI
Loading...
Searching...
No Matches
MPI essentials

Detailed Description

Simplify the initialization/finalization of an MPI environment and the usage of MPI_Comm and MPI_Group objects by wrapping them in C++ classes.

This group provides the building blocks needed by virtually every MPI program:

A typical Hello world! program using mpi::environment and mpi::communicator can be found in Example 1: Hello world!.

Classes

class  mpi::communicator
 C++ wrapper around MPI_Comm providing various convenience functions. More...
struct  mpi::environment
 RAII class to initialize and finalize MPI. More...
class  mpi::group
 C++ wrapper around MPI_Group providing various convenience functions. More...

Functions

bool mpi::is_finalized () noexcept
 Check if MPI has been finalized by calling MPI_Finalized.
bool mpi::is_initialized () noexcept
 Check if MPI has been initialized by calling MPI_Initialized.

Variables

static const bool mpi::has_env
 Boolean variable that checks if there is an active MPI runtime environment.

Function Documentation

◆ is_finalized()

bool mpi::is_finalized ( )
inlinenodiscardnoexcept

#include <mpi/environment.hpp>

Check if MPI has been finalized by calling MPI_Finalized.

Returns
True if MPI_Finalize has been called, false otherwise.

Definition at line 51 of file environment.hpp.

◆ is_initialized()

bool mpi::is_initialized ( )
inlinenodiscardnoexcept

#include <mpi/environment.hpp>

Check if MPI has been initialized by calling MPI_Initialized.

Returns
True if MPI_Init has been called, false otherwise.

Definition at line 41 of file environment.hpp.

Variable Documentation

◆ has_env

const bool mpi::has_env
static

#include <mpi/environment.hpp>

Initial value:
= []() {
if (std::getenv("OMPI_COMM_WORLD_RANK") != nullptr or std::getenv("PMI_RANK") != nullptr or std::getenv("PMIX_RANK") != nullptr
or std::getenv("CRAY_MPICH_VERSION") != nullptr or std::getenv("FORCE_MPI_INIT") != nullptr)
return true;
else
return false;
}()

Boolean variable that checks if there is an active MPI runtime environment.

It is true if one of the environment variables OMPI_COMM_WORLD_RANK, PMI_RANK, CRAY_MPICH_VERSION, PMIX_RANK or FORCE_MPI_INIT is set, false otherwise.

Note
The environment variables are set, when a program is executed with mpirun or mpiexec.

Definition at line 65 of file environment.hpp.