Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: CommMpi header
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 #ifndef NEKTAR_LIB_UTILITIES_COMMMPI_H
36 #define NEKTAR_LIB_UTILITIES_COMMMPI_H
37 
38 #include <mpi.h>
39 #include <string>
40 
43 
44 #ifndef MPI_SYNC
45 #define MPISYNC 0
46 #else
47 #define MPISYNC 1
48 #endif
49 
50 namespace Nektar
51 {
52 namespace LibUtilities
53 {
54 // Forward declarations
55 class CommMpi;
56 
57 /// Pointer to a Communicator object.
58 typedef boost::shared_ptr<CommMpi> CommMpiSharedPtr;
59 
60 /// A global linear system.
61 class CommMpi : public Comm
62 {
63 public:
64  /// Creates an instance of this class
65  static CommSharedPtr create(int narg, char *arg[])
66  {
68  }
69 
70  /// Name of class
71  static std::string className;
72 
73  CommMpi(int narg, char *arg[]);
74  virtual ~CommMpi();
75 
76  MPI_Comm GetComm();
77 
78 protected:
79  virtual void v_Finalise();
80  virtual int v_GetRank();
81  virtual void v_Block();
82  virtual double v_Wtime();
83  virtual bool v_TreatAsRankZero(void);
84  virtual void v_Send(void *buf, int count, CommDataType dt, int dest);
85  virtual void v_Recv(void *buf, int count, CommDataType dt, int source);
86  virtual void v_SendRecv(void *sendbuf, int sendcount, CommDataType sendtype,
87  int dest, void *recvbuf, int recvcount,
88  CommDataType recvtype, int source);
89  virtual void v_SendRecvReplace(void *buf, int count, CommDataType dt,
90  int pSendProc, int pRecvProc);
91  virtual void v_AllReduce(void *buf, int count, CommDataType dt,
92  enum ReduceOperator pOp);
93  virtual void v_AlltoAll(void *sendbuf, int sendcount, CommDataType sendtype,
94  void *recvbuf, int recvcount,
95  CommDataType recvtype);
96  virtual void v_AlltoAllv(void *sendbuf, int sendcounts[], int sensdispls[],
97  CommDataType sendtype, void *recvbuf,
98  int recvcounts[], int rdispls[],
99  CommDataType recvtype);
100  virtual void v_Bcast(void *buffer, int count, CommDataType dt, int root);
101  virtual void v_Exscan(Array<OneD, unsigned long long> &pData,
102  const enum ReduceOperator pOp,
104 
105  virtual void v_Gather(void *sendbuf, int sendcount, CommDataType sendtype,
106  void *recvbuf, int recvcount, CommDataType recvtype,
107  int root);
108  virtual void v_Scatter(void *sendbuf, int sendcount, CommDataType sendtype,
109  void *recvbuf, int recvcount, CommDataType recvtype,
110  int root);
111 
112  virtual void v_SplitComm(int pRows, int pColumns);
113  virtual CommSharedPtr v_CommCreateIf(int flag);
114 
115 private:
116  MPI_Comm m_comm;
117  int m_rank;
118 
119  CommMpi(MPI_Comm pComm);
120 };
121 }
122 }
123 
124 #endif
virtual void v_SendRecvReplace(void *buf, int count, CommDataType dt, int pSendProc, int pRecvProc)
Definition: CommMpi.cpp:202
ReduceOperator
Type of operation to perform in AllReduce.
Definition: Comm.h:67
virtual void v_Recv(void *buf, int count, CommDataType dt, int source)
Definition: CommMpi.cpp:177
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
virtual void v_Send(void *buf, int count, CommDataType dt, int dest)
Definition: CommMpi.cpp:162
virtual void v_AllReduce(void *buf, int count, CommDataType dt, enum ReduceOperator pOp)
Definition: CommMpi.cpp:216
array buffer
Definition: GsLib.hpp:60
virtual void v_AlltoAllv(void *sendbuf, int sendcounts[], int sensdispls[], CommDataType sendtype, void *recvbuf, int recvcounts[], int rdispls[], CommDataType recvtype)
Definition: CommMpi.cpp:258
static CommSharedPtr create(int narg, char *arg[])
Creates an instance of this class.
Definition: CommMpi.h:65
virtual CommSharedPtr v_CommCreateIf(int flag)
Definition: CommMpi.cpp:354
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:55
virtual void v_SplitComm(int pRows, int pColumns)
Definition: CommMpi.cpp:327
CommMpi(int narg, char *arg[])
Definition: CommMpi.cpp:53
virtual double v_Wtime()
Definition: CommMpi.cpp:154
virtual bool v_TreatAsRankZero(void)
Definition: CommMpi.cpp:130
boost::shared_ptr< CommMpi > CommMpiSharedPtr
Pointer to a Communicator object.
Definition: CommMpi.h:55
virtual void v_Scatter(void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype, int root)
Definition: CommMpi.cpp:312
Base communications class.
Definition: Comm.h:75
A global linear system.
Definition: CommMpi.h:61
static std::string className
Name of class.
Definition: CommMpi.h:71
#define dest(otri, vertexptr)
virtual void v_Exscan(Array< OneD, unsigned long long > &pData, const enum ReduceOperator pOp, Array< OneD, unsigned long long > &ans)
Definition: CommMpi.cpp:275
virtual void v_Bcast(void *buffer, int count, CommDataType dt, int root)
Definition: CommMpi.cpp:269
virtual void v_SendRecv(void *sendbuf, int sendcount, CommDataType sendtype, int dest, void *recvbuf, int recvcount, CommDataType recvtype, int source)
Definition: CommMpi.cpp:187
virtual void v_Gather(void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype, int root)
Definition: CommMpi.cpp:302
virtual void v_AlltoAll(void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype)
Definition: CommMpi.cpp:246