37 UPstream::Request(MPI_REQUEST_NULL)
51 *
this = UPstream::Request(MPI_REQUEST_NULL);
107 req = UPstream::Request(MPI_REQUEST_NULL);
126 if (MPI_REQUEST_NULL != request)
128 MPI_Cancel(&request);
129 MPI_Request_free(&request);
145 if (MPI_REQUEST_NULL != request)
147 MPI_Cancel(&request);
148 MPI_Request_free(&request);
150 req = UPstream::Request(MPI_REQUEST_NULL);
163 for (
auto& req : requests)
166 if (MPI_REQUEST_NULL != request)
168 MPI_Cancel(&request);
169 MPI_Request_free(&request);
171 req = UPstream::Request(MPI_REQUEST_NULL);
193 if (len >= 0 && len <
count)
202 for (
const label i :
range)
205 if (MPI_REQUEST_NULL != request)
207 MPI_Cancel(&request);
208 MPI_Request_free(&request);
227 if (MPI_REQUEST_NULL != request)
233 MPI_Request_free(&request);
235 req = UPstream::Request(MPI_REQUEST_NULL);
248 for (
auto& req : requests)
251 if (MPI_REQUEST_NULL != request)
257 MPI_Request_free(&request);
259 req = UPstream::Request(MPI_REQUEST_NULL);
282 if (len >= 0 && len <
count)
294 Perr<<
"UPstream::waitRequests : starting wait for " 306 <<
"MPI_Wait returned with error" 316 <<
"MPI_Waitall returned with error" 331 Perr<<
"UPstream::waitRequests : finished wait." <<
endl;
348 auto*
waitRequests =
reinterpret_cast<MPI_Request*
>(requests.data());
350 for (
auto& req : requests)
354 if (MPI_REQUEST_NULL != request)
373 <<
"MPI_Waitall returned with error" 380 requests = UPstream::Request(MPI_REQUEST_NULL);
401 if (len >= 0 && len <
count)
412 Perr<<
"UPstream::waitAnyRequest : starting wait for any of " 419 int index = MPI_UNDEFINED;
423 <<
"MPI_Waitany returned with error" 429 if (index == MPI_UNDEFINED)
443 DynamicList<int>* indices
454 if (indices) indices->clear();
462 if (len >= 0 && len <
count)
473 Perr<<
"UPstream:waitSomeRequest : starting wait for some of " 479 List<int> tmpIndices;
482 indices->resize_nocopy(
count);
486 tmpIndices.resize(
count);
500 (indices ? indices->data() : tmpIndices.data()),
506 <<
"MPI_Waitsome returned with error" 512 if (outcount == MPI_UNDEFINED || outcount < 1)
515 if (indices) indices->clear();
521 indices->resize(outcount);
530 UList<UPstream::Request>& requests,
531 DynamicList<int>* indices
537 if (indices) indices->clear();
545 auto*
waitRequests =
reinterpret_cast<MPI_Request*
>(requests.data());
547 for (
auto& req : requests)
554 List<int> tmpIndices;
557 indices->resize_nocopy(
count);
561 tmpIndices.resize(
count);
566 Perr<<
"UPstream:waitSomeRequest : starting wait for some of " 567 << requests.size() <<
" requests" <<
endl;
581 (indices ? indices->data() : tmpIndices.data()),
587 <<
"MPI_Waitsome returned with error" 593 if (outcount == MPI_UNDEFINED || outcount < 1)
596 if (indices) indices->clear();
599 requests = UPstream::Request(MPI_REQUEST_NULL);
605 indices->resize(outcount);
611 for (label i = requests.size()-1; i >= 0; --i)
633 auto*
waitRequests =
reinterpret_cast<MPI_Request*
>(requests.data());
638 for (
auto& req : requests)
647 int index = MPI_UNDEFINED;
651 <<
"MPI_Waitany returned with error" 657 if (index == MPI_UNDEFINED)
665 for (label i =
count-1; i >= 0; --i)
671 for (label i =
count; i < requests.size(); ++i)
673 requests[i] = UPstream::Request(MPI_REQUEST_NULL);
749 if (MPI_REQUEST_NULL == request)
756 Perr<<
"UPstream::waitRequest : starting wait for request:" 763 if (MPI_Wait(&request, MPI_STATUS_IGNORE))
766 <<
"MPI_Wait returned with error" 774 Perr<<
"UPstream::waitRequest : finished wait for request:" 791 if (MPI_REQUEST_NULL == request)
798 if (MPI_Wait(&request, MPI_STATUS_IGNORE))
801 <<
"MPI_Wait returned with error" 807 req = UPstream::Request(MPI_REQUEST_NULL);
826 Perr<<
"UPstream::finishedRequest : check request:" 833 if (MPI_REQUEST_NULL == request)
840 MPI_Test(&request, &flag, MPI_STATUS_IGNORE);
857 if (MPI_REQUEST_NULL == request)
863 MPI_Test(&request, &flag, MPI_STATUS_IGNORE);
868 req = UPstream::Request(MPI_REQUEST_NULL);
892 if (len >= 0 && len <
count)
901 Perr<<
"UPstream::finishedRequests : check " <<
count 902 <<
" requests starting at " <<
pos <<
endl;
943 auto*
waitRequests =
reinterpret_cast<MPI_Request*
>(requests.data());
945 for (
auto& req : requests)
949 if (MPI_REQUEST_NULL != request)
970 requests = UPstream::Request(MPI_REQUEST_NULL);
982 for (label i =
count-1; i >= 0; --i)
988 for (label i =
count; i < requests.size(); ++i)
990 requests[i] = UPstream::Request(MPI_REQUEST_NULL);
1008 bool anyActive =
false;
1073 <<
"MPI_Testsome returned with error" 1079 if (outcount == MPI_UNDEFINED)
1101 for (
int i = 0; i < outcount; ++i)
1103 const int idx = indices[i];
1123 return (outcount > 0);
1181 <<
"MPI_Waitall returned with error" prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
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 to_mpi(const UPstream::Communicator &arg) noexcept
static void waitRequest(const label i)
Wait until request i has finished. Corresponds to MPI_Wait()
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() ...