MADNESS 0.10.1
SafeMPI::Intracomm Class Reference

Wrapper around MPI_Comm. Has a shallow copy constructor; use Create(Get_group()) for deep copy. More...

#include <safempi.h>

Inheritance diagram for SafeMPI::Intracomm:

Classes

struct  Impl
struct  WorldInitObject

Public Member Functions

 Intracomm (const Intracomm &other)
 Intracomm (const MPI_Comm &comm, bool take_ownership_of_comm=true)
 Intracomm (const WorldInitObject &)
 ~Intracomm ()
void Abort (int code=1) const
void Allreduce (const void *sendbuf, void *recvbuf, const int count, const MPI_Datatype datatype, const MPI_Op op) const
void Barrier () const
void Bcast (void *buf, size_t count, const MPI_Datatype datatype, const int root) const
void binary_tree_info (int root, int &parent, int &child0, int &child1)
 Construct info about a binary tree with given root.
Intracomm Clone () const
Intracomm Create (Group group) const
bool Get_attr (int key, void *value) const
Group Get_group () const
MPI_Comm & Get_mpi_comm () const
int Get_rank () const
int Get_size () const
Request Irecv (void *buf, const int count, const MPI_Datatype datatype, const int src, const int tag) const
Request Irecv_bytes (void *buf, const std::size_t nbyte, const int src, const int tag) const
 Nonblocking receive of nbyte bytes; unlike Irecv() , nbyte may exceed INT_MAX.
Request Isend (const void *buf, const int count, const MPI_Datatype datatype, const int dest, const int tag) const
Request Isend_bytes (const void *buf, const std::size_t nbyte, const int dest, const int tag, const bool sync=false) const
 Nonblocking send of nbyte bytes; unlike Isend() , nbyte may exceed INT_MAX.
Request Issend (const void *buf, const int count, const MPI_Datatype datatype, const int dest, const int tag) const
bool operator== (const Intracomm &other) const
void Recv (void *buf, const int count, const MPI_Datatype datatype, const int source, const int tag) const
void Recv (void *buf, const int count, const MPI_Datatype datatype, const int source, const int tag, MPI_Status &status) const
void Reduce (const void *sendbuf, void *recvbuf, const int count, const MPI_Datatype datatype, const MPI_Op op, const int root) const
void Send (const void *buf, const int count, const MPI_Datatype datatype, int dest, int tag) const
Intracomm Split (int Color, int Key=0) const
Intracomm Split_type (int Type, int Key=0) const
int unique_reserved_tag ()
 Returns a unique tag reserved for long-term use (0<tag<1000).
int unique_tag ()
 Returns a unique tag for temporary use (1023<tag<4095).

Static Public Member Functions

static int unique_tag_period ()

Static Public Attributes

static const int SHARED_SPLIT_TYPE = MPI_COMM_TYPE_SHARED
static const int UNDEFINED_COLOR = MPI_UNDEFINED
static const int UNDEFINED_SPLIT_TYPE = MPI_UNDEFINED

Private Member Functions

 Intracomm ()
 Intracomm (const std::shared_ptr< Impl > &i)
Intracomm & operator= (const Intracomm &other)

Static Private Member Functions

static bool Comm_compare (const MPI_Comm &comm1, const MPI_Comm &comm2)

Private Attributes

std::shared_ptr< Impl > pimpl

Friends

int Finalize ()
 Analogous to MPI_Finalize.
void SafeMPI::detail::init_comm_world ()

Detailed Description

Wrapper around MPI_Comm. Has a shallow copy constructor; use Create(Get_group()) for deep copy.

Constructor & Destructor Documentation

◆ Intracomm() [1/5]

SafeMPI::Intracomm::Intracomm ( const std::shared_ptr< Impl > & i)
inlineprivate

◆ Intracomm() [2/5]

SafeMPI::Intracomm::Intracomm ( )
inlineprivate

References pimpl.

Referenced by Create(), Split(), and Split_type().

◆ Intracomm() [3/5]

SafeMPI::Intracomm::Intracomm ( const WorldInitObject & init)

References pimpl.

◆ Intracomm() [4/5]

SafeMPI::Intracomm::Intracomm ( const MPI_Comm & comm,
bool take_ownership_of_comm = true )
inlineexplicit

◆ Intracomm() [5/5]

SafeMPI::Intracomm::Intracomm ( const Intracomm & other)
inline

References Intracomm(), and pimpl.

◆ ~Intracomm()

SafeMPI::Intracomm::~Intracomm ( )
inline

Member Function Documentation

◆ Abort()

void SafeMPI::Intracomm::Abort ( int code = 1) const
inline

References MPI_Abort(), and pimpl.

◆ Allreduce()

void SafeMPI::Intracomm::Allreduce ( const void * sendbuf,
void * recvbuf,
const int count,
const MPI_Datatype datatype,
const MPI_Op op ) const
inline

◆ Barrier()

void SafeMPI::Intracomm::Barrier ( ) const
inline

◆ Bcast()

void SafeMPI::Intracomm::Bcast ( void * buf,
size_t count,
const MPI_Datatype datatype,
const int root ) const
inline

◆ binary_tree_info()

void SafeMPI::Intracomm::binary_tree_info ( int root,
int & parent,
int & child0,
int & child1 )

Construct info about a binary tree with given root.

Constructs a binary tree spanning the communicator with process root as the root of the tree. Returns the logical parent and children in the tree of the calling process. If there is no parent/child the value -1 will be set.

References Get_rank(), Get_size(), me, and np.

◆ Clone()

Intracomm SafeMPI::Intracomm::Clone ( ) const
inline

◆ Comm_compare()

bool SafeMPI::Intracomm::Comm_compare ( const MPI_Comm & comm1,
const MPI_Comm & comm2 )
inlinestaticprivate

◆ Create()

Intracomm SafeMPI::Intracomm::Create ( Group group) const
inline

This collective operation creates a new Intracomm from an Intracomm::Group object. Must be called by all processes that belong to this communicator, but not all must use the same group . Thus this Intracomm can be partitioned into several Intracomm objects with one call.

Parameters
groupIntracomm::Group describing the Intracomm object to be created (Intracomm::Get_group() and Intracomm::Group::Incl() )
Returns
a new Intracomm object

References Intracomm(), Intracomm(), SafeMPI::Group::group(), MADNESS_ASSERT, MADNESS_MPI_TEST, me, MPI_Comm_create(), MPI_Comm_rank(), MPI_Comm_size(), nproc, pimpl, and SAFE_MPI_GLOBAL_MUTEX.

Referenced by Clone(), test_mpi_group(), and test_multi_world().

◆ Get_attr()

bool SafeMPI::Intracomm::Get_attr ( int key,
void * value ) const
inline

◆ Get_group()

Group SafeMPI::Intracomm::Get_group ( ) const
inline

This local operation returns the Intracomm::Group object corresponding to this intracommunicator

Returns
the Intracomm::Group object corresponding to this intracommunicator

References MADNESS_ASSERT, pimpl, and SAFE_MPI_GLOBAL_MUTEX.

Referenced by madness::WorldAmInterface::WorldAmInterface(), Clone(), test_mpi_group(), and test_multi_world().

◆ Get_mpi_comm()

MPI_Comm & SafeMPI::Intracomm::Get_mpi_comm ( ) const
inline

References MADNESS_ASSERT, and pimpl.

◆ Get_rank()

◆ Get_size()

◆ Irecv()

Request SafeMPI::Intracomm::Irecv ( void * buf,
const int count,
const MPI_Datatype datatype,
const int src,
const int tag ) const
inline

◆ Irecv_bytes()

Request SafeMPI::Intracomm::Irecv_bytes ( void * buf,
const std::size_t nbyte,
const int src,
const int tag ) const
inline

Nonblocking receive of nbyte bytes; unlike Irecv() , nbyte may exceed INT_MAX.

The large-count function of MPI 4 ( MPI_Irecv_c ) or a derived datatype is used as in Isend_bytes() ; the sender need not have made the same choice.

Note
the size of the message received is Status::Get_byte_count() , which cannot report more than INT_MAX bytes without MPI 4; the receiver should know the size

References SafeMPI::ByteCount::count(), SafeMPI::ByteCount::datatype(), Irecv(), MADNESS_ASSERT, MADNESS_MPI_TEST, SafeMPI::ByteCount::max_plain_count(), MPI_BYTE, pimpl, SAFE_MPI_GLOBAL_MUTEX, and SafeMPI::ByteCount::use_large_count().

◆ Isend()

Request SafeMPI::Intracomm::Isend ( const void * buf,
const int count,
const MPI_Datatype datatype,
const int dest,
const int tag ) const
inline

◆ Isend_bytes()

Request SafeMPI::Intracomm::Isend_bytes ( const void * buf,
const std::size_t nbyte,
const int dest,
const int tag,
const bool sync = false ) const
inline

Nonblocking send of nbyte bytes; unlike Isend() , nbyte may exceed INT_MAX.

Up to ByteCount::max_plain_count() bytes ( INT_MAX unless a test lowered it) are sent as Isend() sends them. More are given to the large-count function of MPI 4 ( MPI_Isend_c ) where MPI has it, and are otherwise described by a derived datatype (see ByteCount ).

Parameters
syncif true, the send is synchronous ( MPI_Issend )

References SafeMPI::ByteCount::count(), SafeMPI::ByteCount::datatype(), Isend(), Issend(), MADNESS_ASSERT, MADNESS_MPI_TEST, SafeMPI::ByteCount::max_plain_count(), MPI_BYTE, pimpl, SAFE_MPI_GLOBAL_MUTEX, and SafeMPI::ByteCount::use_large_count().

◆ Issend()

Request SafeMPI::Intracomm::Issend ( const void * buf,
const int count,
const MPI_Datatype datatype,
const int dest,
const int tag ) const
inline

◆ operator=()

Intracomm & SafeMPI::Intracomm::operator= ( const Intracomm & other)
private

References Intracomm().

◆ operator==()

bool SafeMPI::Intracomm::operator== ( const Intracomm & other) const
inline

References Intracomm(), Comm_compare(), and pimpl.

◆ Recv() [1/2]

void SafeMPI::Intracomm::Recv ( void * buf,
const int count,
const MPI_Datatype datatype,
const int source,
const int tag ) const
inline

◆ Recv() [2/2]

void SafeMPI::Intracomm::Recv ( void * buf,
const int count,
const MPI_Datatype datatype,
const int source,
const int tag,
MPI_Status & status ) const
inline

◆ Reduce()

void SafeMPI::Intracomm::Reduce ( const void * sendbuf,
void * recvbuf,
const int count,
const MPI_Datatype datatype,
const MPI_Op op,
const int root ) const
inline

◆ Send()

void SafeMPI::Intracomm::Send ( const void * buf,
const int count,
const MPI_Datatype datatype,
int dest,
int tag ) const
inline

◆ Split()

Intracomm SafeMPI::Intracomm::Split ( int Color,
int Key = 0 ) const
inline

This collective operation creates a new Intracomm using the MPI_Comm_split. Must be called by all processes that belong to this communicator. Each caller must provide Color of the new Intracomm and Key (this controls the rank within the new Intracomm; ties are broken by the rank in this Intracomm).

Parameters
ColorSpecifies the new Intracomm that the calling process is to be assigned to. The value of color must be non-negative. If Color=UNDEFINED_COLOR then an uninitialized Intracomm object will be produced.
KeyThe relative rank of the calling process in the group of the new Intracomm. If omitted, each communicator's ranks will be determined by the rank in the host communicator.
Returns
a new Intracomm object

References Intracomm(), Intracomm(), MADNESS_ASSERT, MADNESS_MPI_TEST, me, MPI_COMM_NULL, MPI_Comm_rank(), MPI_Comm_size(), MPI_Comm_split(), nproc, pimpl, and SAFE_MPI_GLOBAL_MUTEX.

Referenced by create_worlds(), and test_multi_world().

◆ Split_type()

Intracomm SafeMPI::Intracomm::Split_type ( int Type,
int Key = 0 ) const
inline

This collective operation creates a new Intracomm using the MPI_Comm_split_type. Must be called by all processes that belong to this communicator. Each caller must provide the split type and Key (this controls the rank within the new Intracomm; ties are broken by the rank in this Intracomm).

Parameters
TypeControls how this Intracomm will be split. The value can only be UNDEFINED_SPLIT_TYPE or SHARED_SPLIT_TYPE. If Type=UNDEFINED_SPLIT_TYPE then an uninitialized Intracomm object will be produced.
KeyThe relative rank of the calling process in the group of the new Intracomm. If omitted, each communicator's ranks will be determined by the rank in the host communicator.
Returns
a new Intracomm object

References Intracomm(), Intracomm(), MADNESS_ASSERT, MADNESS_MPI_TEST, me, MPI_COMM_NULL, MPI_Comm_rank(), MPI_Comm_size(), MPI_Comm_split_type(), MPI_Info_create(), MPI_Info_free(), nproc, pimpl, and SAFE_MPI_GLOBAL_MUTEX.

Referenced by madness::check_thread_binding(), and test_multi_world().

◆ unique_reserved_tag()

int SafeMPI::Intracomm::unique_reserved_tag ( )
inline

Returns a unique tag reserved for long-term use (0<tag<1000).

Get a tag from this routine for long-term/repeated use.

Tags in [1000,1023] are statically assigned.

References MADNESS_ASSERT, and pimpl.

◆ unique_tag()

int SafeMPI::Intracomm::unique_tag ( )
inline

Returns a unique tag for temporary use (1023<tag<4095).

These tags are intended for one time use to avoid tag collisions with other messages around the same time period. It simply increments/wraps a counter and returns the next legal value.

So that send and receiver agree on the tag all processes need to call this routine in the same sequence.

References MADNESS_ASSERT, and pimpl.

Referenced by madness::archive::ArchiveStoreImpl< ParallelOutputArchive< localarchiveT >, WorldContainer< keyT, valueT > >::store(), and madness::archive::ArchiveStoreImpl< ParallelOutputArchive< VectorOutputArchive >, WorldContainer< keyT, valueT > >::store().

◆ unique_tag_period()

int SafeMPI::Intracomm::unique_tag_period ( )
inlinestatic
Returns
the period of repeat of unique tags produces by unique_tag()

References SafeMPI::Intracomm::Impl::unique_tag_period().

◆ Finalize

int Finalize ( )
friend

Analogous to MPI_Finalize.

This returns status rather than throw an exception upon failure because this is a "destructor", and throwing from destructors is evil.

Returns
0 if successful, nonzero otherwise (see MPI_Finalize() for the return codes).

References SafeMPI::COMM_WORLD, and MPI_Finalize().

◆ SafeMPI::detail::init_comm_world

Member Data Documentation

◆ pimpl

◆ SHARED_SPLIT_TYPE

const int SafeMPI::Intracomm::SHARED_SPLIT_TYPE = MPI_COMM_TYPE_SHARED
static

◆ UNDEFINED_COLOR

const int SafeMPI::Intracomm::UNDEFINED_COLOR = MPI_UNDEFINED
static

◆ UNDEFINED_SPLIT_TYPE

const int SafeMPI::Intracomm::UNDEFINED_SPLIT_TYPE = MPI_UNDEFINED
static

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