43 #ifndef Foam_Pstream_H 44 #define Foam_Pstream_H 114 template<
class Type,
unsigned N>
123 template<
class Type,
class... Args>
126 const int communicator,
135 template<
class ListType>
147 template<
class T,
class BinaryOp,
bool InplaceMode>
155 const int communicator
161 template<
class T,
class BinaryOp,
bool InplaceMode>
168 const int communicator
177 template<
class T,
class BinaryOp,
bool InplaceMode=false>
219 template<
class T,
class CombineOp>
232 template<
class T,
class CombineOp>
243 template<
class T,
class CombineOp>
261 template<
class T,
class BinaryOp,
bool InplaceMode>
264 const UPstream::commsStructList& comms,
269 const int communicator
275 template<
class T,
class BinaryOp,
bool InplaceMode>
290 template<
class T,
class BinaryOp,
bool InplaceMode=false>
301 template<
class T,
class CombineOp>
316 template<
class T,
class BinaryOp,
bool InplaceMode=false>
327 template<
class T,
class CombineOp>
338 template<
class T,
class CombineOp>
356 template<
class Container,
class BinaryOp,
bool InplaceMode>
363 const int communicator
369 template<
class Container,
class BinaryOp,
bool InplaceMode>
375 const int communicator
383 template<
class Container,
class BinaryOp,
bool InplaceMode=false>
394 template<
class Container,
class CombineOp>
410 template<
class Container,
class BinaryOp,
bool InplaceMode=false>
421 template<
class Container,
class CombineOp>
432 template<
class Container,
class CombineOp>
459 const int communicator
470 const int communicator
481 const int communicator
511 template<
class Container>
516 const Container& sendBufs,
523 template<
class Container>
527 const Container& sendBufs,
538 template<
class Container>
541 const Container& sendBufs,
558 template<
class Container>
571 template<
class Container,
class Type>
579 const bool wait =
true 587 template<
class Container,
class Type>
595 const bool wait =
true 602 template<
class Container,
class Type>
609 const bool wait =
true 616 template<
class Container,
class Type>
623 const bool wait =
true 637 template<
class Container,
class Type>
644 const bool wait =
true 659 template<
class Container,
class Type>
666 const bool wait =
true 676 template<
class Container,
class Type>
682 const bool wait =
true 728 template<
class Container>
745 static
void scatterList
774 #include "PstreamBroadcast.txx" 775 #include "PstreamGather.txx" 776 #include "PstreamGatherList.txx" 777 #include "PstreamExchange.txx" static bool gatherList_topo_algorithm(UList< T > &values, const int tag, const int communicator)
Gather data, keeping individual values separate.
static void listCombineAllGather(UList< T > &values, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Same as Pstream::listCombineReduce.
static void exchangeSizes(const labelUList &sendProcs, const labelUList &recvProcs, const Container &sendBufs, labelList &sizes, const int tag=UPstream::msgType(), const int comm=UPstream::worldComm)
Helper: exchange sizes of sendBufs for specified send/recv ranks.
static void exchangeConsensus(const UList< Container > &sendBufs, List< Container > &recvBufs, const int tag, const int comm, const bool wait=true)
Exchange contiguous data using non-blocking consensus (NBX) Sends sendData, receives into recvData...
static void scatter(T &value, const int tag=UPstream::msgType(), const int comm=UPstream::worldComm)
A 1D vector of objects of type <T> with a fixed length <N>.
commsTypes
Communications types.
static void broadcasts(const int communicator, Type &value, Args &&... values)
Broadcast multiple items to all communicator ranks. Does nothing in non-parallel. ...
static bool gather_topo_algorithm(T &value, BinaryOp bop, const int tag, const int communicator)
Implementation: gather (reduce) single element data onto UPstream::masterNo() using a topo algorithm...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
static void combineScatter(T &value, const int tag=UPstream::msgType(), const int comm=UPstream::worldComm)
static void mapGather(Container &values, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Gather (reduce) Map/HashTable containers, applying bop to combine entries from different processors...
FOAM_DEPRECATED_FOR(2025-03, "broadcast() or broadcastList()") static void scatterList(UList< T > &values
The inverse of gatherList, but when combined with gatherList it effectively acts like a partial broad...
static void combineAllGather(T &value, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Same as Pstream::combineReduce.
void setCapacity(const label len)
Alter the size of the underlying storage.
static int & msgType() noexcept
Message tag of standard messages.
static void gather_algorithm(const UPstream::commsStructList &comms, T &value, BinaryOp bop, const int tag, const int communicator)
Implementation: gather (reduce) single element data onto UPstream::masterNo()
static void broadcast(Type &value, const int communicator=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all communicator ranks. Does nothing in non-paral...
static T listScatterValues(const UList< T > &allValues, const int communicator=UPstream::worldComm, const int tag=UPstream::msgType())
Scatter individual values from list locations.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
static void scatterList_algorithm(const UPstream::commsStructList &comms, UList< T > &values, const int tag, const int communicator)
Implementation: inverse of gatherList_algorithm.
static void combineGather(T &value, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Forwards to Pstream::gather with an in-place cop.
static void gatherList(UList< T > &values, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Gather data, but keep individual values separate.
static void broadcastList(ListType &list, const int communicator=UPstream::worldComm)
Broadcast list content (contiguous or non-contiguous) to all communicator ranks. Does nothing in non-...
static void exchange(const UList< Container > &sendBufs, const labelUList &recvSizes, List< Container > &recvBufs, const int tag=UPstream::msgType(), const int comm=UPstream::worldComm, const bool wait=true)
Helper: exchange contiguous data. Sends sendBufs, receives into recvBufs using predetermined receive ...
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
static void listGather(UList< T > &values, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Gather (reduce) list elements, applying bop to each list element.
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...
Inter-processor communications stream.
static void mapCombineReduce(Container &values, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Forwards to Pstream::mapReduce with an in-place cop.
static bool mapGather_topo_algorithm(Container &values, BinaryOp bop, const int tag, const int communicator)
Implementation: gather (reduce) Map/HashTable containers onto UPstream::masterNo() using a topo algor...
static void listCombineScatter(List< T > &value, const int tag=UPstream::msgType(), const int comm=UPstream::worldComm)
static bool is_parallel(const label communicator=worldComm)
True if parallel algorithm or exchange is required.
static void mapCombineGather(Container &values, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Forwards to Pstream::mapGather with an in-place cop.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
commsTypes commsType() const noexcept
Get the communications type of the stream.
UPstream(const commsTypes commsType) noexcept
Construct for given communication type.
static void listGather_algorithm(const UPstream::commsStructList &comms, UList< T > &values, BinaryOp bop, const int tag, const int communicator)
Implementation: gather (reduce) list element data onto UPstream::masterNo()
Collection of communication structures.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Wrapper for internally indexed communicator label. Always invokes UPstream::allocateCommunicatorCompo...
ClassName("Pstream")
Declare name of the class and its debug switch.
static void allGatherList(UList< T > &values, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Gather data, but keep individual values separate. Uses MPI_Allgather or manual communication.
static void gatherList_algorithm(const UPstream::commsStructList &comms, UList< T > &values, const int tag, const int communicator)
Implementation: gather data, keeping individual values separate. Output is only valid (consistent) on...
static void mapCombineScatter(Container &values, const int tag=UPstream::msgType(), const int comm=UPstream::worldComm)
static void combineReduce(T &value, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) applying cop to inplace combine value from different processors...
static void listCombineReduce(UList< T > &values, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Forwards to Pstream::listReduce with an in-place cop.
static void mapReduce(Container &values, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) applying bop to combine map values from different processors...
static List< T > listGatherValues(const T &localValue, const int communicator=UPstream::worldComm, const int tag=UPstream::msgType())
Gather individual values into list locations.
DynamicList< char > transferBuf_
Allocated transfer buffer (can be used for send or receive)
static void gather(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Gather (reduce) data, applying bop to combine value from different processors. The basis for Foam::re...
static void listReduce(UList< T > &values, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce list elements (list must be equal size on all ranks), applying bop to each list element...
static void mapGather_algorithm(const UPstream::commsStructList &comms, Container &values, BinaryOp bop, const int tag, const int communicator)
Implementation: gather (reduce) Map/HashTable containers onto UPstream::masterNo() ...
Inter-processor communications stream.
static void listCombineGather(UList< T > &values, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Forwards to Pstream::listGather with an in-place cop.
static bool broadcast(Type *buffer, std::streamsize count, const int communicator)
Broadcast buffer contents (contiguous types), from rank=0 to all ranks. The sizes must match on all p...
Pstream(const UPstream::commsTypes commsType) noexcept
Construct for communication type with empty buffer.
static bool listGather_topo_algorithm(UList< T > &values, BinaryOp bop, const int tag, const int communicator)
Implementation: gather (reduce) list element data onto UPstream::masterNo() using a topo algorithm...
static void mapCombineAllGather(Container &values, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Same as Pstream::mapCombineReduce.
A HashTable to objects of type <T> with a label key.