WARPXM v1.10.0
Loading...
Searching...
No Matches
wxmpimsgtmpl.h
Go to the documentation of this file.
1#ifndef wxmpimsgtmpl_h
2#define wxmpimsgtmpl_h
3
4// WarpX includes
5#include "wxmpitraits.h"
6#include "wxmsgtmpl.h"
7
8// std includes
9#include <iostream>
10
19{
21 {
22 }
23 MPI_Request request; // send/recv request
24 void* data; // pointer to memory for recv
25};
26
27template<typename T> class WxMpiMsgTmpl : public WxMsgTmpl<T>
28{
29public:
30 WxMpiMsgTmpl(MPI_Comm comm) : _comm(comm), _sending(false)
31 {
32 }
33
41 void send(unsigned num, const T* arr, unsigned recvRank, int tag) const override;
42
48 void finishSend(WxMsgStatus ms) const override;
49
60 startSend(unsigned num, const T* arr, unsigned recvRank, int tag) const override;
61
69 void
70 recv(unsigned num, std::vector<T>& array, unsigned sendRank, int tag) const override;
71
79 void recv(unsigned num, T* array, unsigned sendRank, int tag) const override;
80
89 WxMsgStatus startRecv(unsigned num, unsigned sendRank, int tag) const override;
90
101 startRecv(unsigned num, T* arr, unsigned sendRank, int tag) const override;
102
111 void allReduce(unsigned num, T* sendBuff, T* recvBuff, MPI_Op op) const override;
112
113 void broadcast(unsigned num, T* buffer, int root) const override;
114
115private:
116 MPI_Comm _comm;
117 bool _sending;
118 MPI_Request _sendRequest;
119};
120
121extern template class WxMpiMsgTmpl<char>;
122extern template class WxMpiMsgTmpl<unsigned char>;
123extern template class WxMpiMsgTmpl<short>;
124extern template class WxMpiMsgTmpl<unsigned short>;
125extern template class WxMpiMsgTmpl<int>;
126extern template class WxMpiMsgTmpl<unsigned int>;
127extern template class WxMpiMsgTmpl<long>;
128extern template class WxMpiMsgTmpl<unsigned long>;
129extern template class WxMpiMsgTmpl<float>;
130extern template class WxMpiMsgTmpl<double>;
131extern template class WxMpiMsgTmpl<long double>;
132extern template class WxMpiMsgTmpl<long long int>;
133
135#endif // wxmpimsgtmpl_h
Definition: wxmpimsgtmpl.h:28
void broadcast(unsigned num, T *buffer, int root) const override
WxMpiMsgTmpl(MPI_Comm comm)
Definition: wxmpimsgtmpl.h:30
WxMsgStatus startSend(unsigned num, const T *arr, unsigned recvRank, int tag) const override
Send an array to another rank.
void finishSend(WxMsgStatus ms) const override
Finish the send started by startSend.
WxMsgStatus startRecv(unsigned num, T *arr, unsigned sendRank, int tag) const override
Receive an array from another rank.
void recv(unsigned num, std::vector< T > &array, unsigned sendRank, int tag) const override
Receive an array from another rank.
void allReduce(unsigned num, T *sendBuff, T *recvBuff, MPI_Op op) const override
Reduce data to all ranks.
void recv(unsigned num, T *array, unsigned sendRank, int tag) const override
Receive an array from another rank.
void send(unsigned num, const T *arr, unsigned recvRank, int tag) const override
Send an array to another rank.
WxMsgStatus startRecv(unsigned num, unsigned sendRank, int tag) const override
Receive an array from another rank.
Provides interface for messaging between processes.
Definition: wxmsgtmpl.h:27
Mpi specific message status wrapper.
Definition: wxmpimsgtmpl.h:19
WxMpiMsgStatus_v()
Definition: wxmpimsgtmpl.h:20
void * data
Definition: wxmpimsgtmpl.h:24
MPI_Request request
Definition: wxmpimsgtmpl.h:23
Provides a means for derived messengers to return implimentation specific message status flags and da...
Definition: wxmsgtmpl.h:19