40#ifndef Foam_UPstream_H
41#define Foam_UPstream_H
119 const label myProcID,
198 static bool haveThreads_;
244 static void collectReceives
252 static void allocatePstreamCommunicator
254 const label parentIndex,
259 static void freePstreamCommunicator
316 const bool doPstream =
true
322 const label communicator,
323 const bool doPstream =
true
369 static label
procNo(
const label comm,
const int baseProcID);
376 const label currentComm,
377 const int currentProcID
386 static bool init(
int& argc,
char**& argv,
const bool needsThread);
418 static void freeTag(
const char*,
const int tag);
420 static void freeTag(
const std::string&,
const int tag);
425 static bool parRun(
const bool on)
noexcept
580 static void shutdown(
int errNo = 0);
586 static void exit(
int errNo = 1);
611 #undef Pstream_CommonRoutines
612 #define Pstream_CommonRoutines(Native) \
615 static void mpiGather \
617 const Native* sendData, \
621 const label communicator = worldComm \
625 static void mpiScatter \
627 const Native* sendData, \
631 const label communicator = worldComm \
637 #undef Pstream_CommonRoutines
638 #define Pstream_CommonRoutines(Native) \
643 const Native* sendData, \
646 const UList<int>& recvCounts, \
647 const UList<int>& recvOffsets, \
648 const label communicator = worldComm \
652 static void scatter \
654 const Native* sendData, \
655 const UList<int>& sendCounts, \
656 const UList<int>& sendOffsets, \
659 const label communicator = worldComm \
670 #undef Pstream_CommonRoutines
706 const std::streamsize bufSize,
730Ostream&
operator<<(Ostream&,
const UPstream::commsStruct&);
Various functions to operate on Lists.
#define Pstream_CommonRoutines(Native)
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
A HashTable similar to std::unordered_map.
An interval of (signed) integers defined by a start and a size.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void size(const label n)
Older name for setAddressableSize.
T & operator[](const label i)
Return element of UList.
Structure for communicating between processors.
bool operator!=(const commsStruct &) const
friend Ostream & operator<<(Ostream &, const commsStruct &)
const labelList & allBelow() const noexcept
bool operator==(const commsStruct &) const
commsStruct() noexcept
Default construct. Above == -1.
const labelList & below() const noexcept
The procIDs of all processors directly below.
label above() const noexcept
The procID of the processor directly above.
const labelList & allNotBelow() const noexcept
Helper class for allocating/freeing communicators.
communicator(const label parent, const labelList &subRanks, const bool doPstream)
Inter-processor communications stream.
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
static bool init(int &argc, char **&argv, const bool needsThread)
Initialisation function called from main.
commsTypes
Types of communications.
@ nonBlocking
"nonBlocking"
static label warnComm
Debugging: warn for use of any communicator differing from warnComm.
static void freeTag(const char *, const int tag)
static bool initNull()
Special purpose initialisation function.
static void freeCommunicators(const bool doPstream)
Free all communicators.
static void shutdown(int errNo=0)
Shutdown (finalize) MPI as required.
static const Enum< commsTypes > commsTypeNames
Names of the communication types.
static void freeCommunicator(const label communicator, const bool doPstream=true)
Free a previously allocated communicator.
static int allocateTag(const char *)
static int & msgType() noexcept
Message tag of standard messages.
static List< T > listGatherValues(const T &localValue, const label communicator=worldComm)
Gather individual values into list locations.
static bool floatTransfer
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)
UPstream(const commsTypes commsType)
Construct for given communication type.
static const int mpiBufferSize
MPI buffer-size (bytes)
static bool master(const label communicator=worldComm)
Am I the master process.
static const labelList & worldIDs() noexcept
worldID (index in allWorlds) of all processes
static void exit(int errNo=1)
Shutdown (finalize) MPI as required and exit program with errNo.
static List< int > & procID(label communicator)
Process ID of given process index.
static label nProcs(const label communicator=worldComm)
Number of processes in parallel run, and 1 for serial run.
commsTypes commsType() const noexcept
Get the communications type of the stream.
static constexpr int firstSlave() noexcept
Process index of first sub-process.
static label worldComm
Default communicator (all processors)
static label nRequests()
Get number of outstanding requests.
static const List< commsStruct > & treeCommunication(const label communicator=worldComm)
Communication schedule for tree all-to-master (proc 0)
static label parent(const label communicator)
IntRange< int > rangeType
Int ranges are used for MPI ranks (processes)
static bool haveThreads() noexcept
Have support for threads.
static label myWorldID()
My worldID.
static rangeType allProcs(const label communicator=worldComm)
Range of process indices for all processes.
static rangeType subProcs(const label communicator=worldComm)
Range of process indices for sub-processes.
static bool broadcast(char *buf, const std::streamsize bufSize, const label communicator=worldComm, const int rootProcNo=masterNo())
static int nProcsSimpleSum
Number of processors to change from linear to tree communication.
static int nPollProcInterfaces
Number of polling cycles in processor updates.
static const wordList & allWorlds() noexcept
All worlds.
static void addValidParOptions(HashTable< string > &validParOptions)
static void waitRequests(const label start=0)
Wait until all requests (from start onwards) have finished.
static label allocateCommunicator(const label parent, const labelList &subRanks, const bool doPstream=true)
Allocate a new communicator.
static void resetRequests(const label sz)
Truncate number of outstanding requests.
static void abort()
Call MPI_Abort with no other checks or cleanup.
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 const List< commsStruct > & whichCommunication(const label communicator=worldComm)
static int lastSlave(const label communicator=worldComm)
Process index of last sub-process.
static int maxCommsSize
Optional maximum message size (bytes)
static label procNo(const label comm, const int baseProcID)
static T listScatterValues(const UList< T > &allValues, const label communicator=worldComm)
Scatter individual values from list locations.
static commsTypes defaultCommsType
Default commsType.
static bool finishedRequest(const label i)
Non-blocking comms: has request i finished?
static void waitRequest(const label i)
Wait until request i has finished.
static bool & parRun() noexcept
Test if this a parallel run.
static const word & myWorld()
My world.
static int baseProcNo(const label myComm, const int procID)
A class for handling words, derived from Foam::string.
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
#define forAll(list, i)
Loop across all elements in list.
combineReduce operator for lists. Used for counting.
void operator()(T &x, const T &y) const