MPQC  3.0.0-alpha
sc::MPIMessageGrp Class Reference

The MPIMessageGrp class is an concrete implementation of MessageGrp that uses the MPI 1 library. More...

#include <util/group/messmpi.h>

Inheritance diagram for sc::MPIMessageGrp:
sc::MessageGrp sc::DescribedClass sc::RefCount

Classes

class  MessageHandleData
 

Public Member Functions

 MPIMessageGrp (MPI_Comm comm)
 Use an MPI communicator to create a MessageGrp. More...
 
 MPIMessageGrp (int *argc, char ***argv)
 Use argc and argv to create a MPIMessageGrp. More...
 
 MPIMessageGrp (const Ref< KeyVal > &)
 Construction MPIMessageGrp given a KeyVal input object.
 
Ref< MessageGrpclone (void)
 Clones (dups) an MPIMessageGrp from MPI_COMM_WORLD.
 
Ref< MessageGrpsplit (int grpkey=0, int rankkey=0)
 Returns MessageGrp objects that are a subset of this MessageGrp. More...
 
Ref< MessageGrpsubset (const std::set< int > &)
 Returns MessageGrp objects that are a subset of this MessageGrp. More...
 
void raw_send (int target, const void *data, int nbyte)
 
void raw_recv (int sender, void *data, int nbyte, MessageInfo *info=0)
 
void raw_sendt (int target, int type, const void *data, int nbyte, bool rcvrdy=false)
 
void raw_recvt (int sender, int type, void *data, int nbyte, MessageInfo *info=0)
 
int probet (int sender, int type, MessageInfo *info=0)
 Ask if a given typed message has been received.
 
void sync ()
 Synchronize all of the processors.
 
void sum (double *, int n, double *scratch=0, int target=-1)
 
void sum (int *, int n, int *scratch=0, int target=-1)
 
void reduce (double *, int n, GrpReduce< double > &, double *scratch=0, int target=-1)
 
void reduce (unsigned int *, int n, GrpReduce< unsigned int > &, unsigned int *scratch=0, int target=-1)
 
void reduce (int *, int n, GrpReduce< int > &, int *scratch=0, int target=-1)
 
void reduce (char *, int n, GrpReduce< char > &, char *scratch=0, int target=-1)
 
void reduce (unsigned char *, int n, GrpReduce< unsigned char > &, unsigned char *scratch=0, int target=-1)
 
void reduce (signed char *, int n, GrpReduce< signed char > &, signed char *scratch=0, int target=-1)
 
void reduce (short *, int n, GrpReduce< short > &, short *scratch=0, int target=-1)
 
void reduce (float *, int n, GrpReduce< float > &, float *scratch=0, int target=-1)
 
void reduce (long *, int n, GrpReduce< long > &, long *scratch=0, int target=-1)
 
void raw_nb_sendt (int sender, int type, const void *data, int nbyte, MessageHandle &, bool rcvrdy=false)
 
void raw_nb_recvt (int sender, int type, void *data, int nbyte, MessageHandle &)
 
void wait (const MessageHandle &, MessageInfo *info=0)
 Wait for an operation to complete. More...
 
void raw_bcast (void *data, int nbyte, int from)
 
- Public Member Functions inherited from sc::MessageGrp
 MessageGrp (const Ref< KeyVal > &)
 
virtual ~MessageGrp ()
 Destroy this MessageGrp. More...
 
int n ()
 Returns the number of processors.
 
int me ()
 Returns my processor number. In the range [0,n()).
 
virtual void send (int target, const double *data, int ndata)
 
virtual void send (int target, const unsigned int *data, int ndata)
 
virtual void send (int target, const int *data, int ndata)
 
virtual void send (int target, const char *data, int nbyte)
 
virtual void send (int target, const unsigned char *data, int nbyte)
 
virtual void send (int target, const signed char *data, int nbyte)
 
virtual void send (int target, const short *data, int ndata)
 
virtual void send (int target, const long *data, int ndata)
 
virtual void send (int target, const float *data, int ndata)
 
void send (int target, double data)
 This sends a single double datum.
 
void send (int target, int data)
 This sends a single integer datum.
 
virtual void sendt (int target, int type, const double *data, int ndata, bool rcvrdy=false)
 
virtual void sendt (int target, int type, const unsigned int *data, int ndata, bool rcvrdy=false)
 
virtual void sendt (int target, int type, const int *data, int ndata, bool rcvrdy=false)
 
virtual void sendt (int target, int type, const char *data, int nbyte, bool rcvrdy=false)
 
virtual void sendt (int target, int type, const unsigned char *data, int nbyte, bool rcvrdy=false)
 
virtual void sendt (int target, int type, const signed char *data, int nbyte, bool rcvrdy=false)
 
virtual void sendt (int target, int type, const short *data, int ndata, bool rcvrdy=false)
 
virtual void sendt (int target, int type, const long *data, int ndata, bool rcvrdy=false)
 
virtual void sendt (int target, int type, const float *data, int ndata, bool rcvrdy=false)
 
void sendt (int target, int type, double data, bool rcvrdy=false)
 This sends a single double datum.
 
void sendt (int target, int type, int data, bool rcvrdy=false)
 This sends a single integer datum.
 
virtual void recv (int sender, double *data, int ndata)
 
virtual void recv (int sender, unsigned int *data, int ndata)
 
virtual void recv (int sender, int *data, int ndata)
 
virtual void recv (int sender, char *data, int nbyte)
 
virtual void recv (int sender, unsigned char *data, int nbyte)
 
virtual void recv (int sender, signed char *data, int nbyte)
 
virtual void recv (int sender, short *data, int ndata)
 
virtual void recv (int sender, long *data, int ndata)
 
virtual void recv (int sender, float *data, int ndata)
 
void recv (int sender, double &data)
 This receives a single double datum.
 
void recv (int sender, int &data)
 This receives a single integer datum.
 
virtual void recvt (int sender, int type, double *data, int ndata)
 
virtual void recvt (int sender, int type, unsigned int *data, int ndata)
 
virtual void recvt (int sender, int type, int *data, int ndata)
 
virtual void recvt (int sender, int type, char *data, int nbyte)
 
virtual void recvt (int sender, int type, unsigned char *data, int nbyte)
 
virtual void recvt (int sender, int type, signed char *data, int nbyte)
 
virtual void recvt (int sender, int type, short *data, int ndata)
 
virtual void recvt (int sender, int type, long *data, int ndata)
 
virtual void recvt (int sender, int type, float *data, int ndata)
 
void recvt (int sender, int type, double &data)
 This receives a single double datum.
 
void recvt (int sender, int type, int &data)
 This receives a single integer datum.
 
virtual void nb_sendt (int target, int type, const double *data, int ndata, MessageHandle &handle, bool rcvrdy=false)
 
virtual void nb_sendt (int target, int type, const unsigned int *data, int ndata, MessageHandle &handle, bool rcvrdy=false)
 
virtual void nb_sendt (int target, int type, const int *data, int ndata, MessageHandle &handle, bool rcvrdy=false)
 
virtual void nb_sendt (int target, int type, const char *data, int nbyte, MessageHandle &handle, bool rcvrdy=false)
 
virtual void nb_sendt (int target, int type, const unsigned char *data, int nbyte, MessageHandle &handle, bool rcvrdy=false)
 
virtual void nb_sendt (int target, int type, const signed char *data, int nbyte, MessageHandle &handle, bool rcvrdy=false)
 
virtual void nb_sendt (int target, int type, const short *data, int ndata, MessageHandle &handle, bool rcvrdy=false)
 
virtual void nb_sendt (int target, int type, const long *data, int ndata, MessageHandle &handle, bool rcvrdy=false)
 
virtual void nb_sendt (int target, int type, const float *data, int ndata, MessageHandle &handle, bool rcvrdy=false)
 
void nb_sendt (int target, int type, double data, MessageHandle &handle, bool rcvrdy=false)
 
void nb_sendt (int target, int type, int data, MessageHandle &handle, bool rcvrdy=false)
 
virtual void nb_recvt (int sender, int type, double *data, int ndata, MessageHandle &handle)
 
virtual void nb_recvt (int sender, int type, unsigned int *data, int ndata, MessageHandle &handle)
 
virtual void nb_recvt (int sender, int type, int *data, int ndata, MessageHandle &handle)
 
virtual void nb_recvt (int sender, int type, char *data, int nbyte, MessageHandle &handle)
 
virtual void nb_recvt (int sender, int type, unsigned char *data, int nbyte, MessageHandle &handle)
 
virtual void nb_recvt (int sender, int type, signed char *data, int nbyte, MessageHandle &handle)
 
virtual void nb_recvt (int sender, int type, short *data, int ndata, MessageHandle &handle)
 
virtual void nb_recvt (int sender, int type, long *data, int ndata, MessageHandle &handle)
 
virtual void nb_recvt (int sender, int type, float *data, int ndata, MessageHandle &handle)
 
void nb_recvt (int sender, int type, double &data, MessageHandle &handle)
 This receives a single double datum.
 
void nb_recvt (int sender, int type, int &data, MessageHandle &handle)
 This receives a single integer datum.
 
virtual void bcast (double *data, int ndata, int from=0)
 
virtual void bcast (unsigned int *data, int ndata, int from=0)
 
virtual void bcast (int *data, int ndata, int from=0)
 
virtual void bcast (char *data, int nbyte, int from=0)
 
virtual void bcast (unsigned char *data, int nbyte, int from=0)
 
virtual void bcast (signed char *data, int nbyte, int from=0)
 
virtual void bcast (short *data, int ndata, int from=0)
 
virtual void bcast (long *data, int ndata, int from=0)
 
virtual void bcast (float *data, int ndata, int from=0)
 
void bcast (double &data, int from=0)
 
void bcast (int &data, int from=0)
 
virtual void raw_collect (const void *part, const int *lengths, void *whole, int bytes_per_datum=1)
 
void collect (const double *part, const int *lengths, double *whole)
 
virtual void sum (unsigned int *data, int n, unsigned int *=0, int target=-1)
 
virtual void sum (long *data, int n, long *=0, int target=-1)
 
virtual void sum (unsigned long *data, int n, unsigned long *=0, int target=-1)
 
virtual void sum (char *data, int n, char *=0, int target=-1)
 
virtual void sum (unsigned char *data, int n, unsigned char *=0, int target=-1)
 
virtual void sum (signed char *data, int n, signed char *=0, int target=-1)
 
void sum (double &data)
 
void sum (int &data)
 
virtual void max (double *data, int n, double *=0, int target=-1)
 
virtual void max (int *data, int n, int *=0, int target=-1)
 
virtual void max (unsigned int *data, int n, unsigned int *=0, int target=-1)
 
virtual void max (char *data, int n, char *=0, int target=-1)
 
virtual void max (unsigned char *data, int n, unsigned char *=0, int target=-1)
 
virtual void max (signed char *data, int n, signed char *=0, int target=-1)
 
void max (double &data)
 
void max (int &data)
 
virtual void min (double *data, int n, double *=0, int target=-1)
 
virtual void min (int *data, int n, int *=0, int target=-1)
 
virtual void min (unsigned int *data, int n, unsigned int *=0, int target=-1)
 
virtual void min (char *data, int n, char *=0, int target=-1)
 
virtual void min (unsigned char *data, int n, unsigned char *=0, int target=-1)
 
virtual void min (signed char *data, int n, signed char *=0, int target=-1)
 
void min (double &data)
 
void min (int &data)
 
template<typename T >
void reduce (T *, int n, GrpReduce< T > &, T *scratch=0, int target=-1)
 T must be a POD (plain old data) type so that it can be copied bytewise.
 
void reduce (double &data, GrpReduce< double > &r)
 
void reduce (int &data, GrpReduce< int > &r)
 
Ref< MachineTopologytopology ()
 Return the MachineTopology object.
 
int classdesc_to_index (const ClassDesc *)
 
const ClassDescindex_to_classdesc (int)
 
int nclass () const
 
- Public Member Functions inherited from sc::DescribedClass
 DescribedClass (const DescribedClass &)
 
DescribedClassoperator= (const DescribedClass &)
 
ClassDescclass_desc () const MPQC__NOEXCEPT
 This returns the unique pointer to the ClassDesc corresponding to the given type_info object. More...
 
const char * class_name () const
 Return the name of the object's exact type.
 
int class_version () const
 Return the version of the class.
 
virtual void print (std::ostream &=ExEnv::out0()) const
 Print the object.
 
Ref< DescribedClassref ()
 Return this object wrapped up in a Ref smart pointer. More...
 
- Public Member Functions inherited from sc::RefCount
size_t identifier () const
 Return the unique identifier for this object that can be compared for different objects of different types. More...
 
int lock_ptr () const
 Lock this object.
 
int unlock_ptr () const
 Unlock this object.
 
void use_locks (bool inVal)
 start and stop using locks on this object
 
refcount_t nreference () const
 Return the reference count.
 
refcount_t reference ()
 Increment the reference count and return the new count.
 
refcount_t dereference ()
 Decrement the reference count and return the new count.
 
int managed () const
 
void unmanage ()
 Turn off the reference counting mechanism for this object. More...
 

Protected Member Functions

void init (MPI_Comm comm, int *argc=0, char ***argv=0)
 Not thread-safe due to race condition on nmpi_grps variable.
 
- Protected Member Functions inherited from sc::MessageGrp
void initialize (int me, int n)
 The classdesc_to_index_ and index_to_classdesc_ arrays cannot be initialized by the MessageGrp CTOR, because the MessageGrp specialization has not yet been initialized and communication is not available. More...
 
void set_sender (MessageInfo *info, int sender)
 
void set_type (MessageInfo *info, int type)
 
void set_nbyte (MessageInfo *info, int nbyte)
 
void set_id (MessageHandle *handle, void *id)
 
void * get_id (const MessageHandle *handle)
 
- Protected Member Functions inherited from sc::RefCount
 RefCount (const RefCount &)
 
RefCountoperator= (const RefCount &)
 

Protected Attributes

void * buf
 
int bufsize
 
bool use_messagegrp_collectives_
 If true use the generic collective routines in the base class.
 
Ref< ThreadGrpthreadgrp
 
MPI_Comm commgrp
 Currently each commgrp is a dup of MPI_COMM_WORLD.
 
- Protected Attributes inherited from sc::MessageGrp
Ref< MachineTopologytopology_
 
int debug_
 

Static Protected Attributes

static int nmpi_grps
 Number of MPIMessageGrp's currently in use.
 
static ThreadLockgrplock
 lock to access nmpi_grps variable More...
 
static bool mpi_init_called
 Was MPI_Init called by one of MPIMessagrGrp? Will also call MPI_Finalize, if so.
 

Additional Inherited Members

- Public Types inherited from sc::MessageGrp
enum  { AnyType = -1 }
 
enum  { AnySender = -1 }
 
- Static Public Member Functions inherited from sc::MessageGrp
static void set_default_messagegrp (const Ref< MessageGrp > &)
 The default message group contains the primary message group to be used by an application.
 
static MessageGrpget_default_messagegrp ()
 Returns the default message group.
 
static MessageGrpinitial_messagegrp (int &argc, char **&argv)
 Create a message group. More...
 

Detailed Description

The MPIMessageGrp class is an concrete implementation of MessageGrp that uses the MPI 1 library.


Constructor & Destructor Documentation

◆ MPIMessageGrp() [1/2]

sc::MPIMessageGrp::MPIMessageGrp ( MPI_Comm  comm)

Use an MPI communicator to create a MessageGrp.

The comm argument could be a subset of MPI_COMM_WORLD, for example.

◆ MPIMessageGrp() [2/2]

sc::MPIMessageGrp::MPIMessageGrp ( int *  argc,
char ***  argv 
)

Use argc and argv to create a MPIMessageGrp.

This would have to be used for implementations of MPI that have MPI_Init fill in argc and argv.

Member Function Documentation

◆ split()

Ref<MessageGrp> sc::MPIMessageGrp::split ( int  grpkey = 0,
int  rankkey = 0 
)
virtual

Returns MessageGrp objects that are a subset of this MessageGrp.

This call is collective–all nodes in this MessageGrp must call it. If the commkey is less than zero, then a nil pointer will be returned. Otherwise, all nodes calling with the same commkey will be put into the same return MessageGrp. The rankkey argument is used to order the nodes in the new MessageGrp. Nodes with the same rankkey are ordered by rank. With the default arguments, split behaves the same as clone.

Implements sc::MessageGrp.

◆ subset()

Ref<MessageGrp> sc::MPIMessageGrp::subset ( const std::set< int > &  )
virtual

Returns MessageGrp objects that are a subset of this MessageGrp.

This call is collective–all nodes in this MessageGrp must call it. The ordering of the ranks matches the ordering of the original ranks.

Implements sc::MessageGrp.

◆ wait()

void sc::MPIMessageGrp::wait ( const MessageHandle handle,
MessageInfo info = 0 
)
virtual

Wait for an operation to complete.

Parameters
handlethe handle initialized by, for example, nb_recvt.
infoif non-null, this will be filled in with information about the operation that completed.

Implements sc::MessageGrp.

Member Data Documentation

◆ grplock

ThreadLock* sc::MPIMessageGrp::grplock
staticprotected

lock to access nmpi_grps variable

Note
lifetime is managed manually to avoid destruction of lock before calling all MPIMessageGrp destructors

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

Generated at Sun Jan 26 2020 23:24:08 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.