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 // 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 <string>
39 #include <mpi.h>
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 bool v_TreatAsRankZero(void);
83  virtual void v_Send(int pProc, Array<OneD, NekDouble>& pData);
84  virtual void v_Send(int pProc, Array<OneD, int>& pData);
85  virtual void v_Send(int pProc, std::vector<unsigned int>& pData);
86  virtual void v_Recv(int pProc, Array<OneD, NekDouble>& pData);
87  virtual void v_Recv(int pProc, Array<OneD, int>& pData);
88  virtual void v_Recv(int pProc, std::vector<unsigned int>& pData);
89  virtual void v_SendRecv(int pSendProc,
90  Array<OneD, NekDouble>& pSendData,
91  int pRecvProc,
92  Array<OneD, NekDouble>& pRecvData);
93  virtual void v_SendRecv(int pSendProc,
94  Array<OneD, int>& pSendData,
95  int pRecvProc,
96  Array<OneD, int>& pRecvData);
97  virtual void v_SendRecvReplace(int pSendProc,
98  int pRecvProc,
99  Array<OneD, NekDouble>& pSendData);
100  virtual void v_SendRecvReplace(int pSendProc,
101  int pRecvProc,
102  Array<OneD, int>& pSendData);
103  virtual void v_AllReduce(NekDouble& pData,
104  enum ReduceOperator pOp);
105  virtual void v_AllReduce(int& pData,
106  enum ReduceOperator pOp);
107  virtual void v_AllReduce(Array<OneD, NekDouble>& pData,
108  enum ReduceOperator pOp);
109  virtual void v_AllReduce(Array<OneD, int >& pData,
110  enum ReduceOperator pOp);
111  virtual void v_AllReduce(std::vector<unsigned int>& pData,
112  enum ReduceOperator pOp);
113  virtual void v_AlltoAll(Array<OneD, NekDouble>& pSendData,
114  Array<OneD, NekDouble>& pRecvData);
115  virtual void v_AlltoAll(Array<OneD, int>& pSendData,
116  Array<OneD, int>& pRecvData);
117  virtual void v_AlltoAllv(Array<OneD, NekDouble>& pSendData,
118  Array<OneD, int>& pSendDataSizeMap,
119  Array<OneD, int>& pSendDataOffsetMap,
120  Array<OneD, NekDouble>& pRecvData,
121  Array<OneD, int>& pRecvDataSizeMap,
122  Array<OneD, int>& pRecvDataOffsetMap);
123  virtual void v_AlltoAllv(Array<OneD, int>& pSendData,
124  Array<OneD, int>& pSendDataSizeMap,
125  Array<OneD, int>& pSendDataOffsetMap,
126  Array<OneD, int>& pRecvData,
127  Array<OneD, int>& pRecvDataSizeMap,
128  Array<OneD, int>& pRecvDataOffsetMap);
129  virtual void v_SplitComm(int pRows, int pColumns);
130 
131  private:
132  MPI_Comm m_comm;
133  int m_rank;
134 
135  CommMpi(MPI_Comm pComm);
136  };
137  }
138 }
139 
140 #endif
ReduceOperator
Type of operation to perform in AllReduce.
Definition: Comm.h:65
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
virtual void v_SendRecv(int pSendProc, Array< OneD, NekDouble > &pSendData, int pRecvProc, Array< OneD, NekDouble > &pRecvData)
Definition: CommMpi.cpp:296
virtual void v_Recv(int pProc, Array< OneD, NekDouble > &pData)
Definition: CommMpi.cpp:187
virtual void v_SendRecvReplace(int pSendProc, int pRecvProc, Array< OneD, NekDouble > &pSendData)
Definition: CommMpi.cpp:349
static CommSharedPtr create(int narg, char *arg[])
Creates an instance of this class.
Definition: CommMpi.h:65
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:53
virtual void v_SplitComm(int pRows, int pColumns)
Definition: CommMpi.cpp:634
CommMpi(int narg, char *arg[])
Definition: CommMpi.cpp:56
virtual void v_AllReduce(NekDouble &pData, enum ReduceOperator pOp)
Definition: CommMpi.cpp:396
virtual bool v_TreatAsRankZero(void)
Definition: CommMpi.cpp:136
virtual void v_AlltoAll(Array< OneD, NekDouble > &pSendData, Array< OneD, NekDouble > &pRecvData)
Definition: CommMpi.cpp:546
boost::shared_ptr< CommMpi > CommMpiSharedPtr
Pointer to a Communicator object.
Definition: CommMpi.h:55
virtual void v_Send(int pProc, Array< OneD, NekDouble > &pData)
Definition: CommMpi.cpp:161
double NekDouble
Base communications class.
Definition: Comm.h:73
A global linear system.
Definition: CommMpi.h:61
static std::string className
Name of class.
Definition: CommMpi.h:71
virtual void v_AlltoAllv(Array< OneD, NekDouble > &pSendData, Array< OneD, int > &pSendDataSizeMap, Array< OneD, int > &pSendDataOffsetMap, Array< OneD, NekDouble > &pRecvData, Array< OneD, int > &pRecvDataSizeMap, Array< OneD, int > &pRecvDataOffsetMap)
Definition: CommMpi.cpp:582