36 virtual int rank()
const = 0;
82 void send(
const std::vector<T>& array,
unsigned recvRank,
int tag = -1)
const
84 this->_getMsg<T>()->send(
85 array.size(), &(array[0]), recvRank, (tag == -1) ? _sendTag : tag);
97 void send(
unsigned num,
const T* array,
unsigned recvRank,
int tag = -1)
const
99 this->_getMsg<T>()->send(num, array, recvRank, (tag == -1) ? _sendTag : tag);
111 startSend(
const std::vector<T>& vec,
unsigned recvRank,
int tag = -1)
const
113 return this->_getMsg<T>()->startSend(
114 vec.size(), &(vec[0]), recvRank, (tag == -1) ? _sendTag : tag);
128 startSend(
unsigned num,
const T* arr,
unsigned recvRank,
int tag = -1)
const
130 return this->_getMsg<T>()->startSend(
131 num, arr, recvRank, (tag == -1) ? _recvTag : tag);
150 void recv(
int num, std::vector<T>& array,
unsigned sendRank,
int tag = -1)
const
153 this->_getMsg<T>()->recv(
154 num, &(array[0]), sendRank, (tag == -1) ? _recvTag : tag);
166 void recv(
unsigned num, T* array,
unsigned sendRank,
int tag = -1)
const
168 this->_getMsg<T>()->recv(num, array, sendRank, (tag == -1) ? _recvTag : tag);
184 return this->_getMsg<T>()->startRecv(num, sendRank, (tag == -1) ? _recvTag : tag);
201 return this->_getMsg<T>()->startRecv(
202 num, arr, sendRank, (tag == -1) ? _recvTag : tag);
218 return startRecv(vec.size(), vec.data(), sendRank, tag);
250 void allReduce(
unsigned num, T* sendBuff, T* recvBuff, MPI_Op op)
const
252 this->_getMsg<T>()->allReduce(num, sendBuff, recvBuff, op);
263 std::vector<T>
allReduce(std::vector<T> sendBuff, MPI_Op op)
const
265 std::vector<T> recvBuff(sendBuff.size());
266 this->_getMsg<T>()->allReduce(
267 sendBuff.size(), &(sendBuff[0]), &(recvBuff[0]), op);
274 this->_getMsg<T>()->broadcast(num, buffer, root);
282 : _sendTag(sendTag), _recvTag(recvTag), _parent(
parent)
300 int _sendTag, _recvTag;
312 wxe <<
"Message type not set properly";
319 template<
typename T>
const WxMsgTmpl<T>* _getMsg()
const
325 wxe <<
"Message type not set properly";
Provides an abstract interface for message based communication between different processes.
Definition: wxmsgbase.h:22
virtual void barrier() const =0
Block till all processes hit this barrier.
void send(unsigned num, const T *array, unsigned recvRank, int tag=-1) const
Send an array to another rank.
Definition: wxmsgbase.h:97
void recv(int num, std::vector< T > &array, unsigned sendRank, int tag=-1) const
Receive a std::vector from another rank.
Definition: wxmsgbase.h:150
virtual int rank() const =0
Rank of process.
WxMsgStatus startSend(const std::vector< T > &vec, unsigned recvRank, int tag=-1) const
Send an vector to another rank.
Definition: wxmsgbase.h:111
std::vector< T > allReduce(std::vector< T > sendBuff, MPI_Op op) const
Reduce data to all ranks (vector form)
Definition: wxmsgbase.h:263
WxMsgTypeMap_t _msgTypeMap
Definition: wxmsgbase.h:351
void addMsg(WxMsgTmpl< T > *b)
Add a new messager : the derived class should call this to setup WxMsgBase properly.
Definition: wxmsgbase.h:290
WxMsgBase * parent() const
Get parent communicating processor group.
Definition: wxmsgbase.h:50
virtual ~WxMsgBase()
Destructor.
Definition: wxmsgbase.h:27
WxMsgStatus startRecv(unsigned num, T *arr, unsigned sendRank, int tag=-1) const
Receive an array from another rank.
Definition: wxmsgbase.h:199
WxMsgStatus startSend(unsigned num, const T *arr, unsigned recvRank, int tag=-1) const
Send an array to another rank.
Definition: wxmsgbase.h:128
void broadcast(unsigned num, T *buffer, int root) const
Definition: wxmsgbase.h:272
WxTypeMap< WxDataTypes_t, WxMsgContainer > WxMsgTypeMap_t
Definition: wxmsgbase.h:349
virtual WxMsgBase * splitComm(int color, int order)=0
See MPI_Comm_split.
virtual void * finishRecv(WxMsgStatus ms) const =0
Finish the receive started by startRecv and return a pointer to the data recieved.
void recv(unsigned num, T *array, unsigned sendRank, int tag=-1) const
Receive an array from another rank.
Definition: wxmsgbase.h:166
virtual void finishSend(WxMsgStatus ms) const =0
Finish the send started by startSend.
void send(const std::vector< T > &array, unsigned recvRank, int tag=-1) const
Send a std::vector to another rank.
Definition: wxmsgbase.h:82
void allReduce(unsigned num, T *sendBuff, T *recvBuff, MPI_Op op) const
Reduce data to all ranks.
Definition: wxmsgbase.h:250
WxMsgBase(int sendTag=0, int recvTag=0, WxMsgBase *parent=0)
Constructor.
Definition: wxmsgbase.h:281
WxMsgStatus startRecv(std::vector< T > &vec, unsigned sendRank, int tag=-1) const
Receive an array from another rank.
Definition: wxmsgbase.h:216
virtual bool checkRecv(WxMsgStatus ms) const =0
Check status of recieve started by a startRecv.
virtual WxMsgBase * createSubComm(const std::vector< int > &ranks)=0
Split communicator into a child communicator.
virtual unsigned numProcs() const =0
Number of processes taking part in messaging.
WxMsgStatus startRecv(unsigned num, unsigned sendRank, int tag=-1) const
Receive an array from another rank.
Definition: wxmsgbase.h:182
Provides interface for messaging between processes.
Definition: wxmsgtmpl.h:27
WxTypeMap can be used to generate a whole class hierachy at compile time.
Definition: wxtypelist.h:200
wxm::lib::Except is the class to use for creating and throwing exceptions.
Definition: wxexcept.h:31
Definition: wxmsgbase.h:334
WxMsgTmpl< T > * _msg
Definition: wxmsgbase.h:343
virtual ~WxMsgContainer()
Definition: wxmsgbase.h:338
WxMsgContainer()
Definition: wxmsgbase.h:335
Provides a means for derived messengers to return implimentation specific message status flags and da...
Definition: wxmsgtmpl.h:19