Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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:
Inheritance graph
[legend]
Collaboration diagram for Nektar::LibUtilities::CommSerial:
Collaboration graph
[legend]

Public Member Functions

 CommSerial (int argc, char *argv[])
 
virtual ~CommSerial ()
 
- 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 T >
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)
 
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 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

virtual void v_Finalise ()
 
virtual int v_GetRank ()
 
virtual bool v_TreatAsRankZero (void)
 
virtual void v_Block ()
 
virtual NekDouble v_Wtime ()
 
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_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)
 

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...
 

Detailed Description

A global linear system.

Definition at line 55 of file CommSerial.h.

Constructor & Destructor Documentation

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

Definition at line 49 of file CommSerial.cpp.

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

49  : Comm(argc, argv)
50 {
51 #ifdef NEKTAR_USING_PETSC
52  PetscInitializeNoArguments();
53 #endif
54  m_size = 1;
55  m_type = "Serial";
56 }
std::string m_type
Type of communication.
Definition: Comm.h:131
int m_size
Number of processes.
Definition: Comm.h:130
Nektar::LibUtilities::CommSerial::~CommSerial ( )
virtual

Definition at line 58 of file CommSerial.cpp.

59 {
60 }

Member Function Documentation

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

Creates an instance of this class.

Definition at line 59 of file CommSerial.h.

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

60  {
62  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
void Nektar::LibUtilities::CommSerial::v_AllReduce ( void buf,
int  count,
CommDataType  dt,
enum ReduceOperator  pOp 
)
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 137 of file CommSerial.cpp.

139 {
140 }
void Nektar::LibUtilities::CommSerial::v_AlltoAll ( void sendbuf,
int  sendcount,
CommDataType  sendtype,
void recvbuf,
int  recvcount,
CommDataType  recvtype 
)
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 145 of file CommSerial.cpp.

147 {
148 }
void Nektar::LibUtilities::CommSerial::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 153 of file CommSerial.cpp.

157 {
158 }
void Nektar::LibUtilities::CommSerial::v_Bcast ( void buffer,
int  count,
CommDataType  dt,
int  root 
)
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 160 of file CommSerial.cpp.

161 {
162 }
void Nektar::LibUtilities::CommSerial::v_Block ( )
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 91 of file CommSerial.cpp.

92 {
93 }
CommSharedPtr Nektar::LibUtilities::CommSerial::v_CommCreateIf ( int  flag)
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 194 of file CommSerial.cpp.

References ASSERTL0.

195 {
196  ASSERTL0(flag, "Serial process must always be split");
197  return shared_from_this();
198 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
void Nektar::LibUtilities::CommSerial::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 164 of file CommSerial.cpp.

167 {
168 }
void Nektar::LibUtilities::CommSerial::v_Finalise ( )
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 65 of file CommSerial.cpp.

66 {
67 #ifdef NEKTAR_USING_PETSC
68  PetscFinalize();
69 #endif
70 }
void Nektar::LibUtilities::CommSerial::v_Gather ( void sendbuf,
int  sendcount,
CommDataType  sendtype,
void recvbuf,
int  recvcount,
CommDataType  recvtype,
int  root 
)
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 170 of file CommSerial.cpp.

References Nektar::LibUtilities::CommDataTypeGetSize().

173 {
174  std::memcpy(recvbuf, sendbuf, sendcount * CommDataTypeGetSize(sendtype));
175 }
int CommDataTypeGetSize(CommDataType dt)
Return the size in bytes of a data type dt.
int Nektar::LibUtilities::CommSerial::v_GetRank ( void  )
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Reimplemented in Nektar::FieldUtils::FieldConvertComm.

Definition at line 75 of file CommSerial.cpp.

76 {
77  return 0;
78 }
void Nektar::LibUtilities::CommSerial::v_Recv ( void buf,
int  count,
CommDataType  dt,
int  source 
)
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 113 of file CommSerial.cpp.

114 {
115 }
void Nektar::LibUtilities::CommSerial::v_Scatter ( void sendbuf,
int  sendcount,
CommDataType  sendtype,
void recvbuf,
int  recvcount,
CommDataType  recvtype,
int  root 
)
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 177 of file CommSerial.cpp.

References Nektar::LibUtilities::CommDataTypeGetSize().

180 {
181  std::memcpy(recvbuf, sendbuf, sendcount * CommDataTypeGetSize(sendtype));
182 }
int CommDataTypeGetSize(CommDataType dt)
Return the size in bytes of a data type dt.
void Nektar::LibUtilities::CommSerial::v_Send ( void buf,
int  count,
CommDataType  dt,
int  dest 
)
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 106 of file CommSerial.cpp.

107 {
108 }
void Nektar::LibUtilities::CommSerial::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 120 of file CommSerial.cpp.

123 {
124 }
void Nektar::LibUtilities::CommSerial::v_SendRecvReplace ( void buf,
int  count,
CommDataType  dt,
int  pSendProc,
int  pRecvProc 
)
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 129 of file CommSerial.cpp.

131 {
132 }
void Nektar::LibUtilities::CommSerial::v_SplitComm ( int  pRows,
int  pColumns 
)
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Reimplemented in Nektar::FieldUtils::FieldConvertComm.

Definition at line 186 of file CommSerial.cpp.

References ASSERTL0.

187 {
188  ASSERTL0(false, "Cannot split a serial process.");
189 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
bool Nektar::LibUtilities::CommSerial::v_TreatAsRankZero ( void  )
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Reimplemented in Nektar::FieldUtils::FieldConvertComm.

Definition at line 83 of file CommSerial.cpp.

84 {
85  return true;
86 }
NekDouble Nektar::LibUtilities::CommSerial::v_Wtime ( )
protectedvirtual

Implements Nektar::LibUtilities::Comm.

Definition at line 98 of file CommSerial.cpp.

99 {
100  return 0;
101 }

Member Data Documentation

std::string Nektar::LibUtilities::CommSerial::className
static
Initial value:
"Serial", CommSerial::create, "Single-process serial communication.")

Name of class.

Definition at line 65 of file CommSerial.h.