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

A global linear system. More...

#include <CommSerial.h>

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

Public Member Functions

 CommSerial (int argc, char *argv[])
 
 ~CommSerial () override
 
- Public Member Functions inherited from Nektar::LibUtilities::Comm
 Comm (int narg, char *arg[])
 
virtual ~Comm ()
 
void Finalise ()
 
int GetSize () const
 Returns number of processes. More...
 
int GetRank ()
 
const std::string & GetType () const
 
bool TreatAsRankZero ()
 
bool IsSerial ()
 
bool IsParallelInTime ()
 
std::tuple< int, int, int > GetVersion ()
 
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 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 &pData, int pRoot)
 
template<class T >
Gather (int rootProc, T &val)
 
template<class T >
Scatter (int rootProc, T &pData)
 
template<class T >
void DistGraphCreateAdjacent (T &sources, T &sourceweights, int reorder)
 
template<class T1 , class T2 >
void NeighborAlltoAllv (T1 &pSendData, T2 &pSendDataSizeMap, T2 &pSendDataOffsetMap, T1 &pRecvData, T2 &pRecvDataSizeMap, T2 &pRecvDataOffsetMap)
 
template<class T >
void Irsend (int pProc, T &pData, int count, const CommRequestSharedPtr &request, int loc)
 
template<class T >
void Isend (int pProc, T &pData, int count, const CommRequestSharedPtr &request, int loc)
 
template<class T >
void SendInit (int pProc, T &pData, int count, const CommRequestSharedPtr &request, int loc)
 
template<class T >
void Irecv (int pProc, T &pData, int count, const CommRequestSharedPtr &request, int loc)
 
template<class T >
void RecvInit (int pProc, T &pData, int count, const CommRequestSharedPtr &request, int loc)
 
void StartAll (const CommRequestSharedPtr &request)
 
void WaitAll (const CommRequestSharedPtr &request)
 
CommRequestSharedPtr CreateRequest (int num)
 
CommSharedPtr CommCreateIf (int flag)
 If the flag is non-zero create a new communicator. More...
 
void SplitComm (int pRows, int pColumns, int pTime=1)
 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...
 
CommSharedPtr GetTimeComm ()
 Retrieve the time communicator to which this process belongs. More...
 
CommSharedPtr GetSpaceComm ()
 Retrieve the space communicator to which this process belongs. More...
 
bool RemoveExistingFiles ()
 
std::pair< CommSharedPtr, CommSharedPtrSplitCommNode ()
 

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

void v_Finalise () final
 
int v_GetRank () override
 
bool v_TreatAsRankZero () override
 
bool v_IsSerial () override
 
std::tuple< int, int, int > v_GetVersion () final
 
void v_Block () final
 
NekDouble v_Wtime () final
 
void v_Send (void *buf, int count, CommDataType dt, int dest) final
 
void v_Recv (void *buf, int count, CommDataType dt, int source) final
 
void v_SendRecv (void *sendbuf, int sendcount, CommDataType sendtype, int dest, void *recvbuf, int recvcount, CommDataType recvtype, int source) final
 
void v_AllReduce (void *buf, int count, CommDataType dt, enum ReduceOperator pOp) final
 
void v_AlltoAll (void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype) final
 
void v_AlltoAllv (void *sendbuf, int sendcounts[], int sensdispls[], CommDataType sendtype, void *recvbuf, int recvcounts[], int rdispls[], CommDataType recvtype) final
 
void v_AllGather (void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype) final
 
void v_AllGatherv (void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcounts[], int rdispls[], CommDataType recvtype) final
 
void v_AllGatherv (void *recvbuf, int recvcounts[], int rdispls[], CommDataType recvtype) final
 
void v_Bcast (void *buffer, int count, CommDataType dt, int root) final
 
void v_Gather (void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype, int root) final
 
void v_Scatter (void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype, int root) final
 
void v_DistGraphCreateAdjacent (int indegree, const int sources[], const int sourceweights[], int reorder) final
 
void v_NeighborAlltoAllv (void *sendbuf, int sendcounts[], int sdispls[], CommDataType sendtype, void *recvbuf, int recvcounts[], int rdispls[], CommDataType recvtype) final
 
void v_Irsend (void *buf, int count, CommDataType dt, int dest, CommRequestSharedPtr request, int loc) final
 
void v_Isend (void *buf, int count, CommDataType dt, int dest, CommRequestSharedPtr request, int loc) final
 
void v_SendInit (void *buf, int count, CommDataType dt, int dest, CommRequestSharedPtr request, int loc) final
 
void v_Irecv (void *buf, int count, CommDataType dt, int source, CommRequestSharedPtr request, int loc) final
 
void v_RecvInit (void *buf, int count, CommDataType dt, int source, CommRequestSharedPtr request, int loc) final
 
void v_StartAll (CommRequestSharedPtr request) final
 
void v_WaitAll (CommRequestSharedPtr request) final
 
CommRequestSharedPtr v_CreateRequest (int num) final
 
void v_SplitComm (int pRows, int pColumns, int pTime) override
 
CommSharedPtr v_CommCreateIf (int flag) final
 
- Protected Member Functions inherited from Nektar::LibUtilities::Comm
 Comm ()
 
virtual void v_Finalise ()=0
 
virtual int v_GetRank ()=0
 
virtual bool v_TreatAsRankZero ()=0
 
virtual bool v_IsSerial ()=0
 
virtual std::tuple< int, int, int > v_GetVersion ()=0
 
virtual void v_Block ()=0
 
virtual NekDouble v_Wtime ()=0
 
virtual void v_Send (void *buf, int count, CommDataType dt, int dest)=0
 
virtual void v_Recv (void *buf, int count, CommDataType dt, int source)=0
 
virtual void v_SendRecv (void *sendbuf, int sendcount, CommDataType sendtype, int dest, void *recvbuf, int recvcount, CommDataType recvtype, int source)=0
 
virtual void v_AllReduce (void *buf, int count, CommDataType dt, enum ReduceOperator pOp)=0
 
virtual void v_AlltoAll (void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype)=0
 
virtual void v_AlltoAllv (void *sendbuf, int sendcounts[], int sensdispls[], CommDataType sendtype, void *recvbuf, int recvcounts[], int rdispls[], CommDataType recvtype)=0
 
virtual void v_AllGather (void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype)=0
 
virtual void v_AllGatherv (void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcounts[], int rdispls[], CommDataType recvtype)=0
 
virtual void v_AllGatherv (void *recvbuf, int recvcounts[], int rdispls[], CommDataType recvtype)=0
 
virtual void v_Bcast (void *buffer, int count, CommDataType dt, int root)=0
 
virtual void v_Gather (void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype, int root)=0
 
virtual void v_Scatter (void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype, int root)=0
 
virtual void v_DistGraphCreateAdjacent (int indegree, const int sources[], const int sourceweights[], int reorder)=0
 
virtual void v_NeighborAlltoAllv (void *sendbuf, int sendcounts[], int sdispls[], CommDataType sendtype, void *recvbuf, int recvcounts[], int rdispls[], CommDataType recvtype)=0
 
virtual void v_Irsend (void *buf, int count, CommDataType dt, int dest, CommRequestSharedPtr request, int loc)=0
 
virtual void v_Isend (void *buf, int count, CommDataType dt, int dest, CommRequestSharedPtr request, int loc)=0
 
virtual void v_SendInit (void *buf, int count, CommDataType dt, int dest, CommRequestSharedPtr request, int loc)=0
 
virtual void v_Irecv (void *buf, int count, CommDataType dt, int source, CommRequestSharedPtr request, int loc)=0
 
virtual void v_RecvInit (void *buf, int count, CommDataType dt, int source, CommRequestSharedPtr request, int loc)=0
 
virtual void v_StartAll (CommRequestSharedPtr request)=0
 
virtual void v_WaitAll (CommRequestSharedPtr request)=0
 
virtual CommRequestSharedPtr v_CreateRequest (int num)=0
 
virtual void v_SplitComm (int pRows, int pColumns, int pTime)=0
 
virtual CommSharedPtr v_CommCreateIf (int flag)=0
 
virtual std::pair< CommSharedPtr, CommSharedPtrv_SplitCommNode ()
 

Additional Inherited Members

- 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...
 
CommSharedPtr m_commTime
 
CommSharedPtr m_commSpace
 

Detailed Description

A global linear system.

Definition at line 52 of file CommSerial.h.

Constructor & Destructor Documentation

◆ CommSerial()

Nektar::LibUtilities::CommSerial::CommSerial ( int  argc,
char *  argv[] 
)

Definition at line 46 of file CommSerial.cpp.

46 : Comm(argc, argv)
47{
48#ifdef NEKTAR_USING_PETSC
49 PetscInitializeNoArguments();
50#endif
51 m_size = 1;
52 m_type = "Serial";
53}
int m_size
Number of processes.
Definition: Comm.h:175
std::string m_type
Type of communication.
Definition: Comm.h:176

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

◆ ~CommSerial()

Nektar::LibUtilities::CommSerial::~CommSerial ( )
overridedefault

Member Function Documentation

◆ create()

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

Creates an instance of this class.

Definition at line 56 of file CommSerial.h.

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

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

◆ v_AllGather()

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

Implements Nektar::LibUtilities::Comm.

Definition at line 179 of file CommSerial.cpp.

185{
186}

◆ v_AllGatherv() [1/2]

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

Implements Nektar::LibUtilities::Comm.

Definition at line 204 of file CommSerial.cpp.

208{
209}

◆ v_AllGatherv() [2/2]

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

Implements Nektar::LibUtilities::Comm.

Definition at line 191 of file CommSerial.cpp.

198{
199}

◆ v_AllReduce()

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

Implements Nektar::LibUtilities::Comm.

Definition at line 146 of file CommSerial.cpp.

150{
151}

◆ v_AlltoAll()

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

Implements Nektar::LibUtilities::Comm.

Definition at line 156 of file CommSerial.cpp.

162{
163}

◆ v_AlltoAllv()

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

Implements Nektar::LibUtilities::Comm.

Definition at line 168 of file CommSerial.cpp.

173{
174}

◆ v_Bcast()

void Nektar::LibUtilities::CommSerial::v_Bcast ( void buffer,
int  count,
CommDataType  dt,
int  root 
)
finalprotectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 214 of file CommSerial.cpp.

218{
219}

◆ v_Block()

void Nektar::LibUtilities::CommSerial::v_Block ( )
finalprotectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 102 of file CommSerial.cpp.

103{
104}

◆ v_CommCreateIf()

CommSharedPtr Nektar::LibUtilities::CommSerial::v_CommCreateIf ( int  flag)
finalprotectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 356 of file CommSerial.cpp.

357{
358 if (flag == 0)
359 {
360 // flag == 0 => get back MPI_COMM_NULL, return a null ptr instead.
361 return std::shared_ptr<Comm>();
362 }
363 else
364 {
365 // Return a real communicator
366 return shared_from_this();
367 }
368}

◆ v_CreateRequest()

CommRequestSharedPtr Nektar::LibUtilities::CommSerial::v_CreateRequest ( int  num)
finalprotectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 338 of file CommSerial.cpp.

339{
340 return std::shared_ptr<CommRequest>(new CommRequest);
341}

◆ v_DistGraphCreateAdjacent()

void Nektar::LibUtilities::CommSerial::v_DistGraphCreateAdjacent ( int  indegree,
const int  sources[],
const int  sourceweights[],
int  reorder 
)
finalprotectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 246 of file CommSerial.cpp.

249{
250}

◆ v_Finalise()

void Nektar::LibUtilities::CommSerial::v_Finalise ( )
finalprotectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 60 of file CommSerial.cpp.

61{
62#ifdef NEKTAR_USING_PETSC
63 PetscFinalize();
64#endif
65}

◆ v_Gather()

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

Implements Nektar::LibUtilities::Comm.

Definition at line 224 of file CommSerial.cpp.

228{
229 std::memcpy(recvbuf, sendbuf, sendcount * CommDataTypeGetSize(sendtype));
230}
int CommDataTypeGetSize(CommDataType dt)
Return the size in bytes of a data type dt.

References Nektar::LibUtilities::CommDataTypeGetSize().

◆ v_GetRank()

int Nektar::LibUtilities::CommSerial::v_GetRank ( void  )
overrideprotectedvirtual

Implements Nektar::LibUtilities::Comm.

Reimplemented in Nektar::FieldUtils::FieldConvertComm.

Definition at line 70 of file CommSerial.cpp.

71{
72 return 0;
73}

◆ v_GetVersion()

std::tuple< int, int, int > Nektar::LibUtilities::CommSerial::v_GetVersion ( )
finalprotectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 94 of file CommSerial.cpp.

95{
96 return std::make_tuple(0, 0, 0);
97}

◆ v_Irecv()

void Nektar::LibUtilities::CommSerial::v_Irecv ( void buf,
int  count,
CommDataType  dt,
int  source,
CommRequestSharedPtr  request,
int  loc 
)
finalprotectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 301 of file CommSerial.cpp.

306{
307}

◆ v_Irsend()

void Nektar::LibUtilities::CommSerial::v_Irsend ( void buf,
int  count,
CommDataType  dt,
int  dest,
CommRequestSharedPtr  request,
int  loc 
)
finalprotectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 266 of file CommSerial.cpp.

272{
273}

◆ v_Isend()

void Nektar::LibUtilities::CommSerial::v_Isend ( void buf,
int  count,
CommDataType  dt,
int  dest,
CommRequestSharedPtr  request,
int  loc 
)
finalprotectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 278 of file CommSerial.cpp.

283{
284}

◆ v_IsSerial()

bool Nektar::LibUtilities::CommSerial::v_IsSerial ( void  )
overrideprotectedvirtual

Implements Nektar::LibUtilities::Comm.

Reimplemented in Nektar::FieldUtils::FieldConvertComm.

Definition at line 86 of file CommSerial.cpp.

87{
88 return true;
89}

◆ v_NeighborAlltoAllv()

void Nektar::LibUtilities::CommSerial::v_NeighborAlltoAllv ( void sendbuf,
int  sendcounts[],
int  sdispls[],
CommDataType  sendtype,
void recvbuf,
int  recvcounts[],
int  rdispls[],
CommDataType  recvtype 
)
finalprotectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 255 of file CommSerial.cpp.

260{
261}

◆ v_Recv()

void Nektar::LibUtilities::CommSerial::v_Recv ( void buf,
int  count,
CommDataType  dt,
int  source 
)
finalprotectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 126 of file CommSerial.cpp.

129{
130}

◆ v_RecvInit()

void Nektar::LibUtilities::CommSerial::v_RecvInit ( void buf,
int  count,
CommDataType  dt,
int  source,
CommRequestSharedPtr  request,
int  loc 
)
finalprotectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 312 of file CommSerial.cpp.

318{
319}

◆ v_Scatter()

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

Implements Nektar::LibUtilities::Comm.

Definition at line 235 of file CommSerial.cpp.

239{
240 std::memcpy(recvbuf, sendbuf, sendcount * CommDataTypeGetSize(sendtype));
241}

References Nektar::LibUtilities::CommDataTypeGetSize().

◆ v_Send()

void Nektar::LibUtilities::CommSerial::v_Send ( void buf,
int  count,
CommDataType  dt,
int  dest 
)
finalprotectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 117 of file CommSerial.cpp.

120{
121}

◆ v_SendInit()

void Nektar::LibUtilities::CommSerial::v_SendInit ( void buf,
int  count,
CommDataType  dt,
int  dest,
CommRequestSharedPtr  request,
int  loc 
)
finalprotectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 289 of file CommSerial.cpp.

295{
296}

◆ v_SendRecv()

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

Implements Nektar::LibUtilities::Comm.

Definition at line 135 of file CommSerial.cpp.

140{
141}

◆ v_SplitComm()

void Nektar::LibUtilities::CommSerial::v_SplitComm ( int  pRows,
int  pColumns,
int  pTime 
)
overrideprotectedvirtual

Implements Nektar::LibUtilities::Comm.

Reimplemented in Nektar::FieldUtils::FieldConvertComm.

Definition at line 346 of file CommSerial.cpp.

349{
350 ASSERTL0(false, "Cannot split a serial process.");
351}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208

References ASSERTL0.

◆ v_StartAll()

void Nektar::LibUtilities::CommSerial::v_StartAll ( CommRequestSharedPtr  request)
finalprotectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 324 of file CommSerial.cpp.

325{
326}

◆ v_TreatAsRankZero()

bool Nektar::LibUtilities::CommSerial::v_TreatAsRankZero ( void  )
overrideprotectedvirtual

Implements Nektar::LibUtilities::Comm.

Reimplemented in Nektar::FieldUtils::FieldConvertComm.

Definition at line 78 of file CommSerial.cpp.

79{
80 return true;
81}

◆ v_WaitAll()

void Nektar::LibUtilities::CommSerial::v_WaitAll ( CommRequestSharedPtr  request)
finalprotectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 331 of file CommSerial.cpp.

332{
333}

◆ v_Wtime()

NekDouble Nektar::LibUtilities::CommSerial::v_Wtime ( )
finalprotectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 109 of file CommSerial.cpp.

110{
111 return 0;
112}

Member Data Documentation

◆ className

std::string Nektar::LibUtilities::CommSerial::className
static
Initial value:
"Serial", CommSerial::create, "Single-process serial communication.")
static CommSharedPtr create(int narg, char *arg[])
Creates an instance of this class.
Definition: CommSerial.h:56
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
CommFactory & GetCommFactory()

Name of class.

Definition at line 62 of file CommSerial.h.