45 MPI_Comm _com = MPI_COMM_WORLD;
58 [[nodiscard]] MPI_Comm
get() const noexcept {
return _com; }
64 [[nodiscard]]
int rank()
const {
77 [[nodiscard]]
int size()
const {
101 check_mpi_call(MPI_Comm_split(_com, color, key, &c._com),
"MPI_Comm_split");
154 inline operator boost::mpi::communicator()
const {
return boost::mpi::communicator(_com, boost::mpi::comm_duplicate); }
155 inline communicator(boost::mpi::communicator c) : _com(c) {}
175 if (poll_msec == 0) {
182 check_mpi_call(MPI_Test(&req, &flag, MPI_STATUS_IGNORE),
"MPI_Test");
183 usleep(poll_msec * 1000);
C++ wrapper around MPI_Comm providing various convenience functions.
int size() const
Get the size of the communicator.
communicator(MPI_Comm c)
Construct a communicator with a given MPI_Comm object.
int rank() const
Get the rank of the calling process in the communicator.
communicator duplicate() const
Duplicate the communicator.
void free()
Free the communicator.
communicator split(int color, int key=0) const
Split the communicator into disjoint subgroups.
MPI_Comm get() const noexcept
Get the wrapped MPI_Comm object.
void barrier(long poll_msec=1) const
Barrier synchronization.
void abort(int error_code) const
If mpi::has_env is true, MPI_Abort is called with the given error code, otherwise std::abort is calle...
communicator()=default
Construct a communicator with MPI_COMM_WORLD.
Provides an MPI environment for initializing and finalizing an MPI program.
static const bool has_env
Boolean variable that is true, if one of the environment variables OMPI_COMM_WORLD_RANK,...
void check_mpi_call(int errcode, const std::string &mpi_routine)
Check the success of an MPI call.
Provides general utilities related to MPI.