58 group(
group &&other) noexcept : grp_{std::exchange(other.grp_, MPI_GROUP_NULL)} {}
62 if (
this != std::addressof(rhs)) {
64 grp_ = std::exchange(rhs.grp_, MPI_GROUP_NULL);
76 explicit group(MPI_Group grp) : grp_(grp) {}
87 [[nodiscard]] MPI_Group
get() const noexcept {
return grp_; }
90 [[nodiscard]]
bool is_null() const noexcept {
return grp_ == MPI_GROUP_NULL; }
96 [[nodiscard]]
int rank()
const {
106 [[nodiscard]]
int size()
const {
121 MPI_Group newgroup = MPI_GROUP_NULL;
122 if (
has_env)
check_mpi_call(MPI_Group_incl(grp_,
static_cast<int>(ranks.size()), ranks.data(), &newgroup),
"MPI_Group_incl");
123 return group{newgroup};
132 MPI_Group grp_ = MPI_GROUP_NULL;
C++ wrapper around MPI_Comm providing various convenience functions.
MPI_Comm get() const noexcept
Get the wrapped MPI_Comm object.
bool is_null() const noexcept
Check if the contained MPI_Group is MPI_GROUP_NULL.
void free() noexcept
Free the group by calling MPI_Group_free (if it is not is_null()).
group include(std::vector< int > const &ranks) const
Create a new group by calling MPI_Group_incl.
~group()
Destructor calls free() to release the group.
int rank() const
Get the rank of the calling process in the group.
group(group &&other) noexcept
Move constructor leaves moved-from object with MPI_GROUP_NULL.
group(communicator c)
Create a group from a communicator by calling MPI_Comm_group.
group()=default
Construct a group with MPI_GROUP_NULL.
group(MPI_Group grp)
Take ownership of an existing MPI_Group object.
group & operator=(group &&rhs) noexcept
Move assignment operator leaves moved-from object with MPI_GROUP_NULL.
group(group const &)=delete
Deleted copy constructor.
MPI_Group get() const noexcept
Get the wrapped MPI_Group object.
int size() const
Get the size of the group.
group & operator=(group const &)=delete
Deleted copy assignment operator.
Provides a C++ wrapper class for an MPI_Comm object.
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.