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);
173 if (len >= 0 && len <
count)
182 for (
const label i :
range)
185 if (MPI_REQUEST_NULL != request)
187 MPI_Cancel(&request);
188 MPI_Request_free(&request);
207 if (MPI_REQUEST_NULL != request)
213 MPI_Request_free(&request);
215 req = UPstream::Request(MPI_REQUEST_NULL);
228 for (
auto& req : requests)
231 if (MPI_REQUEST_NULL != request)
237 MPI_Request_free(&request);
239 req = UPstream::Request(MPI_REQUEST_NULL);
262 if (len >= 0 && len <
count)
274 Pout<<
"UPstream::waitRequests : starting wait for " 286 <<
"MPI_Wait returned with error" 296 <<
"MPI_Waitall returned with error" 311 Pout<<
"UPstream::waitRequests : finished wait." <<
endl;
328 auto*
waitRequests =
reinterpret_cast<MPI_Request*
>(requests.data());
330 for (
auto& req : requests)
334 if (MPI_REQUEST_NULL != request)
353 <<
"MPI_Waitall returned with error" 360 requests = UPstream::Request(MPI_REQUEST_NULL);
381 if (len >= 0 && len <
count)
392 Pout<<
"UPstream::waitAnyRequest : starting wait for any of " 399 int index = MPI_UNDEFINED;
403 <<
"MPI_Waitany returned with error" 409 if (index == MPI_UNDEFINED)
423 DynamicList<int>* indices
434 if (indices) indices->clear();
442 if (len >= 0 && len <
count)
453 Pout<<
"UPstream:waitSomeRequest : starting wait for some of " 459 List<int> tmpIndices;
462 indices->resize_nocopy(
count);
466 tmpIndices.resize(
count);
480 (indices ? indices->data() : tmpIndices.data()),
486 <<
"MPI_Waitsome returned with error" 492 if (outcount == MPI_UNDEFINED || outcount < 1)
495 if (indices) indices->clear();
501 indices->resize(outcount);
510 UList<UPstream::Request>& requests,
511 DynamicList<int>* indices
517 if (indices) indices->clear();
525 auto*
waitRequests =
reinterpret_cast<MPI_Request*
>(requests.data());
527 for (
auto& req : requests)
534 List<int> tmpIndices;
537 indices->resize_nocopy(
count);
541 tmpIndices.resize(
count);
546 Pout<<
"UPstream:waitSomeRequest : starting wait for some of " 547 << requests.size() <<
" requests" <<
endl;
561 (indices ? indices->data() : tmpIndices.data()),
567 <<
"MPI_Waitsome returned with error" 573 if (outcount == MPI_UNDEFINED || outcount < 1)
576 if (indices) indices->clear();
579 requests = UPstream::Request(MPI_REQUEST_NULL);
585 indices->resize(outcount);
591 for (label i = requests.size()-1; i >= 0; --i)
613 auto*
waitRequests =
reinterpret_cast<MPI_Request*
>(requests.data());
618 for (
auto& req : requests)
627 int index = MPI_UNDEFINED;
631 <<
"MPI_Waitany returned with error" 637 if (index == MPI_UNDEFINED)
645 for (label i =
count-1; i >= 0; --i)
651 for (label i =
count; i < requests.size(); ++i)
653 requests[i] = UPstream::Request(MPI_REQUEST_NULL);
729 if (MPI_REQUEST_NULL == request)
736 Pout<<
"UPstream::waitRequest : starting wait for request:" 743 if (MPI_Wait(&request, MPI_STATUS_IGNORE))
746 <<
"MPI_Wait returned with error" 754 Pout<<
"UPstream::waitRequest : finished wait for request:" 771 if (MPI_REQUEST_NULL == request)
778 if (MPI_Wait(&request, MPI_STATUS_IGNORE))
781 <<
"MPI_Wait returned with error" 787 req = UPstream::Request(MPI_REQUEST_NULL);
806 Pout<<
"UPstream::finishedRequest : check request:" 813 if (MPI_REQUEST_NULL == request)
820 MPI_Test(&request, &flag, MPI_STATUS_IGNORE);
837 if (MPI_REQUEST_NULL == request)
843 MPI_Test(&request, &flag, MPI_STATUS_IGNORE);
848 req = UPstream::Request(MPI_REQUEST_NULL);
872 if (len >= 0 && len <
count)
881 Pout<<
"UPstream::finishedRequests : check " <<
count 882 <<
" requests starting at " <<
pos <<
endl;
923 auto*
waitRequests =
reinterpret_cast<MPI_Request*
>(requests.data());
925 for (
auto& req : requests)
929 if (MPI_REQUEST_NULL != request)
950 requests = UPstream::Request(MPI_REQUEST_NULL);
962 for (label i =
count-1; i >= 0; --i)
968 for (label i =
count; i < requests.size(); ++i)
970 requests[i] = UPstream::Request(MPI_REQUEST_NULL);
988 bool anyActive =
false;
1053 <<
"MPI_Testsome returned with error" 1059 if (outcount == MPI_UNDEFINED)
1081 for (
int i = 0; i < outcount; ++i)
1083 const int idx = indices[i];
1103 return (outcount > 0);
1161 <<
"MPI_Waitall returned with error"
DynamicList< MPI_Request > outstandingRequests_
Outstanding non-blocking operations.
static void removeRequests(const label pos, label len=-1)
Non-blocking comms: cancel/free outstanding requests (from position onwards) and remove from internal...
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 waitSomeRequests(const label pos, label len=-1, DynamicList< int > *indices=nullptr)
Wait until some requests (from position onwards) have finished. Corresponds to MPI_Waitsome() ...
static bool finishedRequests(const label pos, label len=-1)
Non-blocking comms: have all requests (from position onwards) finished? Corresponds to MPI_Testall() ...