KaMPIng 0.2.0
Flexible and (near) zero-overhead C++ bindings for MPI
Loading...
Searching...
No Matches
kamping::Group Class Reference

A group of MPI processes. More...

#include <group.hpp>

Public Member Functions

 Group (MPI_Group group, bool owning=false)
 Constructs a new group from an existing MPI group.
 
 Group (Group const &)=delete
 
Group operator= (Group const &)=delete
 
 Group (Group &&other)
 Move constructor.
 
Groupoperator= (Group &&other)
 Move assignment.
 
template<typename Comm >
 Group (Comm const &comm)
 Constructs the group associated with a communicator.
 
 ~Group ()
 Default destructor, freeing the encapsulated group if owned.
 
GroupEquality compare (Group const &other) const
 Compare two groups.
 
bool is_identical (Group const &other) const
 Compare two groups.
 
bool is_similar (Group const &other) const
 Compare two groups.
 
bool has_same_ranks (Group const &other) const
 Compare two groups.
 
Group difference (Group const &other) const
 Makes a group from the difference of two groups.
 
Group intersection (Group const &other) const
 Makes a group from the intersection of two groups.
 
Group set_union (Group const &other) const
 Makes a group from the union of two groups.
 
std::optional< inttranslate_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.
 
template<typename In , typename Out >
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.
 
size_t size () const
 Get the number of ranks in the group.
 
size_t rank () const
 Get the rank of the calling process in the group.
 
MPI_Group mpi_group () const
 Native MPI_Group handle corresponding to this Group.
 

Static Public Member Functions

static Group empty ()
 Constructs an empty group.
 

Detailed Description

A group of MPI processes.

Member Function Documentation

◆ compare()

GroupEquality kamping::Group::compare ( Group const & other) const
inline

Compare two groups.

Parameters
otherThe group to compare with.
Returns
The equality of the two groups (see GroupEquality).

◆ difference()

Group kamping::Group::difference ( Group const & other) const
inline

Makes a group from the difference of two groups.

Parameters
otherThe other group.
Returns
A group containing all the ranks of the first group that are not in the second group.

◆ empty()

static Group kamping::Group::empty ( )
inlinestatic

Constructs an empty group.

Returns
An empty group.

◆ has_same_ranks()

bool kamping::Group::has_same_ranks ( Group const & other) const
inline

Compare two groups.

Parameters
otherThe group to compare with.
Returns
True if the groups are identical; see GroupEquality. False otherwise.

◆ intersection()

Group kamping::Group::intersection ( Group const & other) const
inline

Makes a group from the intersection of two groups.

Parameters
otherThe other group.
Returns
A group containing only the ranks present in both groups.

◆ is_identical()

bool kamping::Group::is_identical ( Group const & other) const
inline

Compare two groups.

Parameters
otherThe group to compare with.
Returns
True if the groups are identical; see GroupEquality. False otherwise.

◆ is_similar()

bool kamping::Group::is_similar ( Group const & other) const
inline

Compare two groups.

Parameters
otherThe group to compare with.
Returns
True if the groups are similar; see GroupEquality. False otherwise.

◆ mpi_group()

MPI_Group kamping::Group::mpi_group ( ) const
inline

Native MPI_Group handle corresponding to this Group.

Returns
The MPI_Group handle.

◆ rank()

size_t kamping::Group::rank ( ) const
inline

Get the rank of the calling process in the group.

Returns
The rank of the calling process in the group.

◆ set_union()

Group kamping::Group::set_union ( Group const & other) const
inline

Makes a group from the union of two groups.

Parameters
otherThe other group.
Returns
A group containing all ranks present in either of the two groups.
Note
The set_ prefix was choosen in order to avoid a name clash with the C++ keyword union.

◆ size()

size_t kamping::Group::size ( ) const
inline

Get the number of ranks in the group.

Returns
The number of ranks in the group.

◆ translate_rank_to_group()

std::optional< int > kamping::Group::translate_rank_to_group ( int rank_in_this_group,
Group const & other_group ) const
inline

Translates a rank relative to this group to a rank relative to another group.

Parameters
rank_in_this_groupThe rank in this group.
other_groupThe other group.
Returns
An optional containing the rank in the other group, or std::nullopt if the rank is not present in the other group.

◆ translate_ranks_to_group()

template<typename In , typename Out >
void kamping::Group::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
inline

Translates multiple ranks relative to this group to ranks relative to another group.

Template Parameters
InA random access iterator type with int as value type.
OutA random access iterator type with int as value type.
Parameters
ranks_in_this_group_beginIterator to the beginning of the ranks in this group.
ranks_in_this_group_endIterator to the end of the ranks in this group.
ranks_in_other_group_beginIterator to the beginning of the output ranks in the other group.
other_groupThe other group.
Note
The output ranks will be written starting from ranks_in_other_group_begin. The caller must ensure that there is enough space to write all the output ranks. If a rank is not present in the other group, the corresponding output rank will be set to MPI_UNDEFINED.

The documentation for this class was generated from the following file: