46 namespace PstreamDetail
63 template<
class Container,
class Type>
81 for (
auto& buf : recvBufs)
93 if (sendBufs.
size() > numProc)
96 <<
"Send buffers:" << sendBufs.
size() <<
" > numProc:" << numProc
99 if (recvBufs.size() < numProc)
102 <<
"Recv buffers:" << recvBufs.size() <<
" < numProc:" << numProc
109 recvBufs[myProci] = sendBufs[myProci];
110 if (myProci < recvSizes.
size())
112 recvSizes[myProci] = recvBufs[myProci].
size();
140 for (label proci = 0; proci < numProc; ++proci)
142 const auto& sendData = sendBufs[proci];
144 if (sendData.empty())
148 else if (proci != myProci)
152 sendRequests.emplace_back(),
154 sendData.cdata_bytes(),
155 sendData.size_bytes(),
176 for (
bool barrier_active =
false, done =
false; !done; )
178 std::pair<int, int64_t> probed =
187 if (probed.second > 0)
192 const label proci(probed.first);
193 const label
count(probed.second /
sizeof(Type));
195 auto& recvData = recvBufs[proci];
196 recvData.resize(
count);
198 if (proci < recvSizes.
size())
200 recvSizes[proci] =
count;
207 recvData.data_bytes(),
208 recvData.size_bytes(),
229 barrier_active =
true;
246 template<
class Container,
class Type>
279 const auto iter = sendBufs.
find(myProci);
282 const auto& sendData = iter.val();
284 if (!sendData.empty())
287 recvBufs(iter.key()) = sendData;
318 const label proci = iter.key();
319 const auto& sendData = iter.val();
321 if (sendData.empty() || proci < 0 || proci >= numProc)
325 else if (proci != myProci)
329 sendRequests.emplace_back(),
331 sendData.cdata_bytes(),
332 sendData.size_bytes(),
353 for (
bool barrier_active =
false, done =
false; !done; )
355 std::pair<int, int64_t> probed =
364 if (probed.second > 0)
369 const label proci(probed.first);
370 const label
count(probed.second /
sizeof(Type));
372 auto& recvData = recvBufs(proci);
373 recvData.resize(
count);
379 recvData.data_bytes(),
380 recvData.size_bytes(),
400 barrier_active =
true;
412 template<
class Container,
class Type>
427 <<
"Send buffers size:" << sendBufs.
size()
436 PstreamDetail::exchangeConsensus<Container, Type>
447 template<
class Container,
class Type>
459 PstreamDetail::exchangeConsensus<Container, Type>
469 template<
class Container,
class Type>
483 PstreamDetail::exchangeConsensus<Container, Type>
void size(const label n)
Older name for setAddressableSize.
Inter-processor communication reduction functions.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
static bool finishedRequest(const label i)
Non-blocking comms: has request i finished? Corresponds to MPI_Test()
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
static std::pair< int, int64_t > probeMessage(const UPstream::commsTypes commsType, const int fromProcNo, const int tag=UPstream::msgType(), const label communicator=worldComm)
Probe for an incoming message.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
void exchangeConsensus(const UList< Container > &sendBufs, UList< Container > &recvBufs, labelUList &recvSizes, const int tag, const label comm)
Exchange contiguous data using non-blocking consensus exchange (NBX) with optional tracking of the re...
static int tuning_NBX_
Tuning parameters for non-blocking exchange (NBX)
label size() const noexcept
The number of elements in table.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
"scheduled" (MPI standard) : (MPI_Send, MPI_Recv)
static bool is_rank(const label communicator=worldComm)
True if process corresponds to any rank (master or sub-rank) in the given communicator.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
An opaque wrapper for MPI_Request with a vendor-independent representation without any <mpi...
iterator find(const label &key)
Find and return an iterator set at the hashed entry.
#define forAllIters(container, iter)
Iterate across all elements in the container object.
static bool is_parallel(const label communicator=worldComm)
True if parallel algorithm or exchange is required.
errorManip< error > abort(error &err)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
A template class to specify that a data type can be considered as being contiguous in memory...
static bool write(const UPstream::commsTypes commsType, const int toProcNo, const char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm, UPstream::Request *req=nullptr, const UPstream::sendModes sendMode=UPstream::sendModes::normal)
Write buffer contents to given processor.
"nonBlocking" (immediate) : (MPI_Isend, MPI_Irecv)
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
static void exchangeConsensus(const UList< Container > &sendBufs, List< Container > &recvBufs, const int tag, const label comm, const bool wait=true)
Exchange contiguous data using non-blocking consensus (NBX) Sends sendData, receives into recvData...
forAllConstIters(mixture.phases(), phase)
static std::streamsize read(const UPstream::commsTypes commsType, const int fromProcNo, char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm, UPstream::Request *req=nullptr)
Read buffer contents from given processor.
A HashTable to objects of type <T> with a label key.
static void barrier(const label communicator, UPstream::Request *req=nullptr)
Impose a synchronisation barrier (optionally non-blocking)
static bool finishedRequests(const label pos, label len=-1)
Non-blocking comms: have all requests (from position onwards) finished? Corresponds to MPI_Testall() ...