Nektar++
CommMpi.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File CommMpi.h
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: CommMpi header
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 #ifndef NEKTAR_LIB_UTILITIES_COMMMPI_H
35 #define NEKTAR_LIB_UTILITIES_COMMMPI_H
36 
37 #include <mpi.h>
38 #include <string>
39 
42 
43 #ifndef MPI_SYNC
44 #define MPISYNC 0
45 #else
46 #define MPISYNC 1
47 #endif
48 
49 namespace Nektar
50 {
51 namespace LibUtilities
52 {
53 // Forward declarations
54 class CommMpi;
55 
56 /// Pointer to a Communicator object.
57 typedef std::shared_ptr<CommMpi> CommMpiSharedPtr;
58 
59 /// A global linear system.
60 class CommMpi : public Comm
61 {
62 public:
63  /// Creates an instance of this class
64  static CommSharedPtr create(int narg, char *arg[])
65  {
67  }
68 
69  /// Name of class
70  static std::string className;
71 
72  CommMpi(int narg, char *arg[]);
73  virtual ~CommMpi();
74 
75  MPI_Comm GetComm();
76 
77 protected:
78 
79  MPI_Comm m_comm;
80  int m_rank;
81 
82  CommMpi(MPI_Comm pComm);
83 
85  {};
86 
87  virtual void v_Finalise();
88  virtual int v_GetRank();
89  virtual void v_Block();
90  virtual double v_Wtime();
91  virtual bool v_TreatAsRankZero(void);
92  virtual bool v_IsSerial(void);
93  virtual void v_Send(void *buf, int count, CommDataType dt, int dest);
94  virtual void v_Recv(void *buf, int count, CommDataType dt, int source);
95  virtual void v_SendRecv(void *sendbuf, int sendcount, CommDataType sendtype,
96  int dest, void *recvbuf, int recvcount,
97  CommDataType recvtype, int source);
98  virtual void v_SendRecvReplace(void *buf, int count, CommDataType dt,
99  int pSendProc, int pRecvProc);
100  virtual void v_AllReduce(void *buf, int count, CommDataType dt,
101  enum ReduceOperator pOp);
102  virtual void v_AlltoAll(void *sendbuf, int sendcount, CommDataType sendtype,
103  void *recvbuf, int recvcount, CommDataType recvtype);
104  virtual void v_AlltoAllv(void *sendbuf, int sendcounts[], int sensdispls[],
105  CommDataType sendtype, void *recvbuf,
106  int recvcounts[], int rdispls[],
107  CommDataType recvtype);
108  virtual void v_AllGather(void *sendbuf, int sendcount, CommDataType sendtype,
109  void *recvbuf, int recvcount, CommDataType recvtype);
110  virtual void v_AllGatherv(void *sendbuf, int sendcount, CommDataType sendtype,
111  void *recvbuf, int recvcounts[], int rdispls[],
112  CommDataType recvtype);
113  virtual void v_AllGatherv(void *recvbuf, int recvcounts[], int rdispls[],
114  CommDataType recvtype);
115  virtual void v_Bcast(void *buffer, int count, CommDataType dt, int root);
116  virtual void v_Exscan(Array<OneD, unsigned long long> &pData,
117  const enum ReduceOperator pOp,
119 
120  virtual void v_Gather(void *sendbuf, int sendcount, CommDataType sendtype,
121  void *recvbuf, int recvcount, CommDataType recvtype,
122  int root);
123  virtual void v_Scatter(void *sendbuf, int sendcount, CommDataType sendtype,
124  void *recvbuf, int recvcount, CommDataType recvtype,
125  int root);
126 
127 
128  virtual void v_SplitComm(int pRows, int pColumns);
129  virtual CommSharedPtr v_CommCreateIf(int flag);
130 
131 };
132 }
133 }
134 
135 
136 #endif
virtual void v_SendRecvReplace(void *buf, int count, CommDataType dt, int pSendProc, int pRecvProc)
Definition: CommMpi.cpp:222
ReduceOperator
Type of operation to perform in AllReduce.
Definition: Comm.h:65
virtual void v_Recv(void *buf, int count, CommDataType dt, int source)
Definition: CommMpi.cpp:197
virtual void v_Send(void *buf, int count, CommDataType dt, int dest)
Definition: CommMpi.cpp:182
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:53
virtual void v_AllReduce(void *buf, int count, CommDataType dt, enum ReduceOperator pOp)
Definition: CommMpi.cpp:236
array buffer
Definition: GsLib.hpp:61
virtual void v_AllGather(void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype)
Definition: CommMpi.cpp:292
virtual void v_AlltoAllv(void *sendbuf, int sendcounts[], int sensdispls[], CommDataType sendtype, void *recvbuf, int recvcounts[], int rdispls[], CommDataType recvtype)
Definition: CommMpi.cpp:278
virtual bool v_IsSerial(void)
Definition: CommMpi.cpp:151
static CommSharedPtr create(int narg, char *arg[])
Creates an instance of this class.
Definition: CommMpi.h:64
virtual CommSharedPtr v_CommCreateIf(int flag)
Definition: CommMpi.cpp:405
virtual void v_SplitComm(int pRows, int pColumns)
Definition: CommMpi.cpp:378
virtual void v_AllGatherv(void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcounts[], int rdispls[], CommDataType recvtype)
Definition: CommMpi.cpp:301
virtual double v_Wtime()
Definition: CommMpi.cpp:174
virtual bool v_TreatAsRankZero(void)
Definition: CommMpi.cpp:135
virtual void v_Scatter(void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype, int root)
Definition: CommMpi.cpp:363
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
Base communications class.
Definition: Comm.h:81
A global linear system.
Definition: CommMpi.h:60
static std::string className
Name of class.
Definition: CommMpi.h:70
virtual void v_Exscan(Array< OneD, unsigned long long > &pData, const enum ReduceOperator pOp, Array< OneD, unsigned long long > &ans)
Definition: CommMpi.cpp:326
std::shared_ptr< CommMpi > CommMpiSharedPtr
Pointer to a Communicator object.
Definition: CommMpi.h:54
virtual void v_Bcast(void *buffer, int count, CommDataType dt, int root)
Definition: CommMpi.cpp:320
virtual void v_SendRecv(void *sendbuf, int sendcount, CommDataType sendtype, int dest, void *recvbuf, int recvcount, CommDataType recvtype, int source)
Definition: CommMpi.cpp:207
virtual void v_Gather(void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype, int root)
Definition: CommMpi.cpp:353
virtual void v_AlltoAll(void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype)
Definition: CommMpi.cpp:266