41#ifndef Foam_UPstream_H
42#define Foam_UPstream_H
338 static const commsStructList& null();
344 bool good() const
noexcept {
return (comm_ >= 0); }
347 int comm() const
noexcept {
return comm_; }
350 bool linear() const
noexcept {
return flat_; }
354 void linear(
bool on);
394 return tree_.writeList(
os);
407 return rhs.writeList(
os);
426 static bool haveThreads_;
429 static bool noInitialCommDup_;
437 static int constWorldComm_;
441 static int commInterNode_;
445 static int commLocalNode_;
448 static int numNodes_;
488 static label getAvailableCommIndex(
const label parentIndex);
492 static bool setHostCommunicators(
const int numPerNode = 0);
496 static bool setSharedMemoryCommunicators();
503 static void allocateCommunicatorComponents
505 const label parentIndex,
512 static void dupCommunicatorComponents
514 const label parentIndex,
525 static void splitCommunicatorComponents
527 const label parentIndex,
531 const bool two_step =
true
536 static void freeCommunicatorComponents(
const label index);
543 static bool sameProcs_impl(
int comm1,
int comm2)
550 (comm1 >= 0 && comm1 <= procIDs_.size())
551 && (comm2 >= 0 && comm2 <= procIDs_.size())
552 && (procIDs_[comm1] == procIDs_[comm2])
558 template<
typename IntType>
559 static bool sameProcs_impl
574 template<
typename Type1,
typename Type2>
575 static bool sameProcs_impl
602 std::streamsize count,
604 const int communicator,
620 const int communicator,
622 UPstream::Request* req =
nullptr
637 const int communicator,
639 UPstream::Request* req =
nullptr
654 const int communicator,
669 std::streamsize count,
673 const int communicator,
675 UPstream::Request* req =
nullptr,
692 std::streamsize count,
694 const int fromProcNo,
696 const int communicator,
698 UPstream::Request* req =
nullptr
709 const void* sendData,
716 const int communicator,
718 UPstream::Request* req =
nullptr
728 const void* sendData,
734 const int communicator,
736 UPstream::Request* req =
nullptr
748 const int communicator,
750 UPstream::Request* req =
nullptr
758 const void* sendData,
761 const UList<int>& recvCounts,
762 const UList<int>& recvOffsets,
764 const int communicator
771 const void* sendData,
772 const UList<int>& sendCounts,
773 const UList<int>& sendOffsets,
777 const int communicator
865 static label
commWorld(
const label communicator)
noexcept
868 if (communicator >= 0)
worldComm = communicator;
876 static label
commWarn(
const label communicator)
noexcept
887 static void printCommTree(
int communicator,
bool linear =
false);
895 return (parRun_ ? commInterNode_ : constWorldComm_);
901 return (parRun_ ? commLocalNode_ : constWorldComm_);
909 (commInterNode_ > constWorldComm_)
910 && (commLocalNode_ > constWorldComm_)
939 const labelRange& subRanks,
942 const bool withComponents =
true
955 const bool withComponents =
true
980 const bool two_step =
true
988 const bool withComponents =
true
997 static label
procNo(
const label comm,
const int baseProcID);
1004 const label currentComm,
1005 const int currentProcID
1014 static bool init(
int& argc,
char**& argv,
const bool needsThread);
1052 const int fromProcNo,
1071 const int fromProcNo,
1312 return procIDs_[communicator].
size();
1319 return myProcNo_[communicator];
1325 return myProcNo_[communicator] ==
masterNo();
1332 return myProcNo_[communicator] >=
masterNo();
1338 return myProcNo_[communicator] >
masterNo();
1349 parRun_ &&
is_rank(communicator) &&
nProcs(communicator) > 1
1357 static label
parent(
int communicator)
1359 return parentComm_(communicator);
1363 static List<int>&
procID(
int communicator)
1365 return procIDs_[communicator];
1371 static bool sameProcs(
int communicator1,
int communicator2)
1373 return sameProcs_impl(communicator1, communicator2);
1381 typename = std::void_t
1382 <std::enable_if_t<std::is_integral_v<T1>>>
1384 static bool sameProcs(
int communicator,
const UList<T1>& procs)
1386 return sameProcs_impl(communicator, procs);
1394 typename = std::void_t
1396 std::enable_if_t<std::is_integral_v<T1>>,
1397 std::enable_if_t<std::is_integral_v<T2>>
1400 static bool sameProcs(
const UList<T1>& procs1,
const UList<T2>& procs2)
1402 return sameProcs_impl(procs1, procs2);
1467 const int communicator,
1474 parRun_ &&
is_rank(communicator)
1498 static int msgType(
int val)
noexcept
1532 static void shutdown(
int errNo = 0);
1535 static void abort(
int errNo = 1);
1538 static void exit(
int errNo = 1);
1541 #undef Pstream_CommonRoutines
1542 #define Pstream_CommonRoutines(Type) \
1546 static void allToAll \
1549 const UList<Type>& sendData, \
1551 UList<Type>& recvData, \
1552 const int communicator = UPstream::worldComm \
1563 static void allToAllConsensus \
1566 const UList<Type>& sendData, \
1568 UList<Type>& recvData, \
1571 const int communicator = UPstream::worldComm \
1579 static void allToAllConsensus \
1582 const Map<Type>& sendData, \
1584 Map<Type>& recvData, \
1587 const int communicator = UPstream::worldComm \
1592 static Map<Type> allToAllConsensus \
1595 const Map<Type>& sendData, \
1598 const int communicator = UPstream::worldComm \
1601 Map<Type> recvData; \
1602 allToAllConsensus(sendData, recvData, tag, communicator); \
1609 #undef Pstream_CommonRoutines
1615 template<
class Type>
1619 const Type* sendData,
1629 template<
class Type>
1634 const Type* sendData,
1644 template<
class Type>
1655 template<
class Type>
1658 const Type* sendData,
1661 const UList<int>& recvCounts,
1662 const UList<int>& recvOffsets,
1667 template<
class Type>
1670 const Type* sendData,
1686 const T& localValue,
1698 const T& localValue,
1721 template<
class Type>
1725 std::streamsize count,
1734 template<
class Type,
unsigned N>
1758 template<UPstream::opCodes opCode,
class T>
1779 template<UPstream::opCodes opCode,
class T>
1801 template<UPstream::opCodes opCode,
class T>
1821 template<Foam::UPstream::opCodes opCode,
class T>
1828 const bool exclusive =
false
1836 template<Foam::UPstream::opCodes opCode,
class T>
1839 const T& localValue,
1842 const bool exclusive =
false
1845 #undef Pstream_ScanRoutines
1846 #define Pstream_ScanRoutines(OpName, OpCode) \
1851 static void mpiScan_##OpName \
1855 const int communicator, \
1857 const bool exclusive = false \
1860 UPstream::mpiScan<OpCode>(values, count, communicator, exclusive);\
1866 static void mpiExscan_##OpName \
1870 const int communicator \
1873 UPstream::mpiScan<OpCode>(values, count, communicator, true); \
1879 static T mpiScan_##OpName \
1882 const int communicator, \
1884 const bool exclusive = false \
1887 return UPstream::mpiScan<OpCode>(value, communicator, exclusive); \
1893 static T mpiExscan_##OpName \
1896 const int communicator \
1899 return UPstream::mpiScan<OpCode>(value, communicator, true); \
1905 #undef Pstream_ScanRoutines
1943 const
bool withComponents = true
1955 const
bool withComponents = true
1976 template<
class Type>
1983 const
UList<
int>& counts,
1984 const
UList<
int>& offsets,
1992 template<
class Type>
1997 const UList<
int>& counts,
1998 const UList<
int>& offsets,
2015class UPstream::communicator
2027 communicator(
const communicator&) =
delete;
2030 void operator=(
const communicator&) =
delete;
2036 communicator() noexcept : comm_(-1) {}
2039 communicator(communicator&& c) : comm_(
c.comm_) {
c.comm_ = -1; }
2045 const label parentComm,
2047 const labelRange& subRanks
2050 comm_(UPstream::newCommunicator(parentComm, subRanks))
2057 const label parentComm,
2084 static communicator
split
2087 const label parentComm,
2092 const bool two_step =
true
2104 bool good() const
noexcept {
return (comm_ >= 0); }
2107 label comm() const
noexcept {
return comm_; }
2110 communicator& constCast() const
noexcept
2112 return const_cast<communicator&
>(*this);
2117 label release() noexcept { label c(comm_); comm_ = -1;
return c; }
2130 void reset(label parent,
const labelUList& subRanks)
2137 void reset(communicator&& c)
2139 if (
this == &c)
return;
2146 void swap(communicator& c) { std::swap(comm_, c.comm_); }
2152 operator label() const
noexcept {
return comm_; }
2155 void operator=(communicator&& c) {
reset(std::move(c)); }
2158 bool operator==(
const communicator& c)
const noexcept
2160 return (comm_ == c.comm_);
2164 bool operator!=(
const communicator& c)
const noexcept
2166 return (comm_ != c.comm_);
2179class UPstream::Communicator
2186 typedef std::intptr_t value_type;
2218 return (value_ ==
rhs.value_);
2224 return (value_ !=
rhs.value_);
2236 value_(reinterpret_cast<value_type>(
p))
2240 explicit Communicator(value_type val)
noexcept
2270 value_type value() const
noexcept {
return value_; }
2273 const void* pointer() const
noexcept
2275 return reinterpret_cast<const void*
>(value_);
2307 typedef std::intptr_t value_type;
2339 return (value_ ==
rhs.value_);
2345 return (value_ !=
rhs.value_);
2355 explicit Request(const
void*
p) noexcept
2357 value_(reinterpret_cast<value_type>(
p))
2361 explicit Request(value_type val)
noexcept
2372 value_type value() const noexcept {
return value_; }
2375 const void* pointer() const noexcept
2377 return reinterpret_cast<const void*
>(value_);
2384 bool good() const noexcept;
2387 void reset() noexcept;
2391 bool active() const noexcept {
return good(); }
2395 bool finished() {
return UPstream::finishedRequest(*
this); }
2399 void wait() { UPstream::waitRequest(*
this); }
2416Ostream& operator<<(Ostream&,
const UPstream::commsStruct&);
2435 #include "UPstream.txx"
Various functions to operate on Lists.
Implementation of IO operators for Foam::OffsetRange.
A set of traits associated with UPstream communication.
#define Pstream_ScanRoutines(OpName, OpCode)
#define Pstream_CommonRoutines(Type)
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 1D vector of objects of type <T> with a fixed length <N>.
A HashTable similar to std::unordered_map.
An interval of (signed) integers defined by a start and a size.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void clear()
Clear the list, i.e. set size to zero.
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...
bool empty() const noexcept
True if List is empty (ie, size() is zero).
void size(const label n)
Older name for setAddressableSize.
An opaque wrapper for MPI_Comm with a vendor-independent representation without any <mpi....
Communicator(const Communicator &) noexcept=default
Copy construct.
const void * pointer() const noexcept
Return as pointer value.
value_type value() const noexcept
Return raw value.
std::intptr_t value_type
Storage for MPI_Comm (as integer or pointer).
bool operator!=(const Communicator &rhs) const noexcept
Test for inequality.
Communicator(Communicator &&) noexcept=default
Move construct.
Communicator(value_type val) noexcept
Construct from MPI_Comm (as integer type).
An opaque wrapper for MPI_File methods without any <mpi.h> header dependency.
An opaque wrapper for MPI_Request with a vendor-independent representation without any <mpi....
void cancel()
Same as calling UPstream::cancelRequest().
Request(const Request &) noexcept=default
Copy construct.
Request(Request &&) noexcept=default
Move construct.
const void * pointer() const noexcept
Return as pointer value.
bool operator!=(const Request &rhs) const noexcept
Test for inequality.
value_type value() const noexcept
Return raw value.
bool good() const noexcept
True if not equal to MPI_REQUEST_NULL.
bool active() const noexcept
True if request is active (!= MPI_REQUEST_NULL) Same as good(). Same as calling UPstream::activeReque...
std::intptr_t value_type
Storage for MPI_Request (as integer or pointer).
void wait()
Same as calling UPstream::waitRequest().
void free()
Same as calling UPstream::freeRequest().
bool finished()
Same as calling UPstream::finishedRequest().
Request(value_type val) noexcept
Construct from MPI_Request (as integer type).
An opaque wrapper for MPI_Win with a vendor-independent representation and without any <mpi....
Collection of communication structures.
const UPstream::commsStruct & get(int proci) const
Get existing or create (demand-driven) entry.
bool linear() const noexcept
Linear (flat) communication instead of tree communication.
bool empty() const noexcept
True if the list is empty.
commsStructList() noexcept
Construct empty with invalid communicator.
bool good() const noexcept
True if communicator is non-negative (ie, was assigned).
const UPstream::commsStruct & operator[](int proci) const
Get existing or create (demand-driven) entry.
static const commsStructList & null()
An empty structure. Used for placeholders etc.
int comm() const noexcept
The communicator internal index.
Ostream & writeList(Ostream &os) const
Write the communication tree.
commsStructList(int comm, bool flat=false) noexcept
Construct empty with given communicator.
label size() const noexcept
The number of entries.
void clear()
Clear the list.
void printGraph(Ostream &os, int proci=0) const
Print un-directed graph in graphviz dot format.
Structure for communicating between processors.
int nProcs() const noexcept
The number of processors addressed by the structure.
void reset_linear(const int myProci, const int numProcs)
Reset to linear (flat) communication.
const List< int > & below() const noexcept
The procIDs of the processors directly below.
commsStruct() noexcept
Default construct with above == -1.
const List< int > & allNotBelow() const noexcept
The procIDs of all processors not below myProcNo. The inverse set of allBelow without myProcNo.
void reset()
Reset to default constructed state.
int above() const noexcept
The procID of the processor directly above.
const List< int > & allBelow() const noexcept
The procIDs of all processors below (so not just directly below).
Wrapper for internally indexed communicator label. Always invokes UPstream::allocateCommunicatorCompo...
communicator(const label parentComm, const labelUList &subRanks)
Allocate communicator for sub-ranks on given parent.
communicator(communicator &&c)
Move construct, takes ownership.
void reset(communicator &&c)
Take ownership, free managed communicator.
static communicator split(const label parentComm, const int colour, const bool two_step=true)
Factory Method : Split the communicator on the given colour.
bool good() const noexcept
True if communicator is non-negative (ie, was allocated).
communicator(const label parentComm, const labelRange &subRanks)
Allocate communicator for contiguous sub-ranks on given parent.
void operator=(communicator &&c)
Move assignment, takes ownership.
label release() noexcept
Release ownership of the communicator, return old value.
void reset(label parent, const labelRange &subRanks)
Allocate with contiguous sub-ranks of parent communicator.
communicator & constCast() const noexcept
Return non-const reference to this.
bool operator!=(const communicator &c) const noexcept
Test for inequality.
void swap(communicator &c)
Swap communicator labels.
label comm() const noexcept
The communicator label.
~communicator()
Free allocated communicator.
communicator(const communicator &)=delete
No copy construct.
void reset()
Free allocated communicator.
bool operator==(const communicator &c) const noexcept
Test for equality.
static communicator duplicate(const label parentComm)
Duplicate the given communicator.
communicator() noexcept
Default construct (a placeholder communicator).
void operator=(const communicator &)=delete
No copy assignment.
void reset(label parent, const labelUList &subRanks)
Allocate with sub-ranks of parent communicator.
Inter-processor communications stream.
static void freeRequest(UPstream::Request &req)
Non-blocking comms: free outstanding request. Corresponds to MPI_Request_free().
static void mpiAllReduce(T values[], int count, const int communicator)
MPI_Allreduce (blocking) for known operators.
static label commWorld() noexcept
Communicator for all ranks (respecting any local worlds).
static constexpr int commSelf() noexcept
Communicator within the current rank only.
static bool broadcast(FixedList< Type, N > &list, const int communicator, const int root=UPstream::masterNo())
Broadcast fixed-list content (contiguous types) to all ranks (default: from rank=0)....
static std::pair< int, int64_t > probeMessage(const UPstream::commsTypes commsType, const int fromProcNo, const int tag=UPstream::msgType(), const int communicator=worldComm)
Probe for an incoming message.
static void mpi_reduce(void *values, int count, const UPstream::dataTypes dataTypeId, const UPstream::opCodes opCodeId, const int communicator, UPstream::Request *req=nullptr)
In-place reduction of values with result on rank 0.
ClassName("UPstream")
Declare name of the class and its debug switch.
static bool waitSomeRequests(label pos, label len=-1, DynamicList< int > *indices=nullptr)
Wait until some requests (from position onwards) have finished. Corresponds to MPI_Waitsome().
static int wait_done(const int fromProcNo, const int communicator, const int tag=UPstream::msgType()+1970)
Impose a point-to-point synchronisation barrier by receiving a zero-byte "done" message from given ra...
static void printCommTree(int communicator, bool linear=false)
Debugging: print the communication tree.
static void mpiAllReduce(T values[], int count, const UPstream::opCodes opCodeId, const int communicator, UPstream::Request &req)
MPI_Iallreduce (non-blocking) for known operators.
static void mpiGatherv(const Type *sendData, int sendCount, Type *recvData, const UList< int > &recvCounts, const UList< int > &recvOffsets, const int communicator=UPstream::worldComm)
Receive variable length data from all ranks.
static bool finishedRequests(label pos, label len=-1)
Non-blocking comms: have all requests (from position onwards) finished? Corresponds to MPI_Testall().
static void mpiReduce(T values[], int count, const UPstream::opCodes opCodeId, const int communicator)
MPI_Reduce (blocking) for known operators.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
static void mpi_scatter(const void *sendData, void *recvData, int count, const UPstream::dataTypes dataTypeId, const int communicator, UPstream::Request *req=nullptr)
Send identically-sized (contiguous) data from rank 0 to all other ranks.
static void addRequest(UPstream::Request &req)
Transfer the (wrapped) MPI request to the internal global list and invalidate the parameter (ignores ...
static const commsStructList & whichCommunication(const int communicator, bool linear=false)
Communication schedule for all-to-master (proc 0) as linear/tree/none with switching based on UPstrea...
static List< int > & procID(int communicator)
The list of ranks within a given communicator.
static bool init(int &argc, char **&argv, const bool needsThread)
Initialisation function called from main.
static label nRequests() noexcept
Number of outstanding requests (on the internal list of requests).
static label parent(int communicator)
The parent communicator.
commsTypes
Communications types.
@ blocking
compatibility name for buffered
@ scheduled
"scheduled" (MPI standard) : (MPI_Send, MPI_Recv)
@ nonBlocking
"nonBlocking" (immediate) : (MPI_Isend, MPI_Irecv)
@ buffered
"buffered" : (MPI_Bsend, MPI_Recv)
static label commInterHost() noexcept
Communicator between nodes (respects any local worlds).
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
static label warnComm
Debugging: warn for use of any communicator differing from warnComm.
static void mpiReduce(T values[], int count, const int communicator)
MPI_Reduce (blocking) for known operators.
static bool initNull()
Special purpose initialisation function.
static void shutdown(int errNo=0)
Shutdown (finalize) MPI as required.
static const Enum< commsTypes > commsTypeNames
Enumerated names for the communication types.
static int & msgType() noexcept
Message tag of standard messages.
static bool floatTransfer
Should compact transfer be used in which floats replace doubles reducing the bandwidth requirement at...
static void printTopoControl(Ostream &os)
Report the topology routines settings.
static bool mpi_broadcast(void *buf, std::streamsize count, const UPstream::dataTypes dataTypeId, const int communicator, const int root=0)
Broadcast buffer contents to all ranks (default: from rank=0). The sizes must match on all processes.
static void mpiScatterv(const Type *sendData, const UList< int > &sendCounts, const UList< int > &sendOffsets, Type *recvData, int recvCount, const int communicator=UPstream::worldComm)
Send variable length data to all ranks.
static constexpr int masterNo() noexcept
Relative rank for the master process - is always 0.
static int numNodes() noexcept
The number of shared/host nodes in the (const) world communicator.
static void mpi_allgather(void *allData, int count, const UPstream::dataTypes dataTypeId, const int communicator, UPstream::Request *req=nullptr)
Gather/scatter identically-sized data.
static void mpiGather(const Type *sendData, Type *recvData, int count, const int communicator=UPstream::worldComm)
Receive identically-sized (contiguous) data from all ranks.
static bool broadcast(Type *buffer, std::streamsize count, const int communicator, const int root=UPstream::masterNo())
Broadcast buffer contents (contiguous types) to all ranks (default: from rank=0). The sizes must matc...
static void cancelRequest(const label i)
Non-blocking comms: cancel and free outstanding request. Corresponds to MPI_Cancel() + MPI_Request_fr...
static void mpiScatter(const Type *sendData, Type *recvData, int count, const int communicator=UPstream::worldComm)
Send identically-sized (contiguous) data to all ranks.
static int topologyControl_
Selection of topology-aware routines as a bitmask combination of the topoControls enumerations.
static void send_done(const int toProcNo, const int communicator, const int tag=UPstream::msgType()+1970)
Impose a point-to-point synchronisation barrier by sending a zero-byte "done" message to given rank.
static std::streamsize mpi_receive(const UPstream::commsTypes commsType, void *buf, std::streamsize count, const UPstream::dataTypes dataTypeId, const int fromProcNo, const int tag, const int communicator, UPstream::Request *req=nullptr)
Receive buffer contents of specified data type from given processor.
static int nodeCommsMin_
Minimum number of nodes before topology-aware routines are enabled.
static label dupCommunicator(const label parent)
Duplicate the parent communicator.
static List< T > listGatherValues(const T &localValue, const int communicator=UPstream::worldComm)
Gather individual values into list locations.
static void barrier(const int communicator, UPstream::Request *req=nullptr)
Impose a synchronisation barrier (optionally non-blocking).
opCodes
Mapping of some MPI op codes.
@ op_bool_and
Logical and.
@ Extra_end
(internal use) end marker [window types]
@ op_no_op
No-op (window only).
@ op_bit_xor
Bit-wise xor for (unsigned) integral types.
@ Extra_begin
(internal use) begin marker [window types]
@ OpCodes_end
(internal use) end marker [all types]
@ op_replace
Replace (window only).
@ op_bit_or
Bit-wise or for (unsigned) integral types.
@ op_bool_xor
Logical xor.
@ op_bit_and
Bit-wise and for (unsigned) integral types.
static const int mpiBufferSize
MPI buffer-size (bytes).
static const rangeType & localNode_parentProcs()
The range (start/size) of the commLocalNode ranks in terms of the (const) world communicator processo...
static void reduceAnd(bool &value, const int communicator=worldComm)
Logical (and) reduction (MPI_AllReduce).
static bool usingTopoControl(UPstream::topoControls ctrl) noexcept
Test for selection of given topology-aware routine.
static int commLocalNode() noexcept
Communicator within the node/host (respects any local worlds).
static void gather(const Type *send, int count, Type *recv, const UList< int > &counts, const UList< int > &offsets, const int comm=UPstream::worldComm)
static void mpiAllReduce(T values[], int count, const UPstream::opCodes opCodeId, const int communicator)
MPI_Allreduce (blocking) for known operators.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static void reduceOr(bool &value, const int communicator=worldComm)
Logical (or) reduction (MPI_AllReduce).
static bool hasNodeCommunicators() noexcept
Both inter-node and local-node communicators have been created.
static void resetRequests(const label n)
Truncate outstanding requests to given length, which is expected to be in the range [0 to nRequests()...
static bool is_subrank(const label communicator=worldComm)
True if process corresponds to a sub-rank in the given communicator.
static const labelList & worldIDs() noexcept
The indices into allWorlds for all processes.
static int nProcsNonblockingExchange
Number of processors to change to nonBlocking consensual exchange (NBX). Ignored for zero or negative...
static label commWorld(const label communicator) noexcept
Set world communicator. Negative values are a no-op.
static void exit(int errNo=1)
Shutdown (finalize) MPI as required and exit program with errNo.
static const commsStructList & linearCommunication(int communicator)
Linear communication schedule (special case) for given communicator.
static bool sameProcs(const UList< T1 > &procs1, const UList< T2 > &procs2)
Test the equality of two lists of ranks.
sendModes
Different MPI-send modes (ignored for commsTypes::buffered).
@ sync
(MPI_Ssend, MPI_Issend)
@ normal
(MPI_Send, MPI_Isend)
static bool is_parallel(const label communicator=worldComm)
True if parallel algorithm or exchange is required.
static void freeRequests(UList< UPstream::Request > &requests)
Non-blocking comms: free outstanding requests. Corresponds to MPI_Request_free().
static int tuning_NBX_
Tuning parameters for non-blocking exchange (NBX).
commsTypes commsType(const commsTypes ct) noexcept
Set the communications type of the stream.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
commsTypes commsType() const noexcept
Get the communications type of the stream.
static label allocateCommunicator(const label parent, const labelRange &subRanks, const bool withComponents=true)
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
static void abort(int errNo=1)
Call MPI_Abort with no other checks or cleanup.
static label nComms() noexcept
Number of currently defined communicators.
static bool finishedRequestPair(label &req0, label &req1)
Non-blocking comms: have both requests finished? Corresponds to pair of MPI_Test().
IntRange< int > rangeType
Int ranges are used for MPI ranks (processes).
static bool haveThreads() noexcept
Have support for threads.
static label splitCommunicator(const label parent, const int colour, const bool two_step=true)
Allocate a new communicator by splitting the parent communicator on the given colour.
static label myWorldID()
My worldID.
static void cancelRequests(UList< UPstream::Request > &requests)
Non-blocking comms: cancel and free outstanding requests. Corresponds to MPI_Cancel() + MPI_Request_f...
static void mpi_scatterv(const void *sendData, const UList< int > &sendCounts, const UList< int > &sendOffsets, void *recvData, int recvCount, const UPstream::dataTypes dataTypeId, const int communicator)
Send variable length data from rank 0 to all ranks. (caution: known to scale poorly).
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 int find_last(bool condition, int communicator)
Locate the last rank for which the condition is true, or -1 if no ranks satisfy the condition.
static int nProcsSimpleSum
Number of processors to change from linear to tree communication.
static int commInterNode() noexcept
Communicator between nodes/hosts (respects any local worlds).
static bool usingNodeComms(const int communicator)
True if node topology-aware routines have been enabled, it is running in parallel,...
static int nPollProcInterfaces
Number of polling cycles in processor updates.
static bool is_rank(const label communicator=worldComm)
True if process corresponds to any rank (master or sub-rank) in the given communicator.
static void mpi_allreduce(void *values, int count, const UPstream::dataTypes dataTypeId, const UPstream::opCodes opCodeId, const int communicator, UPstream::Request *req=nullptr)
In-place reduction of values with same result on all ranks.
static int nodeCommsControl_
Use of host/node topology-aware routines.
static const commsStructList & treeCommunication(int communicator)
Tree communication schedule (standard case) for given communicator.
static bool sameProcs(int communicator1, int communicator2)
Test for communicator equality.
static void mpiScan(T values[], int count, const int communicator, const bool exclusive=false)
Inclusive/exclusive scan (in-place).
static void mpi_scan_reduce(void *values, int count, const UPstream::dataTypes dataTypeId, const UPstream::opCodes opCodeId, const int communicator, const bool exclusive)
In-place scan/exscan reduction of values.
static void mpi_gather(const void *sendData, void *recvData, int count, const UPstream::dataTypes dataTypeId, const int communicator, UPstream::Request *req=nullptr)
Receive identically-sized (contiguous) data from all ranks, placing the result on rank 0.
static int commConstWorld() noexcept
Communicator for all ranks (respecting any local worlds).
static T listScatterValues(const UList< T > &allValues, const int communicator=UPstream::worldComm)
Scatter individual values from list locations.
static T mpiScan(const T &localValue, const int communicator, const bool exclusive=false)
Inclusive/exclusive scan returning the result. In exclusive mode, the degenerate value on rank=0 has ...
static void mpiAllGather(Type *allData, int count, const int communicator=UPstream::worldComm)
Gather/scatter identically-sized data.
static label commWarn(const label communicator) noexcept
Alter communicator debugging setting. Warns for use of any communicator differing from specified....
static const wordList & allWorlds() noexcept
All worlds.
static bool waitAnyRequest(label pos, label len=-1)
Wait until any request (from position onwards) has finished. Corresponds to MPI_Waitany().
static label commIntraHost() noexcept
Communicator within the node (respects any local worlds).
static int incrMsgType(int val=1) noexcept
Increment the message tag for standard messages.
static void addValidParOptions(HashTable< string > &validParOptions)
Add the valid option this type of communications library adds/requires on the command line.
static void removeRequests(label pos, label len=-1)
Non-blocking comms: cancel/free outstanding requests (from position onwards) and remove from internal...
static int find_first(bool condition, int communicator)
Locate the first rank for which the condition is true, or -1 if no ranks satisfy the condition.
static const List< int > & interNode_offsets()
Processor offsets corresponding to the inter-node communicator.
static constexpr int commGlobal() noexcept
Communicator for all ranks, irrespective of any local worlds.
static void waitRequestPair(label &req0, label &req1)
Non-blocking comms: wait for both requests to finish. Corresponds to pair of MPI_Wait().
static int msgType(int val) noexcept
Set the message tag for standard messages.
static void waitRequests()
Wait for all requests to finish.
static void waitRequests(label pos, label len=-1)
Wait until all requests (from position onwards) have finished. Corresponds to MPI_Waitall().
UPstream(const commsTypes commsType) noexcept
Construct for given communication type.
static List< T > allGatherValues(const T &localValue, const int communicator=UPstream::worldComm)
Allgather individual values into list locations.
static label newCommunicator(const label parent, const labelRange &subRanks, const bool withComponents=true)
Create new communicator with sub-ranks on the parent communicator.
static int maxCommsSize
Optional maximum message size (bytes).
static bool mpi_send(const UPstream::commsTypes commsType, const void *buf, std::streamsize count, const UPstream::dataTypes dataTypeId, const int toProcNo, const int tag, const int communicator, UPstream::Request *req=nullptr, const UPstream::sendModes sendMode=UPstream::sendModes::normal)
Send buffer contents of specified data type to given processor.
static label procNo(const label comm, const int baseProcID)
Return processor number in communicator (given physical processor number) (= reverse of baseProcNo).
static bool sameProcs(int communicator, const UList< T1 > &procs)
Test equality of communicator procs with the given list of ranks. Includes a guard for the communicat...
static int baseProcNo(label comm, int procID)
Return physical processor number (i.e. processor number in worldComm) given communicator and processo...
topoControls
Some bit masks corresponding to topology controls.
@ mapGather
mapGather (reduction) [manual algorithm]
@ gatherList
gatherList [manual algorithm]
static bool activeRequest(const label i)
Is request i active (!= MPI_REQUEST_NULL)?
static void printNodeCommsControl(Ostream &os)
Report the node-communication settings.
static void scatter(const Type *send, const UList< int > &counts, const UList< int > &offsets, Type *recv, int count, const int comm=UPstream::worldComm)
static void mpiAllReduce(T values[], int count, const int communicator, UPstream::Request &req)
MPI_Iallreduce (non-blocking) for known operators.
static void freeCommunicator(const label communicator, const bool withComponents=true)
Free a previously allocated communicator.
static commsTypes defaultCommsType
Default commsType.
dataTypes
Mapping of some fundamental and aggregate types to MPI data types.
@ Basic_end
(internal use) end marker [basic types]
@ type_3double
3*double (eg, doubleVector)
@ DataTypes_end
(internal use) end marker [all types]
@ type_9float
9*float (eg, floatTensor)
@ User_begin
(internal use) begin marker [user types]
@ type_6float
6*float (eg, floatSymmTensor, complex vector)
@ type_6double
6*double (eg, doubleSymmTensor, complex vector)
@ type_3float
3*float (eg, floatVector)
@ type_byte
byte, char, unsigned char, ...
@ User_end
(internal use) end marker [user types]
@ Basic_begin
(internal use) begin marker [basic/all types]
@ type_9double
9*double (eg, doubleTensor)
static void mpi_gatherv(const void *sendData, int sendCount, void *recvData, const UList< int > &recvCounts, const UList< int > &recvOffsets, const UPstream::dataTypes dataTypeId, const int communicator)
Receive variable length data from all ranks, placing the result on rank 0. (caution: known to scale p...
static bool finishedRequest(const label i)
Non-blocking comms: has request i finished? Corresponds to MPI_Test().
static void waitRequest(const label i)
Wait until request i has finished. Corresponds to MPI_Wait().
static bool & parRun() noexcept
Test if this a parallel run.
static const word & myWorld()
My world.
A range or interval of labels defined by a start and a size.
Central-differencing interpolation scheme class.
Lookup type of boundary radiation properties.
A class for handling words, derived from Foam::string.
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
limits reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL))
static bool split(const std::string &line, std::string &key, std::string &val)
OBJstream os(runTime.globalPath()/outputName)
bool equal(const UList< Type1 > &a, const UList< Type2 > &b)
Test for list equality with different but compatible data types. Eg, int32 and int64.
Implementation details for UPstream/Pstream/MPI etc.
Interface handling for UPstream/Pstream/MPI etc.
const dimensionedScalar c
Speed of light in a vacuum.
bool operator!=(const eddy &a, const eddy &b)
dimensionedScalar pos(const dimensionedScalar &ds)
List< word > wordList
List of word.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< label > labelList
A List of labels.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
UList< label > labelUList
A UList of labels.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
#define FOAM_DEPRECATED_FOR(since, replacement)