Skip to content
Snippets Groups Projects
Commit 05322608 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

ENH: Pstream waitRequest ignore placeholder (negative) requests

parent 4b94ac97
No related branches found
No related tags found
No related merge requests found
...@@ -456,10 +456,12 @@ public: ...@@ -456,10 +456,12 @@ public:
//- Wait until request i has finished. //- Wait until request i has finished.
// A no-op if parRun() == false // A no-op if parRun() == false
// or for placeholder (negative) request indices
static void waitRequest(const label i); static void waitRequest(const label i);
//- Non-blocking comms: has request i finished? //- Non-blocking comms: has request i finished?
// A no-op and returns true if parRun() == false // A no-op and returns true if parRun() == false
// or for placeholder (negative) request indices
static bool finishedRequest(const label i); static bool finishedRequest(const label i);
static int allocateTag(const char* const msg = nullptr); static int allocateTag(const char* const msg = nullptr);
......
...@@ -453,7 +453,7 @@ void Foam::UPstream::shutdown(int errNo) ...@@ -453,7 +453,7 @@ void Foam::UPstream::shutdown(int errNo)
// Clean mpi communicators // Clean mpi communicators
forAll(myProcNo_, communicator) forAll(myProcNo_, communicator)
{ {
if (myProcNo_[communicator] != -1) if (myProcNo_[communicator] >= 0)
{ {
freePstreamCommunicator(communicator); freePstreamCommunicator(communicator);
} }
...@@ -730,9 +730,9 @@ void Foam::UPstream::waitRequests(const label start) ...@@ -730,9 +730,9 @@ void Foam::UPstream::waitRequests(const label start)
void Foam::UPstream::waitRequest(const label i) void Foam::UPstream::waitRequest(const label i)
{ {
if (!UPstream::parRun()) if (!UPstream::parRun() || i < 0)
{ {
return; // No-op for non-parallel return; // No-op for non-parallel, or placeholder indices
} }
if (debug) if (debug)
...@@ -741,13 +741,13 @@ void Foam::UPstream::waitRequest(const label i) ...@@ -741,13 +741,13 @@ void Foam::UPstream::waitRequest(const label i)
<< endl; << endl;
} }
if (i < 0 || i >= PstreamGlobals::outstandingRequests_.size()) if (i >= PstreamGlobals::outstandingRequests_.size())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "There are " << PstreamGlobals::outstandingRequests_.size() << "You asked for request=" << i
<< " outstanding send requests and you are asking for i=" << i << " from " << PstreamGlobals::outstandingRequests_.size()
<< nl << " outstanding requests!" << nl
<< "Maybe you are mixing blocking/non-blocking comms?" << "Mixing use of blocking/non-blocking comms?"
<< Foam::abort(FatalError); << Foam::abort(FatalError);
} }
...@@ -781,9 +781,9 @@ void Foam::UPstream::waitRequest(const label i) ...@@ -781,9 +781,9 @@ void Foam::UPstream::waitRequest(const label i)
bool Foam::UPstream::finishedRequest(const label i) bool Foam::UPstream::finishedRequest(const label i)
{ {
if (!UPstream::parRun()) if (!UPstream::parRun() || i < 0)
{ {
return true; // No-op for non-parallel return true; // No-op for non-parallel, or placeholder indices
} }
if (debug) if (debug)
...@@ -792,13 +792,13 @@ bool Foam::UPstream::finishedRequest(const label i) ...@@ -792,13 +792,13 @@ bool Foam::UPstream::finishedRequest(const label i)
<< endl; << endl;
} }
if (i < 0 || i >= PstreamGlobals::outstandingRequests_.size()) if (i >= PstreamGlobals::outstandingRequests_.size())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "There are " << PstreamGlobals::outstandingRequests_.size() << "You asked for request=" << i
<< " outstanding send requests and you are asking for i=" << i << " from " << PstreamGlobals::outstandingRequests_.size()
<< nl << " outstanding requests!" << nl
<< "Maybe you are mixing blocking/non-blocking comms?" << "Mixing use of blocking/non-blocking comms?"
<< Foam::abort(FatalError); << Foam::abort(FatalError);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment