TRIQS/mpi 1.3.0
C++ interface to MPI
Loading...
Searching...
No Matches
mpi::group

#include <mpi/group.hpp>

Detailed Description

C++ wrapper around MPI_Group providing various convenience functions.

It stores an MPI_Group object as its only member which by default is set to MPI_GROUP_NULL. The underlying MPI_Group object is automatically freed when a group object goes out of scope.

This class follows move-only semantics and takes ownership of the wrapped MPI_Group object.

All functions that make direct calls to the MPI C library throw an exception in case the call fails.

Definition at line 46 of file group.hpp.

Public Member Functions

 group ()=default
 Construct a group with MPI_GROUP_NULL.
 group (communicator c)
 Create a group from a communicator by calling MPI_Comm_group.
 group (group &&other) noexcept
 Move constructor leaves moved-from object with MPI_GROUP_NULL.
 group (group const &)=delete
 Deleted copy constructor.
 group (MPI_Group grp)
 Take ownership of an existing MPI_Group object.
 ~group ()
 Destructor calls free() to release the group.
void free () noexcept
 Free the group by calling MPI_Group_free (if it is not is_null()).
MPI_Group get () const noexcept
 Get the wrapped MPI_Group object.
group include (std::vector< int > const &ranks) const
 Create a new group by calling MPI_Group_incl.
bool is_null () const noexcept
 Check if the contained MPI_Group is MPI_GROUP_NULL.
groupoperator= (group &&rhs) noexcept
 Move assignment operator leaves moved-from object with MPI_GROUP_NULL.
groupoperator= (group const &)=delete
 Deleted copy assignment operator.
int rank () const
 Get the rank of the calling process in the group.
int size () const
 Get the size of the group.

Constructor & Destructor Documentation

◆ group() [1/2]

mpi::group::group ( MPI_Group grp)
inlineexplicit

Take ownership of an existing MPI_Group object.

Parameters
grpMPI_Group to be handled.

Definition at line 76 of file group.hpp.

◆ group() [2/2]

mpi::group::group ( communicator c)
inlineexplicit

Create a group from a communicator by calling MPI_Comm_group.

Parameters
cmpi::communicator from which to create a group.

Definition at line 82 of file group.hpp.

Member Function Documentation

◆ include()

group mpi::group::include ( std::vector< int > const & ranks) const
inlinenodiscard

Create a new group by calling MPI_Group_incl.

It produces a new group by reordering the existing group and taking only listed members.

Parameters
ranksList of ranks to include in the new group.
Returns
New group containing only the listed members.

Definition at line 120 of file group.hpp.

◆ rank()

int mpi::group::rank ( ) const
inlinenodiscard

Get the rank of the calling process in the group.

Returns
The result of MPI_Group_rank if mpi::has_env is true, otherwise 0.

Definition at line 96 of file group.hpp.

◆ size()

int mpi::group::size ( ) const
inlinenodiscard

Get the size of the group.

Returns
The result of MPI_Group_size if mpi::has_env is true, otherwise 1.

Definition at line 106 of file group.hpp.


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