36 #ifdef NEKTAR_USING_PETSC
45 namespace LibUtilities
56 MPI_Initialized(&init);
57 ASSERTL0(!init,
"MPI has already been initialised.");
59 int retval = MPI_Init(&narg, &arg);
60 if (retval != MPI_SUCCESS)
62 ASSERTL0(
false,
"Failed to initialise MPI");
69 #ifdef NEKTAR_USING_PETSC
70 PetscInitializeNoArguments();
108 #ifdef NEKTAR_USING_PETSC
112 MPI_Finalized(&flag);
166 MPI_Ssend(buf, count, dt, dest, 0,
m_comm);
170 MPI_Send(buf, count, dt, dest, 0,
m_comm);
179 MPI_Recv(buf, count, dt, source, 0,
m_comm, MPI_STATUS_IGNORE);
188 int dest,
void *recvbuf,
int recvcount,
192 int retval = MPI_Sendrecv(sendbuf, sendcount, sendtype, dest, 0, recvbuf,
193 recvcount, recvtype, source, 0,
m_comm, &status);
196 "MPI error performing send-receive of data.");
203 int pSendProc,
int pRecvProc)
206 int retval = MPI_Sendrecv_replace(buf, count, dt, pRecvProc, 0, pSendProc,
210 "MPI error performing Send-Receive-Replace of data.");
238 int retval = MPI_Allreduce(MPI_IN_PLACE, buf, count, dt, vOp,
m_comm);
240 ASSERTL0(retval == MPI_SUCCESS,
"MPI error performing All-reduce.");
249 int retval = MPI_Alltoall(sendbuf, sendcount, sendtype, recvbuf, recvcount,
252 ASSERTL0(retval == MPI_SUCCESS,
"MPI error performing All-to-All.");
260 int recvcounts[],
int rdispls[],
263 int retval = MPI_Alltoallv(sendbuf, sendcounts, sdispls, sendtype, recvbuf,
264 recvcounts, rdispls, recvtype,
m_comm);
266 ASSERTL0(retval == MPI_SUCCESS,
"MPI error performing All-to-All-v.");
271 int retval = MPI_Bcast(buffer, count, dt, root,
m_comm);
272 ASSERTL0(retval == MPI_SUCCESS,
"MPI error performing Bcast-v.");
279 int n = pData.num_elements();
280 ASSERTL0(n == ans.num_elements(),
"Array sizes differ in Exscan");
299 ASSERTL0(retval == MPI_SUCCESS,
"MPI error performing Exscan-v.");
306 int retval = MPI_Gather(sendbuf, sendcount, sendtype, recvbuf, recvcount,
309 ASSERTL0(retval == MPI_SUCCESS,
"MPI error performing Gather.");
316 int retval = MPI_Scatter(sendbuf, sendcount, sendtype, recvbuf, recvcount,
318 ASSERTL0(retval == MPI_SUCCESS,
"MPI error performing Scatter.");
330 "Rows/Columns do not match comm size.");
335 int myCol =
m_rank % pColumns;
336 int myRow = (
m_rank - myCol) / pColumns;
341 MPI_Comm_split(
m_comm, myRow, myCol, &newComm);
347 MPI_Comm_split(
m_comm, myCol, myRow, &newComm);
360 MPI_Comm_split(
m_comm, flag ? 0 : MPI_UNDEFINED, 0, &newComm);
365 return boost::shared_ptr<Comm>();
370 return boost::shared_ptr<Comm>(
new CommMpi(newComm));
virtual void v_SendRecvReplace(void *buf, int count, CommDataType dt, int pSendProc, int pRecvProc)
#define ASSERTL0(condition, msg)
ReduceOperator
Type of operation to perform in AllReduce.
virtual void v_Recv(void *buf, int count, CommDataType dt, int source)
virtual void v_Finalise()
CommSharedPtr m_commColumn
Column communicator.
virtual void v_Send(void *buf, int count, CommDataType dt, int dest)
std::string m_type
Type of communication.
virtual void v_AllReduce(void *buf, int count, CommDataType dt, enum ReduceOperator pOp)
virtual void v_AlltoAllv(void *sendbuf, int sendcounts[], int sensdispls[], CommDataType sendtype, void *recvbuf, int recvcounts[], int rdispls[], CommDataType recvtype)
CommFactory & GetCommFactory()
CommSharedPtr m_commRow
Row communicator.
static CommSharedPtr create(int narg, char *arg[])
Creates an instance of this class.
virtual CommSharedPtr v_CommCreateIf(int flag)
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
virtual void v_SplitComm(int pRows, int pColumns)
CommMpi(int narg, char *arg[])
virtual bool v_TreatAsRankZero(void)
virtual void v_Scatter(void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype, int root)
Base communications class.
static std::string className
Name of class.
#define dest(otri, vertexptr)
virtual void v_Exscan(Array< OneD, unsigned long long > &pData, const enum ReduceOperator pOp, Array< OneD, unsigned long long > &ans)
virtual void v_Bcast(void *buffer, int count, CommDataType dt, int root)
virtual void v_SendRecv(void *sendbuf, int sendcount, CommDataType sendtype, int dest, void *recvbuf, int recvcount, CommDataType recvtype, int source)
int GetSize()
Returns number of processes.
virtual void v_Gather(void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype, int root)
int m_size
Number of processes.
virtual void v_AlltoAll(void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype)
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.