40 #ifndef Foam_UPstream_H 41 #define Foam_UPstream_H 119 const label myProcID,
201 static bool haveThreads_;
240 static void allocatePstreamCommunicator
242 const label parentIndex,
248 static void freePstreamCommunicator(
const label index);
293 static constexpr label
selfComm = 1;
326 const bool doPstream =
true 334 const bool doPstream =
true 370 const bool doPstream =
true 407 operator label() const
noexcept {
return comm_; }
417 static label
procNo(
const label comm,
const int baseProcID);
424 const label currentComm,
425 const int currentProcID
434 static bool init(
int& argc,
char**& argv,
const bool needsThread);
467 static
int allocateTag(const
char* const msg =
nullptr);
468 static
void freeTag(const
int tag, const
char* const msg =
nullptr);
525 static label
parent(
const label communicator)
584 return linearCommunication_[communicator];
593 return treeCommunication_[communicator];
606 ? linearCommunication_[communicator]
607 : treeCommunication_[communicator]
636 static void shutdown(
int errNo = 0);
642 static void exit(
int errNo = 1);
667 #undef Pstream_CommonRoutines 668 #define Pstream_CommonRoutines(Native) \ 671 static void mpiGather \ 673 const Native* sendData, \ 677 const label communicator = worldComm \ 681 static void mpiScatter \ 683 const Native* sendData, \ 687 const label communicator = worldComm \ 693 #undef Pstream_CommonRoutines 694 #define Pstream_CommonRoutines(Native) \ 699 const Native* sendData, \ 702 const UList<int>& recvCounts, \ 703 const UList<int>& recvOffsets, \ 704 const label communicator = worldComm \ 708 static void scatter \ 710 const Native* sendData, \ 711 const UList<int>& sendCounts, \ 712 const UList<int>& sendOffsets, \ 715 const label communicator = worldComm \ 726 #undef Pstream_CommonRoutines 762 const std::streamsize bufSize,
798 return nProcs(communicator) - 1;
803 Ostream&
operator<<(Ostream&,
const UPstream::commsStruct&);
static bool floatTransfer
Should compact transfer be used in which floats replace doubles reducing the bandwidth requirement at...
const labelList & below() const noexcept
The procIDs of all processors directly below.
static const word & myWorld()
My world.
commsStruct() noexcept
Default construct. Above == -1.
void size(const label n)
Older name for setAddressableSize.
combineReduce operator for lists. Used for counting.
"blocking" : (MPI_Bsend, MPI_Recv)
static const Enum< commsTypes > commsTypeNames
Enumerated names for the communication types.
static const labelList & worldIDs() noexcept
The indices into allWorlds for all processes.
~communicator()
Free allocated communicator and group.
label comm() const noexcept
The communicator label.
commsTypes
Types of communications.
static label nRequests() noexcept
Number of outstanding requests.
An interval of (signed) integers defined by a start and a size.
static rangeType allProcs(const label communicator=worldComm)
Range of process indices for all processes.
IntRange< int > rangeType
Int ranges are used for MPI ranks (processes)
static int maxCommsSize
Optional maximum message size (bytes)
static constexpr int firstSlave() noexcept
Process index of first sub-process.
static int nProcsSimpleSum
Number of processors to change from linear to tree communication.
communicator() noexcept
Default construct (a placeholder communicator)
static List< T > listGatherValues(const T &localValue, const label communicator=worldComm)
Gather individual values into list locations.
static bool initNull()
Special purpose initialisation function.
static bool & parRun() noexcept
Test if this a parallel run.
static bool finishedRequest(const label i)
Non-blocking comms: has request i finished?
static label procNo(const label comm, const int baseProcID)
Return processor number in communicator (given physical processor number) (= reverse of baseProcNo) ...
static void reduceOr(bool &value, const label communicator=worldComm)
Logical (or) reduction (cf. MPI AllReduce)
void clear()
Reset to default constructed state.
static const List< commsStruct > & whichCommunication(const label communicator=worldComm)
Communication schedule for linear/tree all-to-master (proc 0). Chooses based on the value of UPstream...
static int & msgType() noexcept
Message tag of standard messages.
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
static label worldComm
Default world communicator (all processors). May differ from globalComm if local worlds are in use...
label above() const noexcept
The procID of the processor directly above.
static label allocateCommunicator(const label parent, const labelUList &subRanks, const bool doPstream=true)
Allocate a new communicator with subRanks of parent communicator.
static const List< commsStruct > & treeCommunication(const label communicator=worldComm)
Communication schedule for tree all-to-master (proc 0)
static void shutdown(int errNo=0)
Shutdown (finalize) MPI as required.
UList< label > labelUList
A UList of labels.
ClassName("UPstream")
Declare name of the class and its debug switch.
void reset()
Free allocated communicator and group.
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
T & operator[](const label i)
Return element of UList.
static void freeCommunicators(const bool doPstream)
Free all communicators.
static int allocateTag(const char *const msg=nullptr)
static constexpr label globalComm
Communicator for all processors, irrespective of any local worlds.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator) is 1 for serial run.
static int nPollProcInterfaces
Number of polling cycles in processor updates.
static label parent(const label communicator)
The parent communicator.
static void exit(int errNo=1)
Shutdown (finalize) MPI as required and exit program with errNo.
static void reduceAnd(bool &value, const label communicator=worldComm)
Logical (and) reduction (cf. MPI AllReduce)
"scheduled" : (MPI_Send, MPI_Recv)
static bool init(int &argc, char **&argv, const bool needsThread)
Initialisation function called from main.
static constexpr int masterNo() noexcept
Process index of the master (always 0)
static const List< commsStruct > & linearCommunication(const label communicator=worldComm)
Communication schedule for linear all-to-master (proc 0)
static label warnComm
Debugging: warn for use of any communicator differing from warnComm.
Structure for communicating between processors.
const labelList & allBelow() const noexcept
The procIDs of all processors below (so not just directly below)
static bool isUserComm(label communicator) noexcept
True if communicator appears to be user-allocated.
commsTypes commsType() const noexcept
Get the communications type of the stream.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
bool operator==(const commsStruct &) const
static void allToAll(const UList< int32_t > &sendData, UList< int32_t > &recvData, const label communicator=worldComm)
Exchange integer data with all processors (in the communicator).
static void resetRequests(const label n)
Truncate outstanding requests to given length.
static bool is_subrank(const label communicator=worldComm)
Is this process a sub-rank on the communicator.
bool operator!=(const commsStruct &) const
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
static void waitRequests(const label start=0)
Wait until all requests (from start onwards) have finished.
bool good() const noexcept
True if communicator is non-negative (ie, was allocated)
Wrapper class for allocating/freeing communicators.
const labelList & allNotBelow() const noexcept
The procIDs of all processors that are above. The inverse set of allBelow without myProcNo...
static void abort()
Call MPI_Abort with no other checks or cleanup.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
static commsTypes defaultCommsType
Default commsType.
void operator()(T &x, const T &y) const
static int lastSlave(const label communicator=worldComm)
Process index of last sub-process.
static List< int > & procID(const label communicator)
Process IDs within a given communicator.
static label nComms() noexcept
Number of currently defined communicators.
UPstream(const commsTypes commsType)
Construct for given communication type.
const dimensionedScalar c
Speed of light in a vacuum.
static bool master(const label communicator=worldComm)
Am I the master rank.
"nonBlocking" : (MPI_Isend, MPI_Irecv)
void operator=(const communicator &)=delete
No copy assignment.
static void freeTag(const int tag, const char *const msg=nullptr)
static bool haveThreads() noexcept
Have support for threads.
static bool broadcast(char *buf, const std::streamsize bufSize, const label communicator=worldComm, const int rootProcNo=masterNo())
Broadcast buffer contents to all processes in communicator. The sizes must match on all processes...
friend Ostream & operator<<(Ostream &, const commsStruct &)
static rangeType subProcs(const label communicator=worldComm)
Range of process indices for sub-processes.
List< label > labelList
A List of labels.
static const int mpiBufferSize
MPI buffer-size (bytes)
static const wordList & allWorlds() noexcept
All worlds.
static T listScatterValues(const UList< T > &allValues, const label communicator=worldComm)
Scatter individual values from list locations.
#define Pstream_CommonRoutines(Native)
static void waitRequest(const label i)
Wait until request i has finished.
Inter-processor communications stream.
static constexpr label selfComm
A communicator within the current rank only.
static int baseProcNo(label comm, int procID)
Return physical processor number (i.e. processor number in worldComm) given communicator and processo...
static void addValidParOptions(HashTable< string > &validParOptions)
Add the valid option this type of communications library adds/requires on the command line...
static void freeCommunicator(const label communicator, const bool doPstream=true)
Free a previously allocated communicator.
static label myWorldID()
My worldID.