19#include <kassert/kassert.hpp>
39 Group(
MPI_Group group,
bool owning =
false) : _group(group), _owns_group(owning) {}
46 this->_group =
other._group;
47 other._owns_group =
false;
48 this->_owns_group =
true;
53 this->_group =
other._group;
54 other._owns_group =
false;
55 this->_owns_group =
true;
60 template <
typename Comm>
99 return GroupEquality::Identical;
101 return GroupEquality::Similar;
103 return GroupEquality::Unequal;
105 KASSERT(
false,
"MPI_Group_compare returned an unknown value");
106 return GroupEquality::Invalid;
129 return (
result == GroupEquality::Identical) || (
result == GroupEquality::Similar);
Helper functions that make casts safer.
A group of MPI processes.
Definition group.hpp:36
bool is_similar(Group const &other) const
Compare two groups.
Definition group.hpp:120
size_t rank() const
Get the rank of the calling process in the group.
Definition group.hpp:173
bool is_identical(Group const &other) const
Compare two groups.
Definition group.hpp:113
Group & operator=(Group &&other)
Move assignment.
Definition group.hpp:52
size_t size() const
Get the number of ranks in the group.
Definition group.hpp:164
Group set_union(Group const &other) const
Makes a group from the union of two groups.
Definition group.hpp:155
GroupEquality compare(Group const &other) const
Compare two groups.
Definition group.hpp:92
~Group()
Default destructor, freeing the encapsulated group if owned.
Definition group.hpp:73
Group(Comm const &comm)
Constructs the group associated with a communicator.
Definition group.hpp:61
Group intersection(Group const &other) const
Makes a group from the intersection of two groups.
Definition group.hpp:144
Group(Group &&other)
Move constructor.
Definition group.hpp:45
Group(MPI_Group group, bool owning=false)
Constructs a new group from an existing MPI group.
Definition group.hpp:39
Group difference(Group const &other) const
Makes a group from the difference of two groups.
Definition group.hpp:135
bool has_same_ranks(Group const &other) const
Compare two groups.
Definition group.hpp:127
static Group empty()
Constructs an empty group.
Definition group.hpp:68
STL-compatible allocator for requesting memory using the builtin MPI allocator.
Definition allocator.hpp:32
#define THROW_IF_MPI_ERROR(error_code, function)
Wrapper around THROWING_KASSERT for MPI errors.
Definition error_handling.hpp:33
GroupEquality
Describes the equality of two groups.
Definition group.hpp:28
@ Similar
Only the members are the same, the order is different.
@ Invalid
Tried to convert an invalid value to a GroupEquality.
@ Identical
The order and members of the two groups are the same.