Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Nektar::LibUtilities::CommMpi Class Reference

A global linear system. More...

#include <CommMpi.h>

Inheritance diagram for Nektar::LibUtilities::CommMpi:
[legend]

Public Member Functions

 CommMpi (int narg, char *arg[])
 
virtual ~CommMpi ()
 
MPI_Comm GetComm ()
 
- Public Member Functions inherited from Nektar::LibUtilities::Comm
 Comm (int narg, char *arg[])
 
virtual ~Comm ()
 
void Finalise ()
 
int GetSize ()
 Returns number of processes. More...
 
int GetRank ()
 
const std::string & GetType () const
 
void Block ()
 Block execution until all processes reach this point. More...
 
NekDouble Wtime ()
 Return the time in seconds. More...
 
template<class T >
void Send (int pProc, T &pData)
 
template<class T >
void Recv (int pProc, T &pData)
 
template<class T >
void SendRecv (int pSendProc, T &pSendData, int pRecvProc, T &pRecvData)
 
template<class T >
void SendRecvReplace (int pSendProc, int pRecvProc, T &pData)
 
template<class T >
void AllReduce (T &pData, enum ReduceOperator pOp)
 
template<class T >
void AlltoAll (T &pSendData, T &pRecvData)
 
template<class T1 , class T2 >
void AlltoAllv (T1 &pSendData, T2 &pSendDataSizeMap, T2 &pSendDataOffsetMap, T1 &pRecvData, T2 &pRecvDataSizeMap, T2 &pRecvDataOffsetMap)
 
template<class T >
void AllGather (T &pSendData, T &pRecvData)
 
template<class T >
void AllGatherv (T &pSendData, T &pRecvData, Array< OneD, int > &pRecvDataSizeMap, Array< OneD, int > &pRecvDataOffsetMap)
 
template<class T >
void AllGatherv (T &pRecvData, Array< OneD, int > &pRecvDataSizeMap, Array< OneD, int > &pRecvDataOffsetMap)
 
template<class T >
void Bcast (T &data, int rootProc)
 
template<class T >
void Exscan (T &pData, const enum ReduceOperator pOp, T &ans)
 
template<class T >
Gather (const int rootProc, T &val)
 
template<class T >
Scatter (const int rootProc, T &pData)
 
CommSharedPtr CommCreateIf (int flag)
 If the flag is non-zero create a new communicator. More...
 
void SplitComm (int pRows, int pColumns)
 Splits this communicator into a grid of size pRows*pColumns and creates row and column communicators. By default the communicator is a single row. More...
 
CommSharedPtr GetRowComm ()
 Retrieve the row communicator to which this process belongs. More...
 
CommSharedPtr GetColumnComm ()
 Retrieve the column communicator to which this process belongs. More...
 
bool TreatAsRankZero (void)
 
bool IsSerial (void)
 
bool RemoveExistingFiles (void)
 

Static Public Member Functions

static CommSharedPtr create (int narg, char *arg[])
 Creates an instance of this class. More...
 

Static Public Attributes

static std::string className
 Name of class. More...
 

Protected Member Functions

 CommMpi (MPI_Comm pComm)
 
 CommMpi ()
 
virtual void v_Finalise ()
 
virtual int v_GetRank ()
 
virtual void v_Block ()
 
virtual double v_Wtime ()
 
virtual bool v_TreatAsRankZero (void)
 
virtual bool v_IsSerial (void)
 
virtual void v_Send (void *buf, int count, CommDataType dt, int dest)
 
virtual void v_Recv (void *buf, int count, CommDataType dt, int source)
 
virtual void v_SendRecv (void *sendbuf, int sendcount, CommDataType sendtype, int dest, void *recvbuf, int recvcount, CommDataType recvtype, int source)
 
virtual void v_SendRecvReplace (void *buf, int count, CommDataType dt, int pSendProc, int pRecvProc)
 
virtual void v_AllReduce (void *buf, int count, CommDataType dt, enum ReduceOperator pOp)
 
virtual void v_AlltoAll (void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype)
 
virtual void v_AlltoAllv (void *sendbuf, int sendcounts[], int sensdispls[], CommDataType sendtype, void *recvbuf, int recvcounts[], int rdispls[], CommDataType recvtype)
 
virtual void v_AllGather (void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype)
 
virtual void v_AllGatherv (void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcounts[], int rdispls[], CommDataType recvtype)
 
virtual void v_AllGatherv (void *recvbuf, int recvcounts[], int rdispls[], CommDataType recvtype)
 
virtual void v_Bcast (void *buffer, int count, CommDataType dt, int root)
 
virtual void v_Exscan (Array< OneD, unsigned long long > &pData, const enum ReduceOperator pOp, Array< OneD, unsigned long long > &ans)
 
virtual void v_Gather (void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype, int root)
 
virtual void v_Scatter (void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype, int root)
 
virtual void v_SplitComm (int pRows, int pColumns)
 
virtual CommSharedPtr v_CommCreateIf (int flag)
 
- Protected Member Functions inherited from Nektar::LibUtilities::Comm
 Comm ()
 
virtual bool v_RemoveExistingFiles (void)
 

Protected Attributes

MPI_Comm m_comm
 
int m_rank
 
- Protected Attributes inherited from Nektar::LibUtilities::Comm
int m_size
 Number of processes. More...
 
std::string m_type
 Type of communication. More...
 
CommSharedPtr m_commRow
 Row communicator. More...
 
CommSharedPtr m_commColumn
 Column communicator. More...
 

Detailed Description

A global linear system.

Definition at line 60 of file CommMpi.h.

Constructor & Destructor Documentation

◆ CommMpi() [1/3]

Nektar::LibUtilities::CommMpi::CommMpi ( int  narg,
char *  arg[] 
)

Definition at line 52 of file CommMpi.cpp.

References ASSERTL0, m_comm, m_rank, Nektar::LibUtilities::Comm::m_size, and Nektar::LibUtilities::Comm::m_type.

52  : Comm(narg, arg)
53 {
54  int init = 0;
55  MPI_Initialized(&init);
56  ASSERTL0(!init, "MPI has already been initialised.");
57 
58  int retval = MPI_Init(&narg, &arg);
59  if (retval != MPI_SUCCESS)
60  {
61  ASSERTL0(false, "Failed to initialise MPI");
62  }
63 
64  m_comm = MPI_COMM_WORLD;
65  MPI_Comm_size(m_comm, &m_size);
66  MPI_Comm_rank(m_comm, &m_rank);
67 
68 #ifdef NEKTAR_USING_PETSC
69  PetscInitializeNoArguments();
70 #endif
71 
72  m_type = "Parallel MPI";
73 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
std::string m_type
Type of communication.
Definition: Comm.h:149
int m_size
Number of processes.
Definition: Comm.h:148

◆ ~CommMpi()

Nektar::LibUtilities::CommMpi::~CommMpi ( )
virtual

Definition at line 90 of file CommMpi.cpp.

References m_comm.

91 {
92  int flag;
93  MPI_Finalized(&flag);
94  if (!flag && m_comm != MPI_COMM_WORLD)
95  {
96  MPI_Comm_free(&m_comm);
97  }
98 }

◆ CommMpi() [2/3]

Nektar::LibUtilities::CommMpi::CommMpi ( MPI_Comm  pComm)
protected

Definition at line 78 of file CommMpi.cpp.

References m_comm, m_rank, Nektar::LibUtilities::Comm::m_size, and Nektar::LibUtilities::Comm::m_type.

78  : Comm()
79 {
80  m_comm = pComm;
81  MPI_Comm_size(m_comm, &m_size);
82  MPI_Comm_rank(m_comm, &m_rank);
83 
84  m_type = "Parallel MPI";
85 }
std::string m_type
Type of communication.
Definition: Comm.h:149
int m_size
Number of processes.
Definition: Comm.h:148

◆ CommMpi() [3/3]

Nektar::LibUtilities::CommMpi::CommMpi ( )
inlineprotected

Member Function Documentation

◆ create()

static CommSharedPtr Nektar::LibUtilities::CommMpi::create ( int  narg,
char *  arg[] 
)
inlinestatic

Creates an instance of this class.

Definition at line 64 of file CommMpi.h.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr().

65  {
67  }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.

◆ GetComm()

MPI_Comm Nektar::LibUtilities::CommMpi::GetComm ( )

Definition at line 103 of file CommMpi.cpp.

References m_comm.

Referenced by Nektar::MultiRegions::GlobalLinSysPETSc::GlobalLinSysPETSc().

104 {
105  return m_comm;
106 }

◆ v_AllGather()

void Nektar::LibUtilities::CommMpi::v_AllGather ( void sendbuf,
int  sendcount,
CommDataType  sendtype,
void recvbuf,
int  recvcount,
CommDataType  recvtype 
)
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 292 of file CommMpi.cpp.

References ASSERTL0, and m_comm.

Referenced by CommMpi().

294 {
295  int retval = MPI_Allgather(sendbuf, sendcount, sendtype, recvbuf, recvcount,
296  recvtype, m_comm);
297 
298  ASSERTL0(retval == MPI_SUCCESS, "MPI error performing Allgather.");
299 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216

◆ v_AllGatherv() [1/2]

void Nektar::LibUtilities::CommMpi::v_AllGatherv ( void sendbuf,
int  sendcount,
CommDataType  sendtype,
void recvbuf,
int  recvcounts[],
int  rdispls[],
CommDataType  recvtype 
)
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 301 of file CommMpi.cpp.

References ASSERTL0, and m_comm.

Referenced by CommMpi().

304 {
305  int retval = MPI_Allgatherv(sendbuf, sendcount, sendtype, recvbuf,
306  recvcounts, rdispls, recvtype, m_comm);
307 
308  ASSERTL0(retval == MPI_SUCCESS, "MPI error performing Allgather.");
309 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216

◆ v_AllGatherv() [2/2]

void Nektar::LibUtilities::CommMpi::v_AllGatherv ( void recvbuf,
int  recvcounts[],
int  rdispls[],
CommDataType  recvtype 
)
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 311 of file CommMpi.cpp.

References ASSERTL0, and m_comm.

313 {
314  int retval = MPI_Allgatherv(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, recvbuf,
315  recvcounts, rdispls, recvtype, m_comm);
316 
317  ASSERTL0(retval == MPI_SUCCESS, "MPI error performing Allgatherv.");
318 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216

◆ v_AllReduce()

void Nektar::LibUtilities::CommMpi::v_AllReduce ( void buf,
int  count,
CommDataType  dt,
enum ReduceOperator  pOp 
)
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 236 of file CommMpi.cpp.

References ASSERTL0, Nektar::LibUtilities::Comm::GetSize(), m_comm, Nektar::LibUtilities::ReduceMax, Nektar::LibUtilities::ReduceMin, and Nektar::LibUtilities::ReduceSum.

Referenced by CommMpi().

238 {
239  if (GetSize() == 1)
240  {
241  return;
242  }
243 
244  MPI_Op vOp;
245  switch (pOp)
246  {
247  case ReduceMax:
248  vOp = MPI_MAX;
249  break;
250  case ReduceMin:
251  vOp = MPI_MIN;
252  break;
253  case ReduceSum:
254  default:
255  vOp = MPI_SUM;
256  break;
257  }
258  int retval = MPI_Allreduce(MPI_IN_PLACE, buf, count, dt, vOp, m_comm);
259 
260  ASSERTL0(retval == MPI_SUCCESS, "MPI error performing All-reduce.");
261 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
int GetSize()
Returns number of processes.
Definition: Comm.h:215

◆ v_AlltoAll()

void Nektar::LibUtilities::CommMpi::v_AlltoAll ( void sendbuf,
int  sendcount,
CommDataType  sendtype,
void recvbuf,
int  recvcount,
CommDataType  recvtype 
)
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 266 of file CommMpi.cpp.

References ASSERTL0, and m_comm.

Referenced by CommMpi().

268 {
269  int retval = MPI_Alltoall(sendbuf, sendcount, sendtype, recvbuf, recvcount,
270  recvtype, m_comm);
271 
272  ASSERTL0(retval == MPI_SUCCESS, "MPI error performing All-to-All.");
273 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216

◆ v_AlltoAllv()

void Nektar::LibUtilities::CommMpi::v_AlltoAllv ( void sendbuf,
int  sendcounts[],
int  sensdispls[],
CommDataType  sendtype,
void recvbuf,
int  recvcounts[],
int  rdispls[],
CommDataType  recvtype 
)
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 278 of file CommMpi.cpp.

References ASSERTL0, and m_comm.

Referenced by CommMpi().

282 {
283  int retval = MPI_Alltoallv(sendbuf, sendcounts, sdispls, sendtype, recvbuf,
284  recvcounts, rdispls, recvtype, m_comm);
285 
286  ASSERTL0(retval == MPI_SUCCESS, "MPI error performing All-to-All-v.");
287 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216

◆ v_Bcast()

void Nektar::LibUtilities::CommMpi::v_Bcast ( void buffer,
int  count,
CommDataType  dt,
int  root 
)
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 320 of file CommMpi.cpp.

References ASSERTL0, and m_comm.

Referenced by CommMpi().

321 {
322  int retval = MPI_Bcast(buffer, count, dt, root, m_comm);
323  ASSERTL0(retval == MPI_SUCCESS, "MPI error performing Bcast-v.");
324 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
array buffer
Definition: GsLib.hpp:61

◆ v_Block()

void Nektar::LibUtilities::CommMpi::v_Block ( )
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 166 of file CommMpi.cpp.

References m_comm.

Referenced by CommMpi().

167 {
168  MPI_Barrier(m_comm);
169 }

◆ v_CommCreateIf()

CommSharedPtr Nektar::LibUtilities::CommMpi::v_CommCreateIf ( int  flag)
protectedvirtual

Create a new communicator if the flag is non-zero.

Implements Nektar::LibUtilities::Comm.

Definition at line 405 of file CommMpi.cpp.

References CommMpi(), and m_comm.

Referenced by CommMpi().

406 {
407  MPI_Comm newComm;
408  // color == MPI_UNDEF => not in the new communicator
409  // key == 0 on all => use rank to order them. OpenMPI, at least,
410  // implies this is faster than ordering them ourselves.
411  MPI_Comm_split(m_comm, flag ? 0 : MPI_UNDEFINED, 0, &newComm);
412 
413  if (flag == 0)
414  {
415  // flag == 0 => get back MPI_COMM_NULL, return a null ptr instead.
416  return std::shared_ptr<Comm>();
417  }
418  else
419  {
420  // Return a real communicator
421  return std::shared_ptr<Comm>(new CommMpi(newComm));
422  }
423 }

◆ v_Exscan()

void Nektar::LibUtilities::CommMpi::v_Exscan ( Array< OneD, unsigned long long > &  pData,
const enum ReduceOperator  pOp,
Array< OneD, unsigned long long > &  ans 
)
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 326 of file CommMpi.cpp.

References ASSERTL0, m_comm, Nektar::LibUtilities::MPI_UNSIGNED_LONG_LONG, Nektar::LibUtilities::ReduceMax, Nektar::LibUtilities::ReduceMin, and Nektar::LibUtilities::ReduceSum.

Referenced by CommMpi().

329 {
330  int n = pData.num_elements();
331  ASSERTL0(n == ans.num_elements(), "Array sizes differ in Exscan");
332 
333  MPI_Op vOp;
334  switch (pOp)
335  {
336  case ReduceMax:
337  vOp = MPI_MAX;
338  break;
339  case ReduceMin:
340  vOp = MPI_MIN;
341  break;
342  case ReduceSum:
343  default:
344  vOp = MPI_SUM;
345  break;
346  }
347 
348  int retval = MPI_Exscan(pData.get(), ans.get(), n, MPI_UNSIGNED_LONG_LONG,
349  vOp, m_comm);
350  ASSERTL0(retval == MPI_SUCCESS, "MPI error performing Exscan-v.");
351 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216

◆ v_Finalise()

void Nektar::LibUtilities::CommMpi::v_Finalise ( )
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Reimplemented in Nektar::LibUtilities::CommCwipi.

Definition at line 111 of file CommMpi.cpp.

Referenced by CommMpi(), and Nektar::LibUtilities::CommCwipi::v_Finalise().

112 {
113 #ifdef NEKTAR_USING_PETSC
114  PetscFinalize();
115 #endif
116  int flag;
117  MPI_Finalized(&flag);
118  if (!flag)
119  {
120  MPI_Finalize();
121  }
122 }

◆ v_Gather()

void Nektar::LibUtilities::CommMpi::v_Gather ( void sendbuf,
int  sendcount,
CommDataType  sendtype,
void recvbuf,
int  recvcount,
CommDataType  recvtype,
int  root 
)
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 353 of file CommMpi.cpp.

References ASSERTL0, and m_comm.

Referenced by CommMpi().

356 {
357  int retval = MPI_Gather(sendbuf, sendcount, sendtype, recvbuf, recvcount,
358  recvtype, root, m_comm);
359 
360  ASSERTL0(retval == MPI_SUCCESS, "MPI error performing Gather.");
361 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216

◆ v_GetRank()

int Nektar::LibUtilities::CommMpi::v_GetRank ( void  )
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 127 of file CommMpi.cpp.

References m_rank.

Referenced by CommMpi().

128 {
129  return m_rank;
130 }

◆ v_IsSerial()

bool Nektar::LibUtilities::CommMpi::v_IsSerial ( void  )
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 151 of file CommMpi.cpp.

References Nektar::LibUtilities::Comm::m_size.

Referenced by CommMpi().

152 {
153  if(m_size == 1)
154  {
155  return true;
156  }
157  else
158  {
159  return false;
160  }
161 }
int m_size
Number of processes.
Definition: Comm.h:148

◆ v_Recv()

void Nektar::LibUtilities::CommMpi::v_Recv ( void buf,
int  count,
CommDataType  dt,
int  source 
)
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 197 of file CommMpi.cpp.

References m_comm.

Referenced by CommMpi().

198 {
199  MPI_Recv(buf, count, dt, source, 0, m_comm, MPI_STATUS_IGNORE);
200  // ASSERTL0(status.MPI_ERROR == MPI_SUCCESS,
201  // "MPI error receiving data.");
202 }

◆ v_Scatter()

void Nektar::LibUtilities::CommMpi::v_Scatter ( void sendbuf,
int  sendcount,
CommDataType  sendtype,
void recvbuf,
int  recvcount,
CommDataType  recvtype,
int  root 
)
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 363 of file CommMpi.cpp.

References ASSERTL0, and m_comm.

Referenced by CommMpi().

366 {
367  int retval = MPI_Scatter(sendbuf, sendcount, sendtype, recvbuf, recvcount,
368  recvtype, root, m_comm);
369  ASSERTL0(retval == MPI_SUCCESS, "MPI error performing Scatter.");
370 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216

◆ v_Send()

void Nektar::LibUtilities::CommMpi::v_Send ( void buf,
int  count,
CommDataType  dt,
int  dest 
)
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 182 of file CommMpi.cpp.

References m_comm, and MPISYNC.

Referenced by CommMpi().

183 {
184  if (MPISYNC)
185  {
186  MPI_Ssend(buf, count, dt, dest, 0, m_comm);
187  }
188  else
189  {
190  MPI_Send(buf, count, dt, dest, 0, m_comm);
191  }
192 }
#define MPISYNC
Definition: CommMpi.h:44

◆ v_SendRecv()

void Nektar::LibUtilities::CommMpi::v_SendRecv ( void sendbuf,
int  sendcount,
CommDataType  sendtype,
int  dest,
void recvbuf,
int  recvcount,
CommDataType  recvtype,
int  source 
)
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 207 of file CommMpi.cpp.

References ASSERTL0, and m_comm.

Referenced by CommMpi().

210 {
211  MPI_Status status;
212  int retval = MPI_Sendrecv(sendbuf, sendcount, sendtype, dest, 0, recvbuf,
213  recvcount, recvtype, source, 0, m_comm, &status);
214 
215  ASSERTL0(retval == MPI_SUCCESS,
216  "MPI error performing send-receive of data.");
217 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216

◆ v_SendRecvReplace()

void Nektar::LibUtilities::CommMpi::v_SendRecvReplace ( void buf,
int  count,
CommDataType  dt,
int  pSendProc,
int  pRecvProc 
)
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 222 of file CommMpi.cpp.

References ASSERTL0, and m_comm.

Referenced by CommMpi().

224 {
225  MPI_Status status;
226  int retval = MPI_Sendrecv_replace(buf, count, dt, pRecvProc, 0, pSendProc,
227  0, m_comm, &status);
228 
229  ASSERTL0(retval == MPI_SUCCESS,
230  "MPI error performing Send-Receive-Replace of data.");
231 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216

◆ v_SplitComm()

void Nektar::LibUtilities::CommMpi::v_SplitComm ( int  pRows,
int  pColumns 
)
protectedvirtual

Processes are considered as a grid of size pRows*pColumns. Comm objects are created corresponding to the rows and columns of this grid. The row and column to which this process belongs is stored in m_commRow and m_commColumn.

Implements Nektar::LibUtilities::Comm.

Definition at line 378 of file CommMpi.cpp.

References ASSERTL0, CommMpi(), m_comm, Nektar::LibUtilities::Comm::m_commColumn, Nektar::LibUtilities::Comm::m_commRow, m_rank, and Nektar::LibUtilities::Comm::m_size.

Referenced by CommMpi().

379 {
380  ASSERTL0(pRows * pColumns == m_size,
381  "Rows/Columns do not match comm size.");
382 
383  MPI_Comm newComm;
384 
385  // Compute row and column in grid.
386  int myCol = m_rank % pColumns;
387  int myRow = (m_rank - myCol) / pColumns;
388 
389  // Split Comm into rows - all processes with same myRow are put in
390  // the same communicator. The rank within this communicator is the
391  // column index.
392  MPI_Comm_split(m_comm, myRow, myCol, &newComm);
393  m_commRow = std::shared_ptr<Comm>(new CommMpi(newComm));
394 
395  // Split Comm into columns - all processes with same myCol are put
396  // in the same communicator. The rank within this communicator is
397  // the row index.
398  MPI_Comm_split(m_comm, myCol, myRow, &newComm);
399  m_commColumn = std::shared_ptr<Comm>(new CommMpi(newComm));
400 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
CommSharedPtr m_commColumn
Column communicator.
Definition: Comm.h:151
CommSharedPtr m_commRow
Row communicator.
Definition: Comm.h:150
int m_size
Number of processes.
Definition: Comm.h:148

◆ v_TreatAsRankZero()

bool Nektar::LibUtilities::CommMpi::v_TreatAsRankZero ( void  )
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 135 of file CommMpi.cpp.

References m_rank.

Referenced by CommMpi().

136 {
137  if (m_rank == 0)
138  {
139  return true;
140  }
141  else
142  {
143  return false;
144  }
145  return true;
146 }

◆ v_Wtime()

double Nektar::LibUtilities::CommMpi::v_Wtime ( )
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 174 of file CommMpi.cpp.

Referenced by CommMpi().

175 {
176  return MPI_Wtime();
177 }

Member Data Documentation

◆ className

std::string Nektar::LibUtilities::CommMpi::className
static
Initial value:
"ParallelMPI", CommMpi::create, "Parallel communication using MPI.")

Name of class.

Definition at line 70 of file CommMpi.h.

◆ m_comm

MPI_Comm Nektar::LibUtilities::CommMpi::m_comm
protected

◆ m_rank

int Nektar::LibUtilities::CommMpi::m_rank
protected