UPstream.H
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-2017 OpenFOAM Foundation
9  Copyright (C) 2015-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 Class
28  Foam::UPstream
29 
30 Description
31  Inter-processor communications stream
32 
33 SourceFiles
34  UPstream.C
35  UPstreamCommsStruct.C
36  UPstreamTemplates.C
37  combineGatherScatter.C
38  gatherScatter.C
39  gatherScatterList.C
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef UPstream_H
44 #define UPstream_H
45 
46 #include "labelList.H"
47 #include "DynamicList.H"
48 #include "HashTable.H"
49 #include "string.H"
50 #include "Enum.H"
51 #include "ListOps.H"
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace Foam
56 {
57 
58 /*---------------------------------------------------------------------------*\
59  Class UPstream Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 class UPstream
63 {
64 public:
65 
66  //- Int ranges are used for MPI ranks (processes)
67  typedef IntRange<int> rangeType;
68 
69  //- Types of communications
70  enum class commsTypes : char
71  {
72  blocking,
73  scheduled,
75  };
76 
77  //- Names of the communication types
78  static const Enum<commsTypes> commsTypeNames;
79 
80 
81  // Public Classes
82 
83  //- Structure for communicating between processors
84  class commsStruct
85  {
86  // Private Data
87 
88  //- procID of above processor
89  label above_;
90 
91  //- procIDs of processors directly below me
92  labelList below_;
93 
94  //- procIDs of all processors below (so not just directly below)
95  labelList allBelow_;
96 
97  //- procIDs of all processors not below.
98  // (inverse set of allBelow_ and minus myProcNo)
99  labelList allNotBelow_;
100 
101 
102  public:
103 
104  // Constructors
105 
106  //- Default construct. Above == -1
107  commsStruct();
108 
109  //- Construct from components
111  (
112  const label above,
113  const labelList& below,
114  const labelList& allBelow,
115  const labelList& allNotBelow
116  );
117 
118  //- Construct from components; construct allNotBelow_
120  (
121  const label nProcs,
122  const label myProcID,
123  const label above,
124  const labelList& below,
125  const labelList& allBelow
126  );
127 
128 
129  // Member Functions
130 
131  label above() const noexcept
132  {
133  return above_;
134  }
135 
136  const labelList& below() const noexcept
137  {
138  return below_;
139  }
140 
141  const labelList& allBelow() const noexcept
142  {
143  return allBelow_;
144  }
145 
146  const labelList& allNotBelow() const noexcept
147  {
148  return allNotBelow_;
149  }
150 
151 
152  // Member Operators
153 
154  bool operator==(const commsStruct&) const;
155  bool operator!=(const commsStruct&) const;
156 
157 
158  // Ostream Operator
159 
160  friend Ostream& operator<<(Ostream&, const commsStruct&);
161  };
162 
163 
164  //- combineReduce operator for lists. Used for counting.
165  struct listEq
166  {
167  template<class T>
168  void operator()(T& x, const T& y) const
169  {
170  forAll(y, i)
171  {
172  if (y[i].size())
173  {
174  x[i] = y[i];
175  }
176  }
177  }
178  };
179 
180 
181 private:
182 
183  // Private Static Data
184 
185  //- By default this is not a parallel run
186  static bool parRun_;
187 
188  //- Have support for threads?
189  static bool haveThreads_;
190 
191  //- Standard transfer message type
192  static int msgType_;
193 
194  //- Names of all worlds
195  static wordList allWorlds_;
196 
197  //- Per processor the name of the world
198  static labelList worldIDs_;
199 
200 
201  // Communicator specific data
202 
203  //- My processor number
204  static DynamicList<int> myProcNo_;
205 
206  //- List of process IDs
207  static DynamicList<List<int>> procIDs_;
208 
209  //- Parent communicator
210  static DynamicList<label> parentCommunicator_;
211 
212  //- Free communicators
213  static DynamicList<label> freeComms_;
214 
215  //- Linear communication schedule
216  static DynamicList<List<commsStruct>> linearCommunication_;
217 
218  //- Multi level communication schedule
219  static DynamicList<List<commsStruct>> treeCommunication_;
220 
221 
222  // Private Member Functions
223 
224  //- Set data for parallel running
225  static void setParRun(const label nProcs, const bool haveThreads);
226 
227  //- Calculate linear communication schedule
228  static List<commsStruct> calcLinearComm(const label nProcs);
229 
230  //- Calculate tree communication schedule
231  static List<commsStruct> calcTreeComm(const label nProcs);
232 
233  //- Helper function for tree communication schedule determination
234  // Collects all processorIDs below a processor
235  static void collectReceives
236  (
237  const label procID,
238  const List<DynamicList<label>>& receives,
239  DynamicList<label>& allReceives
240  );
241 
242  //- Allocate a communicator with index
243  static void allocatePstreamCommunicator
244  (
245  const label parentIndex,
246  const label index
247  );
248 
249  //- Free a communicator
250  static void freePstreamCommunicator
251  (
252  const label index
253  );
254 
255 
256 protected:
257 
258  // Protected Data
259 
260  //- Communications type of this stream
262 
263 
264 public:
265 
266  // Declare name of the class and its debug switch
267  ClassName("UPstream");
268 
269 
270  // Static Data
271 
272  //- Should compact transfer be used in which floats replace doubles
273  //- reducing the bandwidth requirement at the expense of some loss
274  //- in accuracy
275  static bool floatTransfer;
276 
277  //- Number of processors at which the sum algorithm changes from linear
278  //- to tree
279  static int nProcsSimpleSum;
280 
281  //- Default commsType
283 
284  //- Number of polling cycles in processor updates
285  static int nPollProcInterfaces;
286 
287  //- Optional maximum message size (bytes)
288  static int maxCommsSize;
289 
290  //- MPI buffer-size (bytes)
291  static const int mpiBufferSize;
292 
293  //- Default communicator (all processors)
294  static label worldComm;
295 
296  //- Debugging: warn for use of any communicator differing from warnComm
297  static label warnComm;
298 
299 
300  // Constructors
301 
302  //- Construct for given communication type
303  explicit UPstream(const commsTypes commsType)
304  :
306  {}
307 
308 
309  // Member Functions
310 
311  //- Allocate a new communicator
312  static label allocateCommunicator
313  (
314  const label parent,
315  const labelList& subRanks,
316  const bool doPstream = true
317  );
318 
319  //- Free a previously allocated communicator
320  static void freeCommunicator
321  (
322  const label communicator,
323  const bool doPstream = true
324  );
325 
326  //- Free all communicators
327  static void freeCommunicators(const bool doPstream);
328 
329  //- Helper class for allocating/freeing communicators
330  class communicator
331  {
332  label comm_;
333 
334  //- No copy construct
335  communicator(const communicator&) = delete;
336 
337  //- No copy assignment
338  void operator=(const communicator&) = delete;
339 
340  public:
341 
343  (
344  const label parent,
345  const labelList& subRanks,
346  const bool doPstream
347  )
348  :
349  comm_(allocateCommunicator(parent, subRanks, doPstream))
350  {}
351 
352  ~communicator()
353  {
354  freeCommunicator(comm_);
355  }
356 
357  operator label() const noexcept
358  {
359  return comm_;
360  }
361  };
362 
363  //- Return physical processor number (i.e. processor number in
364  //- worldComm) given communicator and procssor
365  static int baseProcNo(const label myComm, const int procID);
366 
367  //- Return processor number in communicator (given physical processor
368  //- number) (= reverse of baseProcNo)
369  static label procNo(const label comm, const int baseProcID);
370 
371  //- Return processor number in communicator (given processor number
372  //- and communicator)
373  static label procNo
374  (
375  const label myComm,
376  const label currentComm,
377  const int currentProcID
378  );
379 
380  //- Add the valid option this type of communications library
381  //- adds/requires on the command line
382  static void addValidParOptions(HashTable<string>& validParOptions);
383 
384  //- Initialisation function called from main
385  // Spawns sub-processes and initialises inter-communication
386  static bool init(int& argc, char**& argv, const bool needsThread);
387 
388  //- Special purpose initialisation function.
389  // Performs a basic MPI_Init without any other setup.
390  // Only used for applications that need MPI communication when
391  // OpenFOAM is running in a non-parallel mode.
392  // \note Behaves as a no-op if MPI has already been initialized.
393  // Fatal if MPI has already been finalized.
394  static bool initNull();
395 
396 
397  // Non-blocking comms
398 
399  //- Get number of outstanding requests
400  static label nRequests();
401 
402  //- Truncate number of outstanding requests
403  static void resetRequests(const label sz);
404 
405  //- Wait until all requests (from start onwards) have finished.
406  static void waitRequests(const label start = 0);
407 
408  //- Wait until request i has finished.
409  static void waitRequest(const label i);
410 
411  //- Non-blocking comms: has request i finished?
412  static bool finishedRequest(const label i);
413 
414  static int allocateTag(const char*);
415 
416  static int allocateTag(const word&);
417 
418  static void freeTag(const char*, const int tag);
419 
420  static void freeTag(const word&, const int tag);
421 
422 
423  //- Set as parallel run on/off.
424  // \return the previous value
425  static bool parRun(const bool on) noexcept
426  {
427  bool old(parRun_);
428  parRun_ = on;
429  return old;
430  }
431 
432  //- Test if this a parallel run
433  // Modify access is deprecated
434  static bool& parRun() noexcept
435  {
436  return parRun_;
437  }
438 
439  //- Have support for threads
440  static bool haveThreads() noexcept
441  {
442  return haveThreads_;
443  }
444 
445  //- Number of processes in parallel run, and 1 for serial run
446  static label nProcs(const label communicator = worldComm)
447  {
448  return procIDs_[communicator].size();
449  }
450 
451  //- Process index of the master (always 0)
452  static constexpr int masterNo() noexcept
453  {
454  return 0;
455  }
456 
457  //- Am I the master process
458  static bool master(const label communicator = worldComm)
459  {
460  return myProcNo_[communicator] == masterNo();
461  }
462 
463  //- Number of this process (starting from masterNo() = 0)
464  static int myProcNo(const label communicator = worldComm)
465  {
466  return myProcNo_[communicator];
467  }
468 
469  static label parent(const label communicator)
470  {
471  return parentCommunicator_(communicator);
472  }
473 
474  //- Process ID of given process index
475  static List<int>& procID(label communicator)
476  {
477  return procIDs_[communicator];
478  }
479 
480 
481  // Worlds
482 
483  //- All worlds
484  static const wordList& allWorlds() noexcept
485  {
486  return allWorlds_;
487  }
488 
489  //- worldID (index in allWorlds) of all processes
490  static const labelList& worldIDs() noexcept
491  {
492  return worldIDs_;
493  }
494 
495  //- My worldID
496  static label myWorldID()
497  {
498  return worldIDs_[myProcNo(0)];
499  }
500 
501  //- My world
502  static const word& myWorld()
503  {
504  return allWorlds()[myWorldID()];
505  }
506 
507 
508  //- Range of process indices for all processes
509  static rangeType allProcs(const label communicator = worldComm)
510  {
511  // Proc 0 -> nProcs (int value)
512  return rangeType(static_cast<int>(nProcs(communicator)));
513  }
514 
515  //- Range of process indices for sub-processes
516  static rangeType subProcs(const label communicator = worldComm)
517  {
518  // Proc 1 -> nProcs (int value)
519  return rangeType(1, static_cast<int>(nProcs(communicator)-1));
520  }
521 
522  //- Communication schedule for linear all-to-master (proc 0)
524  (
525  const label communicator = worldComm
526  )
527  {
528  return linearCommunication_[communicator];
529  }
530 
531  //- Communication schedule for tree all-to-master (proc 0)
533  (
534  const label communicator = worldComm
535  )
536  {
537  return treeCommunication_[communicator];
538  }
539 
540  //- Message tag of standard messages
541  static int& msgType() noexcept
542  {
543  return msgType_;
544  }
545 
546 
547  //- Get the communications type of the stream
548  commsTypes commsType() const noexcept
549  {
550  return commsType_;
551  }
552 
553  //- Set the communications type of the stream
554  commsTypes commsType(const commsTypes ct) noexcept
555  {
556  commsTypes old(commsType_);
557  commsType_ = ct;
558  return old;
559  }
560 
561 
562  //- Shutdown (finalize) MPI as required.
563  // Uses MPI_Abort instead of MPI_Finalize if errNo is non-zero
564  static void shutdown(int errNo = 0);
565 
566  //- Call MPI_Abort with no other checks or cleanup
567  static void abort();
568 
569  //- Shutdown (finalize) MPI as required and exit program with errNo.
570  static void exit(int errNo = 1);
571 
572  //- Exchange label with all processors (in the communicator).
573  // sendData[proci] is the label to send to proci.
574  // After return recvData contains the data from the other processors.
575  static void allToAll
576  (
577  const labelUList& sendData,
578  labelUList& recvData,
579  const label communicator = worldComm
580  );
581 
582  //- Exchange data with all processors (in the communicator)
583  // sendSizes, sendOffsets give (per processor) the slice of
584  // sendData to send, similarly recvSizes, recvOffsets give the slice
585  // of recvData to receive
586  static void allToAll
587  (
588  const char* sendData,
589  const UList<int>& sendSizes,
590  const UList<int>& sendOffsets,
591 
592  char* recvData,
593  const UList<int>& recvSizes,
594  const UList<int>& recvOffsets,
595 
596  const label communicator = worldComm
597  );
598 
599  //- Receive data from all processors on the master (low-level)
600  static void mpiGather
601  (
602  const char* sendData,
603  int sendSize,
604 
605  char* recvData,
606  int recvSize,
607  const label communicator = worldComm
608  );
609 
610  //- Send data to all processors from master (low-level)
611  static void mpiScatter
612  (
613  const char* sendData,
614  int sendSize,
615 
616  char* recvData,
617  int recvSize,
618  const label communicator = worldComm
619  );
620 
621  //- Receive data from all processors on the master
622  static void gather
623  (
624  const char* sendData,
625  int sendSize,
626 
627  char* recvData,
628  const UList<int>& recvSizes,
629  const UList<int>& recvOffsets,
630  const label communicator = worldComm
631  );
632 
633  //- Send data to all processors from the root of the communicator
634  static void scatter
635  (
636  const char* sendData,
637  const UList<int>& sendSizes,
638  const UList<int>& sendOffsets,
639 
640  char* recvData,
641  int recvSize,
642  const label communicator = worldComm
643  );
644 
645 
646  // Gather single, contiguous value(s)
647 
648  //- Individual values into list locations.
649  // On master list length == nProcs, otherwise zero length
650  template<class T>
652  (
653  const T& localValue,
654  const label communicator = worldComm
655  );
656 
657  //- Individual values into list locations.
658  // On master list length == nProcs, otherwise zero length
659  template<class T>
660  static T listScatterValues
661  (
662  const UList<T>& allValues,
663  const label communicator = worldComm
664  );
665 
666 
667  // Housekeeping
668 
669  //- Process index of first sub-process
670  // \deprecated(2020-09) use subProcs() method instead
671  static constexpr int firstSlave() noexcept
672  {
673  return 1;
674  }
675 
676  //- Process index of last sub-process
677  // \deprecated(2020-09) use subProcs() method instead
678  static int lastSlave(const label communicator = worldComm)
679  {
680  return nProcs(communicator) - 1;
681  }
682 };
683 
684 
685 Ostream& operator<<(Ostream&, const UPstream::commsStruct&);
686 
687 // Template specialisation for access of commsStruct
688 template<>
689 UPstream::commsStruct&
691 
692 template<>
693 const UPstream::commsStruct&
695 
696 
697 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
698 
699 } // End namespace Foam
700 
701 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
702 
703 #ifdef NoRepository
704  #include "UPstreamTemplates.C"
705 #endif
706 
707 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
708 
709 #endif
710 
711 // ************************************************************************* //
Foam::UPstream::allocateTag
static int allocateTag(const char *)
Definition: UPstream.C:1426
Foam::UPstream::warnComm
static label warnComm
Debugging: warn for use of any communicator differing from warnComm.
Definition: UPstream.H:296
Foam::UPstream::linearCommunication
static const List< commsStruct > & linearCommunication(const label communicator=worldComm)
Communication schedule for linear all-to-master (proc 0)
Definition: UPstream.H:523
UPstreamTemplates.C
Foam::UPstream::resetRequests
static void resetRequests(const label sz)
Truncate number of outstanding requests.
Definition: UPstream.C:258
Foam::UPstream::commsType
commsTypes commsType() const noexcept
Get the communications type of the stream.
Definition: UPstream.H:547
Foam::Enum< commsTypes >
Foam::UPstream::masterNo
static constexpr int masterNo() noexcept
Process index of the master (always 0)
Definition: UPstream.H:451
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
HashTable.H
Foam::UPstream::communicator::~communicator
~communicator()
Definition: UPstream.H:351
Foam::UPstream::commsStruct::commsStruct
commsStruct()
Default construct. Above == -1.
Definition: UPstreamCommsStruct.C:33
Foam::UPstream::baseProcNo
static int baseProcNo(const label myComm, const int procID)
Definition: UPstream.C:213
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::DynamicList< int >
Foam::IntRange
An interval of (signed) integers defined by a start and a size.
Definition: IntRange.H:63
Foam::UPstream::lastSlave
static int lastSlave(const label communicator=worldComm)
Process index of last sub-process.
Definition: UPstream.H:677
Foam::UPstream::listEq
combineReduce operator for lists. Used for counting.
Definition: UPstream.H:164
Foam::UPstream::commsStruct::operator<<
friend Ostream & operator<<(Ostream &, const commsStruct &)
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::master
static bool master(const label communicator=worldComm)
Am I the master process.
Definition: UPstream.H:457
string.H
Foam::UPstream::abort
static void abort()
Call MPI_Abort with no other checks or cleanup.
Definition: UPstream.C:70
Foam::UPstream::defaultCommsType
static commsTypes defaultCommsType
Default commsType.
Definition: UPstream.H:281
Foam::UPstream::commsType
commsTypes commsType(const commsTypes ct) noexcept
Set the communications type of the stream.
Definition: UPstream.H:553
Foam::UPstream::commsStruct::below
const labelList & below() const noexcept
Definition: UPstream.H:135
Foam::UPstream::UPstream
UPstream(const commsTypes commsType)
Construct for given communication type.
Definition: UPstream.H:302
Foam::UPstream::haveThreads
static bool haveThreads() noexcept
Have support for threads.
Definition: UPstream.H:439
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::UPstream::commsStruct::operator==
bool operator==(const commsStruct &) const
Definition: UPstreamCommsStruct.C:95
Foam::UPstream::allWorlds
static const wordList & allWorlds() noexcept
All worlds.
Definition: UPstream.H:483
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::UPstream::subProcs
static rangeType subProcs(const label communicator=worldComm)
Range of process indices for sub-processes.
Definition: UPstream.H:515
Foam::UPstream::mpiBufferSize
static const int mpiBufferSize
MPI buffer-size (bytes)
Definition: UPstream.H:290
Foam::UPstream::allocateCommunicator
static label allocateCommunicator(const label parent, const labelList &subRanks, const bool doPstream=true)
Allocate a new communicator.
Definition: UPstream.C:108
Foam::UPstream::myWorldID
static label myWorldID()
My worldID.
Definition: UPstream.H:495
Foam::UPstream
Inter-processor communications stream.
Definition: UPstream.H:61
labelList.H
Foam::UPstream::commsStruct::allNotBelow
const labelList & allNotBelow() const noexcept
Definition: UPstream.H:145
Foam::UPstream::listScatterValues
static T listScatterValues(const UList< T > &allValues, const label communicator=worldComm)
Individual values into list locations.
Definition: UPstreamTemplates.C:78
Foam::UPstream::floatTransfer
static bool floatTransfer
Definition: UPstream.H:274
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
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::UPstream::procID
static List< int > & procID(label communicator)
Process ID of given process index.
Definition: UPstream.H:474
Foam::UPstream::freeCommunicator
static void freeCommunicator(const label communicator, const bool doPstream=true)
Free a previously allocated communicator.
Definition: UPstream.C:174
Foam::UPstream::commsTypeNames
static const Enum< commsTypes > commsTypeNames
Names of the communication types.
Definition: UPstream.H:77
Foam::UPstream::worldIDs
static const labelList & worldIDs() noexcept
worldID (index in allWorlds) of all processes
Definition: UPstream.H:489
Foam::UPstream::myWorld
static const word & myWorld()
My world.
Definition: UPstream.H:501
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::UPstream::commsStruct
Structure for communicating between processors.
Definition: UPstream.H:83
Foam::UPstream::listGatherValues
static List< T > listGatherValues(const T &localValue, const label communicator=worldComm)
Individual values into list locations.
Foam::UPstream::nProcsSimpleSum
static int nProcsSimpleSum
Definition: UPstream.H:278
Foam::UPstream::firstSlave
static constexpr int firstSlave() noexcept
Process index of first sub-process.
Definition: UPstream.H:670
Foam::HashTable
A HashTable similar to std::unordered_map.
Definition: HashTable.H:105
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
Foam::UPstream::allProcs
static rangeType allProcs(const label communicator=worldComm)
Range of process indices for all processes.
Definition: UPstream.H:508
Foam::UPstream::commsTypes::nonBlocking
Foam::UPstream::msgType
static int & msgType() noexcept
Message tag of standard messages.
Definition: UPstream.H:540
Foam::UPstream::nRequests
static label nRequests()
Get number of outstanding requests.
Definition: UPstream.C:252
Foam::UPstream::myProcNo
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:463
Foam::UPstream::listEq::operator()
void operator()(T &x, const T &y) const
Definition: UPstream.H:167
Foam::UPstream::commsType_
commsTypes commsType_
Communications type of this stream.
Definition: UPstream.H:260
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::commsTypes::scheduled
Foam::UPstream::rangeType
IntRange< int > rangeType
Int ranges are used for MPI ranks (processes)
Definition: UPstream.H:66
Foam::UPstream::initNull
static bool initNull()
Special purpose initialisation function.
Definition: UPstream.C:38
Foam::UPstream::maxCommsSize
static int maxCommsSize
Optional maximum message size (bytes)
Definition: UPstream.H:287
Foam::UPstream::worldComm
static label worldComm
Default communicator (all processors)
Definition: UPstream.H:293
Foam::UPstream::parRun
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:433
Foam::List< label >
Foam::UList::operator[]
T & operator[](const label i)
Return element of UList.
Definition: UListI.H:299
Foam::UPstream::procNo
static label procNo(const label comm, const int baseProcID)
Definition: UPstream.C:229
Foam::UList< label >
Foam::UPstream::ClassName
ClassName("UPstream")
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
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::UPstream::freeCommunicators
static void freeCommunicators(const bool doPstream)
Free all communicators.
Definition: UPstream.C:201
Foam::UPstream::commsStruct::allBelow
const labelList & allBelow() const noexcept
Definition: UPstream.H:140
Foam::UPstream::commsStruct::above
label above() const noexcept
Definition: UPstream.H:130
DynamicList.H
ListOps.H
Various functions to operate on Lists.
Foam::UPstream::treeCommunication
static const List< commsStruct > & treeCommunication(const label communicator=worldComm)
Communication schedule for tree all-to-master (proc 0)
Definition: UPstream.H:532
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::UPstream::parent
static label parent(const label communicator)
Definition: UPstream.H:468
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
Foam::UPstream::commsStruct::operator!=
bool operator!=(const commsStruct &) const
Definition: UPstreamCommsStruct.C:107
Foam::UPstream::nProcs
static label nProcs(const label communicator=worldComm)
Number of processes in parallel run, and 1 for serial run.
Definition: UPstream.H:445
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::nPollProcInterfaces
static int nPollProcInterfaces
Number of polling cycles in processor updates.
Definition: UPstream.H:284
y
scalar y
Definition: LISASMDCalcMethod1.H:14
Foam::UPstream::commsTypes::blocking
Enum.H
Foam::UPstream::exit
static void exit(int errNo=1)
Shutdown (finalize) MPI as required and exit program with errNo.
Definition: UPstream.C:63
Foam::UPstream::freeTag
static void freeTag(const char *, const int tag)
Definition: UPstream.C:1484