Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::mpi::group Class Reference

A group is a representation of a subset of the processes within a communicator. More...

#include <group.hpp>

Collaboration diagram for boost::mpi::group:

Classes

struct  group_free
 INTERNAL ONLY. More...
 

Public Member Functions

 group ()
 Constructs an empty group. More...
 
 group (const MPI_Group &in_group, bool adopt)
 Constructs a group from an MPI_Group. More...
 
optional< int > rank () const
 Determine the rank of the calling process in the group. More...
 
int size () const
 Determine the number of processes in the group. More...
 
template<typename InputIterator , typename OutputIterator >
OutputIterator translate_ranks (InputIterator first, InputIterator last, const group &to_group, OutputIterator out)
 Translates the ranks from one group into the ranks of the same processes in another group. More...
 
 operator bool () const
 Determines whether the group is non-empty. More...
 
 operator MPI_Group () const
 Retrieves the underlying MPI_Group associated with this group. More...
 
template<typename InputIterator >
group include (InputIterator first, InputIterator last)
 Creates a new group including a subset of the processes in the current group. More...
 
template<typename InputIterator >
group exclude (InputIterator first, InputIterator last)
 Creates a new group from all of the processes in the current group, exluding a specific subset of the processes. More...
 
template<>
BOOST_MPI_DECL int * translate_ranks (int *first, int *last, const group &to_group, int *out)
 INTERNAL ONLY. More...
 
template<>
BOOST_MPI_DECL group include (int *first, int *last)
 INTERNAL ONLY. More...
 
template<>
BOOST_MPI_DECL group exclude (int *first, int *last)
 INTERNAL ONLY. More...
 

Protected Attributes

shared_ptr< MPI_Group > group_ptr
 The underlying MPI group. More...
 

Detailed Description

A group is a representation of a subset of the processes within a communicator.

The group class allows one to create arbitrary subsets of the processes within a communicator. One can compute the union, intersection, or difference of two groups, or create new groups by specifically including or excluding certain processes. Given a group, one can create a new communicator containing only the processes in that group.

Constructor & Destructor Documentation

boost::mpi::group::group ( )
inline

Constructs an empty group.

Referenced by exclude(), and include().

boost::mpi::group::group ( const MPI_Group &  in_group,
bool  adopt 
)

Constructs a group from an MPI_Group.

This routine allows one to construct a Boost.MPI group from a C MPI_Group. The group object can (optionally) adopt the MPI_Group, after which point the group object becomes responsible for freeing the MPI_Group when the last copy of group disappears.

Parameters
in_groupThe MPI_Group used to construct this group.
adoptWhether the group should adopt the MPI_Group. When true, the group object (or one of its copies) will free the group (via MPI_Comm_free) when the last copy is destroyed. Otherwise, the user is responsible for calling MPI_Group_free.

Member Function Documentation

template<typename InputIterator >
group boost::mpi::group::exclude ( InputIterator  first,
InputIterator  last 
)

Creates a new group from all of the processes in the current group, exluding a specific subset of the processes.

This routine creates a new group which includes all of the processes in the current group except those whose ranks are listed in the integer iterator range [first, last). Equivalent to MPI_Group_excl.

first The beginning of the iterator range of ranks to exclude.

last Past the end of the iterator range of ranks to exclude.

Returns
A new group containing all of the processes in the current group except those processes with ranks [first, last) in the current group.

References BOOST_MPI_CHECK_RESULT, and group().

template<>
BOOST_MPI_DECL group boost::mpi::group::exclude ( int *  first,
int *  last 
)

INTERNAL ONLY.

Specialization of group::exclude that handles the one case where we can avoid any memory allocation or copying before creating the group.

template<typename InputIterator >
group boost::mpi::group::include ( InputIterator  first,
InputIterator  last 
)

Creates a new group including a subset of the processes in the current group.

This routine creates a new group which includes only those processes in the current group that are listed in the integer iterator range [first, last). Equivalent to MPI_Group_incl.

first The beginning of the iterator range of ranks to include.

last Past the end of the iterator range of ranks to include.

Returns
A new group containing those processes with ranks [first, last) in the current group.

References BOOST_MPI_CHECK_RESULT, and group().

template<>
BOOST_MPI_DECL group boost::mpi::group::include ( int *  first,
int *  last 
)

INTERNAL ONLY.

Specialization of group::include that handles the one case where we can avoid any memory allocation or copying before creating the group.

boost::mpi::group::operator bool ( ) const
inline

Determines whether the group is non-empty.

Returns
True if the group is not empty, false if it is empty.
boost::mpi::group::operator MPI_Group ( ) const
inline

Retrieves the underlying MPI_Group associated with this group.

Returns
The MPI_Group handle manipulated by this object. If this object represents the empty group, returns MPI_GROUP_EMPTY.
optional<int> boost::mpi::group::rank ( ) const

Determine the rank of the calling process in the group.

This routine is equivalent to MPI_Group_rank.

Returns
The rank of the calling process in the group, which will be a value in [0, size()). If the calling process is not in the group, returns an empty value.
int boost::mpi::group::size ( ) const

Determine the number of processes in the group.

This routine is equivalent to MPI_Group_size.

Returns
The number of processes in the group.
template<typename InputIterator , typename OutputIterator >
OutputIterator boost::mpi::group::translate_ranks ( InputIterator  first,
InputIterator  last,
const group to_group,
OutputIterator  out 
)

Translates the ranks from one group into the ranks of the same processes in another group.

This routine translates each of the integer rank values in the iterator range [first, last) from the current group into rank values of the corresponding processes in to_group. The corresponding rank values are written via the output iterator out. When there is no correspondence between a rank in the current group and a rank in to_group, the value MPI_UNDEFINED is written to the output iterator.

Parameters
firstBeginning of the iterator range of ranks in the current group.
lastPast the end of the iterator range of ranks in the current group.
to_groupThe group that we are translating ranks to.
outThe output iterator to which the translated ranks will be written.
Returns
the output iterator, which points one step past the last rank written.

References BOOST_MPI_CHECK_RESULT, boost::multiprecision::backends::i, boost::n, and boost::out.

template<>
BOOST_MPI_DECL int* boost::mpi::group::translate_ranks ( int *  first,
int *  last,
const group to_group,
int *  out 
)

INTERNAL ONLY.

Specialization of translate_ranks that handles the one case where we can avoid any memory allocation or copying.

Member Data Documentation

shared_ptr<MPI_Group> boost::mpi::group::group_ptr
protected

The underlying MPI group.

This is a shared pointer, so the actual MPI group which will be shared among all related instances of the group class. When there are no more such instances, the group will be automatically freed.


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