UPstream.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2018 OpenFOAM Foundation
9  Copyright (C) 2016-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "Pstream.H"
30 #include "PstreamReduceOps.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
35 {}
36 
37 
39 {
41  << "The dummy Pstream library cannot be used in parallel mode"
42  << endl;
43 
44  return false;
45 }
46 
47 
48 bool Foam::UPstream::init(int& argc, char**& argv, const bool needsThread)
49 {
51  << "The dummy Pstream library cannot be used in parallel mode"
52  << endl
54 
55  return false;
56 }
57 
58 
59 void Foam::UPstream::shutdown(int errNo)
60 {}
61 
62 
63 void Foam::UPstream::exit(int errNo)
64 {
65  // No MPI - just exit
66  std::exit(errNo);
67 }
68 
69 
71 {
72  // No MPI - just abort
73  std::abort();
74 }
75 
76 
77 void Foam::reduce(scalar&, const sumOp<scalar>&, const int, const label)
78 {}
79 
80 
81 void Foam::reduce(scalar&, const minOp<scalar>&, const int, const label)
82 {}
83 
84 
85 void Foam::reduce(vector2D&, const sumOp<vector2D>&, const int, const label)
86 {}
87 
88 
89 void Foam::sumReduce
90 (
91  scalar&,
92  label&,
93  const int,
94  const label
95 )
96 {}
97 
98 
99 void Foam::reduce(scalar&, const sumOp<scalar>&, const int, const label, label&)
100 {}
101 
102 
103 void Foam::reduce
104 (
105  scalar[],
106  const int,
107  const sumOp<scalar>&,
108  const int,
109  const label,
110  label&
111 )
112 {}
113 
114 
115 #if defined(WM_SPDP)
116 void Foam::reduce
117 (
118  solveScalar& Value,
119  const sumOp<solveScalar>& bop,
120  const int tag,
121  const label comm
122 )
123 {}
124 void Foam::reduce
125 (
126  solveScalar& Value,
127  const minOp<solveScalar>& bop,
128  const int tag,
129  const label comm
130 )
131 {}
132 void Foam::reduce
133 (
134  Vector2D<solveScalar>& Value,
135  const sumOp<Vector2D<solveScalar>>& bop,
136  const int tag,
137  const label comm
138 )
139 {}
140 void Foam::sumReduce
141 (
142  solveScalar& Value,
143  label& Count,
144  const int tag,
145  const label comm
146 )
147 {}
148 void Foam::reduce
149 (
150  solveScalar& Value,
151  const sumOp<solveScalar>& bop,
152  const int tag,
153  const label comm,
154  label& request
155 )
156 {}
157 void Foam::reduce
158 (
159  solveScalar[],
160  const int,
161  const sumOp<solveScalar>&,
162  const int,
163  const label,
164  label&
165 )
166 {}
167 #endif
168 
169 
170 
172 (
173  const labelUList& sendData,
174  labelUList& recvData,
175  const label communicator
176 )
177 {
178  recvData.deepCopy(sendData);
179 }
180 
181 
183 (
184  const char* sendData,
185  int sendSize,
186 
187  char* recvData,
188  int recvSize,
189  const label communicator
190 )
191 {
192  std::memmove(recvData, sendData, sendSize);
193 }
194 
195 
197 (
198  const char* sendData,
199  int sendSize,
200 
201  char* recvData,
202  int recvSize,
203  const label communicator
204 )
205 {
206  std::memmove(recvData, sendData, sendSize);
207 }
208 
209 
211 (
212  const char* sendData,
213  int sendSize,
214 
215  char* recvData,
216  const UList<int>& recvSizes,
217  const UList<int>& recvOffsets,
218  const label communicator
219 )
220 {
221  std::memmove(recvData, sendData, sendSize);
222 }
223 
224 
226 (
227  const char* sendData,
228  const UList<int>& sendSizes,
229  const UList<int>& sendOffsets,
230 
231  char* recvData,
232  int recvSize,
233  const label communicator
234 )
235 {
236  std::memmove(recvData, sendData, recvSize);
237 }
238 
239 
240 void Foam::UPstream::allocatePstreamCommunicator
241 (
242  const label,
243  const label
244 )
245 {}
246 
247 
248 void Foam::UPstream::freePstreamCommunicator(const label)
249 {}
250 
251 
253 {
254  return 0;
255 }
256 
257 
258 void Foam::UPstream::resetRequests(const label i)
259 {}
260 
261 
262 void Foam::UPstream::waitRequests(const label start)
263 {}
264 
265 
266 void Foam::UPstream::waitRequest(const label i)
267 {}
268 
269 
271 {
273  return false;
274 }
275 
276 
277 // ************************************************************************* //
Foam::UPstream::resetRequests
static void resetRequests(const label sz)
Truncate number of outstanding requests.
Definition: UPstream.C:258
Foam::UPstream::mpiGather
static void mpiGather(const char *sendData, int sendSize, char *recvData, int recvSize, const label communicator=worldComm)
Receive data from all processors on the master (low-level)
Definition: UPstream.C:183
Foam::minOp
Definition: ops.H:224
Foam::UPstream::waitRequests
static void waitRequests(const label start=0)
Wait until all requests (from start onwards) have finished.
Definition: UPstream.C:262
Foam::UPstream::abort
static void abort()
Call MPI_Abort with no other checks or cleanup.
Definition: UPstream.C:70
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::Vector2D< scalar >
Foam::UList::deepCopy
void deepCopy(const UList< T > &list)
Copy elements of the given UList. Sizes must match!
Definition: UList.C:107
Foam::sumOp
Definition: ops.H:213
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
Foam::reduce
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Definition: PstreamReduceOps.H:51
Foam::UPstream::waitRequest
static void waitRequest(const label i)
Wait until request i has finished.
Definition: UPstream.C:266
Foam::UPstream::mpiScatter
static void mpiScatter(const char *sendData, int sendSize, char *recvData, int recvSize, const label communicator=worldComm)
Send data to all processors from master (low-level)
Definition: UPstream.C:197
Foam::UPstream::addValidParOptions
static void addValidParOptions(HashTable< string > &validParOptions)
Definition: UPstream.C:34
Foam::FatalError
error FatalError
Pstream.H
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
PstreamReduceOps.H
Inter-processor communication reduction functions.
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::HashTable
A HashTable similar to std::unordered_map.
Definition: HashTable.H:105
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::UPstream::nRequests
static label nRequests()
Get number of outstanding requests.
Definition: UPstream.C:252
Foam::UPstream::scatter
static void scatter(const char *sendData, const UList< int > &sendSizes, const UList< int > &sendOffsets, char *recvData, int recvSize, const label communicator=worldComm)
Send data to all processors from the root of the communicator.
Definition: UPstream.C:226
Foam::UPstream::initNull
static bool initNull()
Special purpose initialisation function.
Definition: UPstream.C:38
Foam::UList< label >
Foam::UPstream::shutdown
static void shutdown(int errNo=0)
Shutdown (finalize) MPI as required.
Definition: UPstream.C:59
Foam::UPstream::finishedRequest
static bool finishedRequest(const label i)
Non-blocking comms: has request i finished?
Definition: UPstream.C:270
Foam::sumReduce
void sumReduce(T &Value, label &Count, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:133
Foam::UPstream::communicator
Helper class for allocating/freeing communicators.
Definition: UPstream.H:329
Foam::UPstream::init
static bool init(int &argc, char **&argv, const bool needsThread)
Initialisation function called from main.
Definition: UPstream.C:48
Foam::UPstream::allToAll
static void allToAll(const labelUList &sendData, labelUList &recvData, const label communicator=worldComm)
Exchange label with all processors (in the communicator).
Definition: UPstream.C:172
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:328
Foam::UPstream::gather
static void gather(const char *sendData, int sendSize, char *recvData, const UList< int > &recvSizes, const UList< int > &recvOffsets, const label communicator=worldComm)
Receive data from all processors on the master.
Definition: UPstream.C:211
Foam::UPstream::exit
static void exit(int errNo=1)
Shutdown (finalize) MPI as required and exit program with errNo.
Definition: UPstream.C:63