37 UPstream::Request(MPI_REQUEST_NULL)
51 *
this = UPstream::Request(MPI_REQUEST_NULL);
87 req = UPstream::Request(MPI_REQUEST_NULL);
106 if (MPI_REQUEST_NULL != request)
108 MPI_Cancel(&request);
109 MPI_Request_free(&request);
125 if (MPI_REQUEST_NULL != request)
127 MPI_Cancel(&request);
128 MPI_Request_free(&request);
130 req = UPstream::Request(MPI_REQUEST_NULL);
143 for (
auto& req : requests)
146 if (MPI_REQUEST_NULL != request)
148 MPI_Cancel(&request);
149 MPI_Request_free(&request);
151 req = UPstream::Request(MPI_REQUEST_NULL);
166 if (MPI_REQUEST_NULL != request)
172 MPI_Request_free(&request);
174 req = UPstream::Request(MPI_REQUEST_NULL);
187 for (
auto& req : requests)
190 if (MPI_REQUEST_NULL != request)
196 MPI_Request_free(&request);
198 req = UPstream::Request(MPI_REQUEST_NULL);
221 if (len >= 0 && len <
count)
233 Pout<<
"UPstream::waitRequests : starting wait for " 245 <<
"MPI_Wait returned with error" 255 <<
"MPI_Waitall returned with error" 270 Pout<<
"UPstream::waitRequests : finished wait." <<
endl;
287 auto*
waitRequests =
reinterpret_cast<MPI_Request*
>(requests.data());
289 for (
auto& req : requests)
293 if (MPI_REQUEST_NULL != request)
312 <<
"MPI_Waitall returned with error" 319 requests = UPstream::Request(MPI_REQUEST_NULL);
340 if (len >= 0 && len <
count)
351 Pout<<
"UPstream::waitAnyRequest : starting wait for some of " 358 int index = MPI_UNDEFINED;
362 <<
"MPI_Waitany returned with error" 368 if (index == MPI_UNDEFINED)
381 DynamicList<int>* indices
414 Pout<<
"UPstream:waitSomeRequest : starting wait for any of " 420 List<int> tmpIndices;
424 indices->resize_nocopy(
count);
428 tmpIndices.resize(
count);
442 (indices ? indices->data() : tmpIndices.data()),
448 <<
"MPI_Waitsome returned with error" 454 if (outcount == MPI_UNDEFINED || outcount < 1)
466 indices->resize(outcount);
485 auto*
waitRequests =
reinterpret_cast<MPI_Request*
>(requests.data());
490 for (
auto& req : requests)
499 int index = MPI_UNDEFINED;
503 <<
"MPI_Waitany returned with error" 509 if (index == MPI_UNDEFINED)
517 for (label i =
count-1; i >= 0; --i)
523 for (label i =
count; i < requests.size(); ++i)
525 requests[i] = UPstream::Request(MPI_REQUEST_NULL);
601 if (MPI_REQUEST_NULL == request)
608 Pout<<
"UPstream::waitRequest : starting wait for request:" 615 if (MPI_Wait(&request, MPI_STATUS_IGNORE))
618 <<
"MPI_Wait returned with error" 626 Pout<<
"UPstream::waitRequest : finished wait for request:" 643 if (MPI_REQUEST_NULL == request)
650 if (MPI_Wait(&request, MPI_STATUS_IGNORE))
653 <<
"MPI_Wait returned with error" 659 req = UPstream::Request(MPI_REQUEST_NULL);
678 Pout<<
"UPstream::finishedRequest : check request:" 685 if (MPI_REQUEST_NULL == request)
692 MPI_Test(&request, &flag, MPI_STATUS_IGNORE);
709 if (MPI_REQUEST_NULL == request)
715 MPI_Test(&request, &flag, MPI_STATUS_IGNORE);
720 req = UPstream::Request(MPI_REQUEST_NULL);
744 if (len >= 0 && len <
count)
753 Pout<<
"UPstream::finishedRequests : check " <<
count 754 <<
" requests starting at " <<
pos <<
endl;
795 auto*
waitRequests =
reinterpret_cast<MPI_Request*
>(requests.data());
797 for (
auto& req : requests)
801 if (MPI_REQUEST_NULL != request)
822 requests = UPstream::Request(MPI_REQUEST_NULL);
834 for (label i =
count-1; i >= 0; --i)
840 for (label i =
count; i < requests.size(); ++i)
842 requests[i] = UPstream::Request(MPI_REQUEST_NULL);
860 bool anyActive =
false;
925 <<
"MPI_Testsome returned with error" 931 if (outcount == MPI_UNDEFINED)
953 for (
int i = 0; i < outcount; ++i)
955 const int idx = indices[i];
975 return (outcount > 0);
1033 <<
"MPI_Waitall returned with error" static bool waitSomeRequests(const label pos, DynamicList< int > *indices=nullptr)
Wait until some requests (from position onwards) have finished. Corresponds to MPI_Waitsome() ...
DynamicList< MPI_Request > outstandingRequests_
Outstanding non-blocking operations.
void reset() noexcept
Reset to default constructed value (MPI_REQUEST_NULL)
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.
Functions to wrap MPI_Bcast, MPI_Allreduce, MPI_Iallreduce etc.
static label nRequests() noexcept
Number of outstanding requests (on the internal list of requests)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
static void cancelRequest(const label i)
Non-blocking comms: cancel and free outstanding request. Corresponds to MPI_Cancel() + MPI_Request_fr...
static bool finishedRequest(const label i)
Non-blocking comms: has request i finished? Corresponds to MPI_Test()
static void freeRequest(UPstream::Request &req)
Non-blocking comms: free outstanding request. Corresponds to MPI_Request_free()
static void freeRequests(UList< UPstream::Request > &requests)
Non-blocking comms: free outstanding requests. Corresponds to MPI_Request_free()
static void addWaitTime()
Add time increment to wait time.
bool good() const noexcept
True if not equal to MPI_REQUEST_NULL.
static void waitRequests()
Wait for all requests to finish.
static bool finishedRequestPair(label &req0, label &req1)
Non-blocking comms: have both requests finished? Corresponds to pair of MPI_Test() ...
dimensionedScalar pos(const dimensionedScalar &ds)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
string trim(const std::string &s)
Return string trimmed of leading and trailing whitespace.
errorManip< error > abort(error &err)
static bool waitAnyRequest(const label pos, label len=-1)
Wait until any request (from position onwards) has finished. Corresponds to MPI_Waitany() ...
static void beginTiming()
Update timer prior to measurement.
static void resetRequests(const label n)
Truncate outstanding requests to given length, which is expected to be in the range [0 to nRequests()...
int debug
Static debugging option.
static void waitRequestPair(label &req0, label &req1)
Non-blocking comms: wait for both requests to finish. Corresponds to pair of MPI_Wait() ...
static void addRequest(UPstream::Request &req)
Transfer the (wrapped) MPI request to the internal global list.
Request() noexcept
Default construct as MPI_REQUEST_NULL.
static void cancelRequests(UList< UPstream::Request > &requests)
Non-blocking comms: cancel and free outstanding requests. Corresponds to MPI_Cancel() + MPI_Request_f...
static std::enable_if< std::is_pointer< Type >::value, Type >::type get(const UPstream::Request &req) noexcept
static void waitRequest(const label i)
Wait until request i has finished. Corresponds to MPI_Wait()
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
static bool finishedRequests(const label pos, label len=-1)
Non-blocking comms: have all requests (from position onwards) finished? Corresponds to MPI_Testall() ...