35 #ifndef NEKTAR_LIB_UTILITIES_COMM_H
36 #define NEKTAR_LIB_UTILITIES_COMM_H
42 #include <boost/enable_shared_from_this.hpp>
43 #include <boost/static_assert.hpp>
52 namespace LibUtilities
75 class Comm :
public boost::enable_shared_from_this<Comm>
94 template <
class T>
void Send(
int pProc, T &pData);
95 template <
class T>
void Recv(
int pProc, T &pData);
97 void SendRecv(
int pSendProc, T &pSendData,
int pRecvProc, T &pRecvData);
103 template <
class T>
void AlltoAll(T &pSendData, T &pRecvData);
112 template <
class T>
void Bcast(T &data,
int rootProc);
117 template <
class T> T
Gather(
const int rootProc, T &val);
118 template <
class T> T
Scatter(
const int rootProc, T &pData);
144 int dest,
void *recvbuf,
int recvcount,
147 int pSendProc,
int pRecvProc) = 0;
151 void *recvbuf,
int recvcount,
153 virtual void v_AlltoAllv(
void *sendbuf,
int sendcounts[],
int sensdispls[],
155 int recvcounts[],
int rdispls[],
172 virtual void v_SplitComm(
int pRows,
int pColumns) = 0;
277 BOOST_STATIC_ASSERT_MSG(
279 "AlltoAll only valid with Array or vector arguments.");
283 "Send and Recv arrays have incompatible sizes in AlltoAll");
285 int count = sendSize /
GetSize();
287 "Array size incompatible with size of communicator");
306 v_AlltoAllv(pSendData.get(), pSendDataSizeMap.get(),
308 pRecvData.get(), pRecvDataSizeMap.get(),
327 "Input and output array sizes don't match");
340 BOOST_STATIC_ASSERT_MSG(
342 "Gather only valid with Array or vector arguments.");
343 bool amRoot = (
GetRank() == rootProc);
346 unsigned nOut = amRoot ?
GetSize() * nEl : 0;
350 v_Gather(CommDataTypeTraits<T>::GetPointer(val), nEl,
360 BOOST_STATIC_ASSERT_MSG(
362 "Scatter only valid with Array or vector arguments.");
364 bool amRoot = (
GetRank() == rootProc);
371 CommDataTypeTraits<T>::GetPointer(ans), nEl,
401 return shared_from_this();
417 return shared_from_this();
void Exscan(T &pData, const enum ReduceOperator pOp, T &ans)
void Recv(int pProc, T &pData)
void AllReduce(T &pData, enum ReduceOperator pOp)
#define ASSERTL0(condition, msg)
virtual void v_Recv(void *buf, int count, CommDataType dt, int source)=0
ReduceOperator
Type of operation to perform in AllReduce.
CommSharedPtr m_commColumn
Column communicator.
virtual void v_AllReduce(void *buf, int count, CommDataType dt, enum ReduceOperator pOp)=0
std::string m_type
Type of communication.
bool TreatAsRankZero(void)
virtual void v_AlltoAllv(void *sendbuf, int sendcounts[], int sensdispls[], CommDataType sendtype, void *recvbuf, int recvcounts[], int rdispls[], CommDataType recvtype)=0
static int GetCount(const T &val)
void AlltoAllv(Array< OneD, T > &pSendData, Array< OneD, int > &pSendDataSizeMap, Array< OneD, int > &pSendDataOffsetMap, Array< OneD, T > &pRecvData, Array< OneD, int > &pRecvDataSizeMap, Array< OneD, int > &pRecvDataOffsetMap)
virtual void v_Send(void *buf, int count, CommDataType dt, int dest)=0
CommFactory & GetCommFactory()
CommSharedPtr m_commRow
Row communicator.
void AlltoAll(T &pSendData, T &pRecvData)
void SendRecv(int pSendProc, T &pSendData, int pRecvProc, T &pRecvData)
virtual void v_SendRecv(void *sendbuf, int sendcount, CommDataType sendtype, int dest, void *recvbuf, int recvcount, CommDataType recvtype, int source)=0
virtual bool v_RemoveExistingFiles(void)
virtual void v_Exscan(Array< OneD, unsigned long long > &pData, const enum ReduceOperator pOp, Array< OneD, unsigned long long > &ans)=0
virtual void v_Bcast(void *buffer, int count, CommDataType dt, int root)=0
NekDouble Wtime()
Return the time in seconds.
CommSharedPtr GetRowComm()
Retrieve the row communicator to which this process belongs.
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
virtual void v_Gather(void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype, int root)=0
virtual CommSharedPtr v_CommCreateIf(int flag)=0
T Scatter(const int rootProc, T &pData)
LibUtilities::NekFactory< std::string, Comm, int, char ** > CommFactory
Datatype of the NekFactory used to instantiate classes derived from the EquationSystem class...
virtual void v_Scatter(void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype, int root)=0
const std::string & GetType() const
#define LIB_UTILITIES_EXPORT
virtual int v_GetRank()=0
void Bcast(T &data, int rootProc)
virtual bool v_TreatAsRankZero(void)=0
virtual void v_Finalise()=0
void Send(int pProc, T &pData)
static CommDataType & GetDataType()
void SplitComm(int pRows, int pColumns)
Splits this communicator into a grid of size pRows*pColumns and creates row and column communicators...
Base communications class.
virtual void v_AlltoAll(void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype)=0
void Block()
Block execution until all processes reach this point.
T Gather(const int rootProc, T &val)
#define dest(otri, vertexptr)
void SendRecvReplace(int pSendProc, int pRecvProc, T &pData)
int GetSize()
Returns number of processes.
static void * GetPointer(T &val)
virtual void v_SplitComm(int pRows, int pColumns)=0
CommSharedPtr CommCreateIf(int flag)
If the flag is non-zero create a new communicator.
virtual NekDouble v_Wtime()=0
virtual void v_SendRecvReplace(void *buf, int count, CommDataType dt, int pSendProc, int pRecvProc)=0
int m_size
Number of processes.
bool RemoveExistingFiles(void)
Provides a generic Factory class.
CommSharedPtr GetColumnComm()
Retrieve the column communicator to which this process belongs.