WARPXM v1.10.0
Loading...
Searching...
No Matches
WxMsgBase Class Referenceabstract

Provides an abstract interface for message based communication between different processes. More...

#include <wxmsgbase.h>

Inheritance diagram for WxMsgBase:
WxMpiMsg

Detailed Description

Provides an abstract interface for message based communication between different processes.

Classes

struct  WxMsgContainer
 

Public Types

typedef WxTypeMap< WxDataTypes_t, WxMsgContainerWxMsgTypeMap_t
 

Public Member Functions

virtual ~WxMsgBase ()
 Destructor.
 
virtual int rank () const =0
 Rank of process.
 
virtual unsigned numProcs () const =0
 Number of processes taking part in messaging.
 
WxMsgBaseparent () const
 Get parent communicating processor group.
 
virtual WxMsgBasecreateSubComm (const std::vector< int > &ranks)=0
 Split communicator into a child communicator.
 
virtual WxMsgBasesplitComm (int color, int order)=0
 See MPI_Comm_split.
 
virtual void barrier () const =0
 Block till all processes hit this barrier.
 
template<typename T >
void send (const std::vector< T > &array, unsigned recvRank, int tag=-1) const
 Send a std::vector to another rank.
 
template<typename T >
void send (unsigned num, const T *array, unsigned recvRank, int tag=-1) const
 Send an array to another rank.
 
template<typename T >
WxMsgStatus startSend (const std::vector< T > &vec, unsigned recvRank, int tag=-1) const
 Send an vector to another rank.
 
template<typename T >
WxMsgStatus startSend (unsigned num, const T *arr, unsigned recvRank, int tag=-1) const
 Send an array to another rank.
 
virtual void finishSend (WxMsgStatus ms) const =0
 Finish the send started by startSend.
 
template<typename T >
void recv (int num, std::vector< T > &array, unsigned sendRank, int tag=-1) const
 Receive a std::vector from another rank.
 
template<typename T >
void recv (unsigned num, T *array, unsigned sendRank, int tag=-1) const
 Receive an array from another rank.
 
template<typename T >
WxMsgStatus startRecv (unsigned num, unsigned sendRank, int tag=-1) const
 Receive an array from another rank.
 
template<typename T >
WxMsgStatus startRecv (unsigned num, T *arr, unsigned sendRank, int tag=-1) const
 Receive an array from another rank.
 
template<typename T >
WxMsgStatus startRecv (std::vector< T > &vec, unsigned sendRank, int tag=-1) const
 Receive an array from another rank.
 
virtual void * finishRecv (WxMsgStatus ms) const =0
 Finish the receive started by startRecv and return a pointer to the data recieved.
 
virtual bool checkRecv (WxMsgStatus ms) const =0
 Check status of recieve started by a startRecv.
 
template<typename T >
void allReduce (unsigned num, T *sendBuff, T *recvBuff, MPI_Op op) const
 Reduce data to all ranks.
 
template<typename T >
std::vector< T > allReduce (std::vector< T > sendBuff, MPI_Op op) const
 Reduce data to all ranks (vector form)
 
template<typename T >
void broadcast (unsigned num, T *buffer, int root) const
 

Public Attributes

WxMsgTypeMap_t _msgTypeMap
 

Protected Member Functions

 WxMsgBase (int sendTag=0, int recvTag=0, WxMsgBase *parent=0)
 Constructor.
 
template<typename T >
void addMsg (WxMsgTmpl< T > *b)
 Add a new messager : the derived class should call this to setup WxMsgBase properly.
 

Member Typedef Documentation

◆ WxMsgTypeMap_t

Constructor & Destructor Documentation

◆ ~WxMsgBase()

virtual WxMsgBase::~WxMsgBase ( )
inlinevirtual

Destructor.

◆ WxMsgBase()

WxMsgBase::WxMsgBase ( int  sendTag = 0,
int  recvTag = 0,
WxMsgBase parent = 0 
)
inlineprotected

Constructor.

This is protected so only children can make instances.

Member Function Documentation

◆ addMsg()

template<typename T >
void WxMsgBase::addMsg ( WxMsgTmpl< T > *  b)
inlineprotected

Add a new messager : the derived class should call this to setup WxMsgBase properly.

◆ allReduce() [1/2]

template<typename T >
std::vector< T > WxMsgBase::allReduce ( std::vector< T >  sendBuff,
MPI_Op  op 
) const
inline

Reduce data to all ranks (vector form)

Parameters
sendBuffbuffer to reduce
opoperation to perform.
Returns
reduced data

◆ allReduce() [2/2]

template<typename T >
void WxMsgBase::allReduce ( unsigned  num,
T *  sendBuff,
T *  recvBuff,
MPI_Op  op 
) const
inline

Reduce data to all ranks.

Parameters
numNumber of elements being reduced
sendBuffbuffer to reduce
recvBuffbuffer to recieve reduced data
opoperation to perform.

◆ barrier()

virtual void WxMsgBase::barrier ( ) const
pure virtual

Block till all processes hit this barrier.

Implemented in WxMpiMsg.

◆ broadcast()

template<typename T >
void WxMsgBase::broadcast ( unsigned  num,
T *  buffer,
int  root 
) const
inline

◆ checkRecv()

virtual bool WxMsgBase::checkRecv ( WxMsgStatus  ms) const
pure virtual

Check status of recieve started by a startRecv.

If this call returns true then finishRecv can be called to immediately recieve the data.

Parameters
msmessage status object returned by startRecv
Returns
true it recieve has been completed, false otherwise

Implemented in WxMpiMsg.

◆ createSubComm()

virtual WxMsgBase * WxMsgBase::createSubComm ( const std::vector< int > &  ranks)
pure virtual

Split communicator into a child communicator.

Parameters
rankslist of processors in old communicator which are to be in the new communicator
Returns
new communicator

Implemented in WxMpiMsg.

◆ finishRecv()

virtual void * WxMsgBase::finishRecv ( WxMsgStatus  ms) const
pure virtual

Finish the receive started by startRecv and return a pointer to the data recieved.

The calling function owns the pointer and is resposible for freeing it.

Parameters
msmessage status object returned by startRecv
Returns
pointer to the data recieved. Caller owns the returned pointer

Implemented in WxMpiMsg.

◆ finishSend()

virtual void WxMsgBase::finishSend ( WxMsgStatus  ms) const
pure virtual

Finish the send started by startSend.

Parameters
msmessage status object returned by startSend

Implemented in WxMpiMsg.

◆ numProcs()

virtual unsigned WxMsgBase::numProcs ( ) const
pure virtual

Number of processes taking part in messaging.

Returns
num of processes

Implemented in WxMpiMsg.

◆ parent()

WxMsgBase * WxMsgBase::parent ( ) const
inline

Get parent communicating processor group.

Returns
parent proccesor group

◆ rank()

virtual int WxMsgBase::rank ( ) const
pure virtual

Rank of process.

Returns
this rank

Implemented in WxMpiMsg.

◆ recv() [1/2]

template<typename T >
void WxMsgBase::recv ( int  num,
std::vector< T > &  array,
unsigned  sendRank,
int  tag = -1 
) const
inline

Receive a std::vector from another rank.

Parameters
numnumber of elements to receive
arrayarray that is filled with received values
tagidentifier for data transaction
sendRankrank that sent array

◆ recv() [2/2]

template<typename T >
void WxMsgBase::recv ( unsigned  num,
T *  array,
unsigned  sendRank,
int  tag = -1 
) const
inline

Receive an array from another rank.

Parameters
numnumber of elements to receive
arrayarray that is filled with received values
tagidentifier for data transaction
sendRankrank that sent array

◆ send() [1/2]

template<typename T >
void WxMsgBase::send ( const std::vector< T > &  array,
unsigned  recvRank,
int  tag = -1 
) const
inline

Send a std::vector to another rank.

Parameters
arraystd::vector of data being sent
recvRankrank that will receive array
tagidentifier for data transaction

◆ send() [2/2]

template<typename T >
void WxMsgBase::send ( unsigned  num,
const T *  array,
unsigned  recvRank,
int  tag = -1 
) const
inline

Send an array to another rank.

Parameters
numnumber of elements to send
arrayarray of length 'num' of data being sent
recvRankrank that will receive array
tagidentifier for data transaction

◆ splitComm()

virtual WxMsgBase * WxMsgBase::splitComm ( int  color,
int  order 
)
pure virtual

See MPI_Comm_split.

Implemented in WxMpiMsg.

◆ startRecv() [1/3]

template<typename T >
WxMsgStatus WxMsgBase::startRecv ( std::vector< T > &  vec,
unsigned  sendRank,
int  tag = -1 
) const
inline

Receive an array from another rank.

This is a non-blocking call.

This call uses the arr pointer for the recieved data

Parameters
vecvector of elements to receive
sendRankrank we want to receive from
tagidentifier for data transaction
Returns
message status

◆ startRecv() [2/3]

template<typename T >
WxMsgStatus WxMsgBase::startRecv ( unsigned  num,
T *  arr,
unsigned  sendRank,
int  tag = -1 
) const
inline

Receive an array from another rank.

This is a non-blocking call.

This call uses the arr pointer for the recieved data

Parameters
numnumber of elements to receive
arrarray to fill with received value
sendRankrank we want to receive from
tagidentifier for data transaction
Returns
message status

◆ startRecv() [3/3]

template<typename T >
WxMsgStatus WxMsgBase::startRecv ( unsigned  num,
unsigned  sendRank,
int  tag = -1 
) const
inline

Receive an array from another rank.

This is a non-blocking call.

This call allocates a dataspace within WxMsgStatus for the recieved data

Parameters
numnumber of elements to receive
sendRankrank we want to receive from
tagidentifier for data transaction
Returns
message status

◆ startSend() [1/2]

template<typename T >
WxMsgStatus WxMsgBase::startSend ( const std::vector< T > &  vec,
unsigned  recvRank,
int  tag = -1 
) const
inline

Send an vector to another rank.

This is a non-blocking call.

Parameters
vecvector to send
recvRankrank that will receive array
tagidentifier for data transaction

◆ startSend() [2/2]

template<typename T >
WxMsgStatus WxMsgBase::startSend ( unsigned  num,
const T *  arr,
unsigned  recvRank,
int  tag = -1 
) const
inline

Send an array to another rank.

This is a non-blocking call.

Parameters
numnumber of elements to send
arrarray that is filled with values to send
recvRankrank that sent array
tagidentifier for data transaction
Returns
message status

Member Data Documentation

◆ _msgTypeMap

WxMsgTypeMap_t WxMsgBase::_msgTypeMap

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