MADNESS  0.10.1
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
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:
Inheritance graph
[legend]

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. More...
 
Intracomm Clone () const
 
Intracomm Create (Group group) const
 
bool Get_attr (int key, void *value) const
 
Group Get_group () const
 
MPI_CommGet_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 Isend (const void *buf, const int count, const MPI_Datatype datatype, const int dest, const int tag) const
 
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) More...
 
int unique_tag ()
 Returns a unique tag for temporary use (1023<tag<4095) More...
 

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)
 
Intracommoperator= (const Intracomm &other)
 

Static Private Member Functions

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

Private Attributes

std::shared_ptr< Implpimpl
 

Friends

int Finalize ()
 Analogous to MPI_Finalize. More...
 
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

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

◆ Intracomm() [3/5]

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

◆ 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

◆ ~Intracomm()

SafeMPI::Intracomm::~Intracomm ( )
inline

Member Function Documentation

◆ Abort()

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

References MPI_Abort(), and pimpl.

Referenced by madness::error().

◆ 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.

Referenced by madness::WorldGopInterface::all_reduce(), madness::WorldGopInterface::bcast_task(), madness::WorldGopInterface::broadcast(), madness::WorldGopInterface::concat0(), madness::WorldGopInterface::fence_impl(), madness::WorldGopInterface::lazy_sync(), and madness::WorldGopInterface::reduce().

◆ Clone()

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

Clones this Intracomm object

Returns
a (deep) copy of this Intracomm object

References Create(), and Get_group().

◆ Comm_compare()

static 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(), SafeMPI::Group::group(), MADNESS_ASSERT, MADNESS_MPI_TEST, me, MPI_Comm_create(), MPI_Comm_rank(), MPI_Comm_size(), pimpl, and SAFE_MPI_GLOBAL_MUTEX.

Referenced by Clone(), 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(), and test_multi_world().

◆ Get_mpi_comm()

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

◆ Get_rank()

int SafeMPI::Intracomm::Get_rank ( ) const
inline

◆ Get_size()

int SafeMPI::Intracomm::Get_size ( ) const
inline

◆ Irecv()

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

◆ Isend()

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

◆ 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

◆ operator==()

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

References 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(), MADNESS_ASSERT, MADNESS_MPI_TEST, me, MPI_COMM_NULL, MPI_Comm_rank(), MPI_Comm_size(), MPI_Comm_split(), pimpl, and SAFE_MPI_GLOBAL_MUTEX.

Referenced by madness::MacroTaskQ::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(), 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(), pimpl, and SAFE_MPI_GLOBAL_MUTEX.

Referenced by 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::WorldGopInterface::broadcast(), madness::WorldGopInterface::concat0(), madness::WorldGopInterface::fence_impl(), madness::WorldGopInterface::reduce(), and madness::archive::ArchiveStoreImpl< ParallelOutputArchive< localarchiveT >, WorldContainer< keyT, valueT > >::store().

◆ unique_tag_period()

static 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().

Referenced by madness::WorldGopInterface::concat0().

Friends And Related Function Documentation

◆ 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).

◆ SafeMPI::detail::init_comm_world

Member Data Documentation

◆ pimpl

std::shared_ptr<Impl> SafeMPI::Intracomm::pimpl
private

◆ SHARED_SPLIT_TYPE

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

Referenced by test_multi_world().

◆ 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: