28#include "kamping/kassert/kassert.hpp"
44 Group(
MPI_Group group,
bool owning =
false) : _group(group), _owns_group(owning) {}
51 this->_group =
other._group;
52 other._owns_group =
false;
53 this->_owns_group =
true;
58 this->_group =
other._group;
59 other._owns_group =
false;
60 this->_owns_group =
true;
65 template <
typename Comm>
104 return GroupEquality::Identical;
106 return GroupEquality::Similar;
108 return GroupEquality::Unequal;
110 KAMPING_ASSERT(
false,
"MPI_Group_compare returned an unknown value");
111 return GroupEquality::Invalid;
134 return (
result == GroupEquality::Identical) || (
result == GroupEquality::Similar);
194 template <
typename In,
typename Out>
202 std::is_same_v<typename std::iterator_traits<In>::value_type,
int>,
203 "Input iterator value type must be int"
206 std::is_same_v<typename std::iterator_traits<Out>::value_type,
int>,
207 "Output iterator value type must be int"
210 std::is_base_of_v<std::random_access_iterator_tag, typename std::iterator_traits<In>::iterator_category>,
211 "Input iterator must be a random access iterator"
214 std::is_base_of_v<std::random_access_iterator_tag, typename std::iterator_traits<Out>::iterator_category>,
215 "Output iterator must be a random access iterator"
Helper functions that make casts safer.
A group of MPI processes.
Definition group.hpp:41
bool is_similar(Group const &other) const
Compare two groups.
Definition group.hpp:125
size_t rank() const
Get the rank of the calling process in the group.
Definition group.hpp:240
bool is_identical(Group const &other) const
Compare two groups.
Definition group.hpp:118
Group & operator=(Group &&other)
Move assignment.
Definition group.hpp:57
size_t size() const
Get the number of ranks in the group.
Definition group.hpp:231
Group set_union(Group const &other) const
Makes a group from the union of two groups.
Definition group.hpp:160
GroupEquality compare(Group const &other) const
Compare two groups.
Definition group.hpp:97
~Group()
Default destructor, freeing the encapsulated group if owned.
Definition group.hpp:78
Group(Comm const &comm)
Constructs the group associated with a communicator.
Definition group.hpp:66
void translate_ranks_to_group(In ranks_in_this_group_begin, In ranks_in_this_group_end, Out ranks_in_other_group_begin, Group const &other_group) const
Translates multiple ranks relative to this group to ranks relative to another group.
Definition group.hpp:195
Group intersection(Group const &other) const
Makes a group from the intersection of two groups.
Definition group.hpp:149
std::optional< int > translate_rank_to_group(int rank_in_this_group, Group const &other_group) const
Translates a rank relative to this group to a rank relative to another group.
Definition group.hpp:172
MPI_Group mpi_group() const
Native MPI_Group handle corresponding to this Group.
Definition group.hpp:249
Group(Group &&other)
Move constructor.
Definition group.hpp:50
Group(MPI_Group group, bool owning=false)
Constructs a new group from an existing MPI group.
Definition group.hpp:44
Group difference(Group const &other) const
Makes a group from the difference of two groups.
Definition group.hpp:140
bool has_same_ranks(Group const &other) const
Compare two groups.
Definition group.hpp:132
static Group empty()
Constructs an empty group.
Definition group.hpp:73
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_KAMPING_ASSERT for MPI errors.
Definition error_handling.hpp:34
GroupEquality
Describes the equality of two groups.
Definition group.hpp:33
@ 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.