Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CommSerial.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File CommSerial.cpp
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: Serial (= no) communication implementation
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #ifdef NEKTAR_USING_PETSC
37 #include "petscsys.h"
38 #endif
39 
41 
42 namespace Nektar
43 {
44 namespace LibUtilities
45 {
47  "Serial", CommSerial::create, "Single-process serial communication.");
48 
49 CommSerial::CommSerial(int argc, char *argv[]) : Comm(argc, argv)
50 {
51 #ifdef NEKTAR_USING_PETSC
52  PetscInitializeNoArguments();
53 #endif
54  m_size = 1;
55  m_type = "Serial";
56 }
57 
59 {
60 }
61 
62 /**
63  *
64  */
66 {
67 #ifdef NEKTAR_USING_PETSC
68  PetscFinalize();
69 #endif
70 }
71 
72 /**
73  *
74  */
76 {
77  return 0;
78 }
79 
80 /**
81  *
82  */
84 {
85  return true;
86 }
87 
88 /**
89  *
90  */
92 {
93 }
94 
95 /**
96  *
97  */
99 {
100  return 0;
101 }
102 
103 /**
104  *
105  */
106 void CommSerial::v_Send(void *buf, int count, CommDataType dt, int dest)
107 {
108 }
109 
110 /**
111  *
112  */
113 void CommSerial::v_Recv(void *buf, int count, CommDataType dt, int source)
114 {
115 }
116 
117 /**
118  *
119  */
120 void CommSerial::v_SendRecv(void *sendbuf, int sendcount, CommDataType sendtype,
121  int dest, void *recvbuf, int recvcount,
122  CommDataType recvtype, int source)
123 {
124 }
125 
126 /**
127  *
128  */
129 void CommSerial::v_SendRecvReplace(void *buf, int count, CommDataType dt,
130  int pSendProc, int pRecvProc)
131 {
132 }
133 
134 /**
135  *
136  */
137 void CommSerial::v_AllReduce(void *buf, int count, CommDataType dt,
138  enum ReduceOperator pOp)
139 {
140 }
141 
142 /**
143  *
144  */
145 void CommSerial::v_AlltoAll(void *sendbuf, int sendcount, CommDataType sendtype,
146  void *recvbuf, int recvcount, CommDataType recvtype)
147 {
148 }
149 
150 /**
151  *
152  */
153 void CommSerial::v_AlltoAllv(void *sendbuf, int sendcounts[], int sensdispls[],
154  CommDataType sendtype, void *recvbuf,
155  int recvcounts[], int rdispls[],
156  CommDataType recvtype)
157 {
158 }
159 
160 void CommSerial::v_Bcast(void *buffer, int count, CommDataType dt, int root)
161 {
162 }
163 
165  const enum ReduceOperator pOp,
167 {
168 }
169 
170 void CommSerial::v_Gather(void *sendbuf, int sendcount, CommDataType sendtype,
171  void *recvbuf, int recvcount, CommDataType recvtype,
172  int root)
173 {
174  std::memcpy(recvbuf, sendbuf, sendcount * CommDataTypeGetSize(sendtype));
175 }
176 
177 void CommSerial::v_Scatter(void *sendbuf, int sendcount, CommDataType sendtype,
178  void *recvbuf, int recvcount, CommDataType recvtype,
179  int root)
180 {
181  std::memcpy(recvbuf, sendbuf, sendcount * CommDataTypeGetSize(sendtype));
182 }
183 /**
184  *
185  */
186 void CommSerial::v_SplitComm(int pRows, int pColumns)
187 {
188  ASSERTL0(false, "Cannot split a serial process.");
189 }
190 
191 /**
192  *
193  */
195 {
196  ASSERTL0(flag, "Serial process must always be split");
197  return shared_from_this();
198 }
199 }
200 }
virtual void v_SendRecvReplace(void *buf, int count, CommDataType dt, int pSendProc, int pRecvProc)
Definition: CommSerial.cpp:129
virtual void v_SplitComm(int pRows, int pColumns)
Definition: CommSerial.cpp:186
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
virtual void v_Exscan(Array< OneD, unsigned long long > &pData, const enum ReduceOperator pOp, Array< OneD, unsigned long long > &ans)
Definition: CommSerial.cpp:164
ReduceOperator
Type of operation to perform in AllReduce.
Definition: Comm.h:67
int CommDataTypeGetSize(CommDataType dt)
Return the size in bytes of a data type dt.
virtual NekDouble v_Wtime()
Definition: CommSerial.cpp:98
virtual bool v_TreatAsRankZero(void)
Definition: CommSerial.cpp:83
std::string m_type
Type of communication.
Definition: Comm.h:131
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: CommSerial.cpp:153
CommFactory & GetCommFactory()
Definition: Comm.cpp:61
virtual void v_Send(void *buf, int count, CommDataType dt, int dest)
Definition: CommSerial.cpp:106
virtual void v_AlltoAll(void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype)
Definition: CommSerial.cpp:145
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:55
static CommSharedPtr create(int narg, char *arg[])
Creates an instance of this class.
Definition: CommSerial.h:59
virtual void v_Gather(void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype, int root)
Definition: CommSerial.cpp:170
double NekDouble
virtual CommSharedPtr v_CommCreateIf(int flag)
Definition: CommSerial.cpp:194
virtual void v_Recv(void *buf, int count, CommDataType dt, int source)
Definition: CommSerial.cpp:113
virtual void v_Bcast(void *buffer, int count, CommDataType dt, int root)
Definition: CommSerial.cpp:160
Base communications class.
Definition: Comm.h:75
#define dest(otri, vertexptr)
CommSerial(int argc, char *argv[])
Definition: CommSerial.cpp:49
virtual void v_AllReduce(void *buf, int count, CommDataType dt, enum ReduceOperator pOp)
Definition: CommSerial.cpp:137
virtual void v_SendRecv(void *sendbuf, int sendcount, CommDataType sendtype, int dest, void *recvbuf, int recvcount, CommDataType recvtype, int source)
Definition: CommSerial.cpp:120
static std::string className
Name of class.
Definition: CommSerial.h:65
virtual void v_Scatter(void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype, int root)
Definition: CommSerial.cpp:177
int m_size
Number of processes.
Definition: Comm.h:130
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:215