diff --git a/applications/test/parallel-chunks/Test-parallel-chunks.C b/applications/test/parallel-chunks/Test-parallel-chunks.C index 8c4360cbd9..cbb372298f 100644 --- a/applications/test/parallel-chunks/Test-parallel-chunks.C +++ b/applications/test/parallel-chunks/Test-parallel-chunks.C @@ -55,7 +55,7 @@ void do_exchangeBuf const bool wait ) { - const label startOfRequests = Pstream::nRequests(); + const label startOfRequests = UPstream::nRequests(); // Set up receives // ~~~~~~~~~~~~~~~ @@ -132,7 +132,7 @@ void do_exchangeContainer const bool wait ) { - const label startOfRequests = Pstream::nRequests(); + const label startOfRequests = UPstream::nRequests(); // Set up receives // ~~~~~~~~~~~~~~~ diff --git a/applications/utilities/preProcessing/mapFieldsPar/MapVolFields.H b/applications/utilities/preProcessing/mapFieldsPar/MapVolFields.H index 956f90daec..d4f928aed0 100644 --- a/applications/utilities/preProcessing/mapFieldsPar/MapVolFields.H +++ b/applications/utilities/preProcessing/mapFieldsPar/MapVolFields.H @@ -43,7 +43,8 @@ void evaluateConstraintTypes(GeometricField& fld) { auto& fldBf = fld.boundaryFieldRef(); - const UPstream::commsTypes commsType(UPstream::defaultCommsType); + const UPstream::commsTypes commsType = UPstream::defaultCommsType; + const label startOfRequests = UPstream::nRequests(); if ( @@ -51,8 +52,6 @@ void evaluateConstraintTypes(GeometricField& fld) || commsType == UPstream::commsTypes::nonBlocking ) { - const label startOfRequests = UPstream::nRequests(); - forAll(fldBf, patchi) { fvPatchField& tgtField = fldBf[patchi]; @@ -68,11 +67,7 @@ void evaluateConstraintTypes(GeometricField& fld) } // Wait for outstanding requests - if - ( - UPstream::parRun() - && commsType == UPstream::commsTypes::nonBlocking - ) + if (commsType == UPstream::commsTypes::nonBlocking) { UPstream::waitRequests(startOfRequests); } diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H index 2364716736..b884eef604 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H @@ -396,19 +396,22 @@ public: // Non-blocking comms - //- Get number of outstanding requests - static label nRequests(); + //- Number of outstanding requests + static label nRequests() noexcept; - //- Truncate number of outstanding requests - static void resetRequests(const label sz); + //- Truncate outstanding requests to given length + static void resetRequests(const label n); //- Wait until all requests (from start onwards) have finished. + // A no-op if parRun() == false static void waitRequests(const label start = 0); //- Wait until request i has finished. + // A no-op if parRun() == false static void waitRequest(const label i); //- Non-blocking comms: has request i finished? + // A no-op and returns true if parRun() == false static bool finishedRequest(const label i); static int allocateTag(const char*); diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C index 21f0336b2e..7daab92e19 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C @@ -437,7 +437,8 @@ void Foam::GeometricBoundaryField::evaluate() /// InfoInFunction << nl; ///} - const UPstream::commsTypes commsType(UPstream::defaultCommsType); + const UPstream::commsTypes commsType = UPstream::defaultCommsType; + const label startOfRequests = UPstream::nRequests(); if ( @@ -445,19 +446,13 @@ void Foam::GeometricBoundaryField::evaluate() || commsType == UPstream::commsTypes::nonBlocking ) { - const label startOfRequests = UPstream::nRequests(); - for (auto& pfld : *this) { pfld.initEvaluate(commsType); } // Wait for outstanding requests - if - ( - UPstream::parRun() - && commsType == Pstream::commsTypes::nonBlocking - ) + if (commsType == Pstream::commsTypes::nonBlocking) { UPstream::waitRequests(startOfRequests); } @@ -506,7 +501,8 @@ void Foam::GeometricBoundaryField::evaluateCoupled() /// InfoInFunction << nl; ///} - const UPstream::commsTypes commsType(UPstream::defaultCommsType); + const UPstream::commsTypes commsType = UPstream::defaultCommsType; + const label startOfRequests = UPstream::nRequests(); if ( @@ -514,8 +510,6 @@ void Foam::GeometricBoundaryField::evaluateCoupled() || commsType == UPstream::commsTypes::nonBlocking ) { - const label startOfRequests = UPstream::nRequests(); - for (auto& pfld : *this) { const auto* cpp = isA(pfld.patch()); @@ -527,11 +521,7 @@ void Foam::GeometricBoundaryField::evaluateCoupled() } // Wait for outstanding requests - if - ( - UPstream::parRun() - && commsType == UPstream::commsTypes::nonBlocking - ) + if (commsType == UPstream::commsTypes::nonBlocking) { UPstream::waitRequests(startOfRequests); } diff --git a/src/OpenFOAM/global/fileOperations/collatedFileOperation/OFstreamCollator.C b/src/OpenFOAM/global/fileOperations/collatedFileOperation/OFstreamCollator.C index d325e127a1..9061999e69 100644 --- a/src/OpenFOAM/global/fileOperations/collatedFileOperation/OFstreamCollator.C +++ b/src/OpenFOAM/global/fileOperations/collatedFileOperation/OFstreamCollator.C @@ -440,7 +440,7 @@ bool Foam::OFstreamCollator::write // Gather all data onto master. Is done in local communicator since // not in write thread. Note that we do not store in contiguous // buffer since that would limit to 2G chars. - const label startOfRequests = Pstream::nRequests(); + const label startOfRequests = UPstream::nRequests(); if (Pstream::master(localComm_)) { for (label proci = 1; proci < slaveData.size(); proci++) @@ -479,7 +479,7 @@ bool Foam::OFstreamCollator::write << Foam::abort(FatalError); } } - Pstream::waitRequests(startOfRequests); + UPstream::waitRequests(startOfRequests); { std::lock_guard guard(mutex_); diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixUpdateMatrixInterfaces.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixUpdateMatrixInterfaces.C index 64dd444721..f3679554e8 100644 --- a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixUpdateMatrixInterfaces.C +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixUpdateMatrixInterfaces.C @@ -40,10 +40,12 @@ void Foam::LduMatrix::initMatrixInterfaces Field& result ) const { + const UPstream::commsTypes commsType = UPstream::defaultCommsType; + if ( - Pstream::defaultCommsType == Pstream::commsTypes::blocking - || Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking + commsType == UPstream::commsTypes::blocking + || commsType == UPstream::commsTypes::nonBlocking ) { forAll(interfaces_, interfacei) @@ -59,12 +61,12 @@ void Foam::LduMatrix::initMatrixInterfaces psiif, interfaceCoeffs[interfacei], //Amultiplier(interfaceCoeffs[interfacei]), - Pstream::defaultCommsType + commsType ); } } } - else if (Pstream::defaultCommsType == Pstream::commsTypes::scheduled) + else if (commsType == UPstream::commsTypes::scheduled) { const lduSchedule& patchSchedule = this->patchSchedule(); @@ -88,7 +90,7 @@ void Foam::LduMatrix::initMatrixInterfaces psiif, interfaceCoeffs[interfacei], //Amultiplier(interfaceCoeffs[interfacei]), - Pstream::commsTypes::blocking + UPstream::commsTypes::blocking ); } } @@ -97,7 +99,7 @@ void Foam::LduMatrix::initMatrixInterfaces { FatalErrorInFunction << "Unsupported communications type " - << Pstream::commsTypeNames[Pstream::defaultCommsType] + << UPstream::commsTypeNames[commsType] << exit(FatalError); } } @@ -112,17 +114,18 @@ void Foam::LduMatrix::updateMatrixInterfaces Field& result ) const { + const UPstream::commsTypes commsType = UPstream::defaultCommsType; + if ( - Pstream::defaultCommsType == Pstream::commsTypes::blocking - || Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking + commsType == UPstream::commsTypes::blocking + || commsType == UPstream::commsTypes::nonBlocking ) { // Block until all sends/receives have been finished - if (Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking) + if (commsType == UPstream::commsTypes::nonBlocking) { - IPstream::waitRequests(); - OPstream::waitRequests(); + UPstream::waitRequests(); } forAll(interfaces_, interfacei) @@ -138,12 +141,12 @@ void Foam::LduMatrix::updateMatrixInterfaces psiif, interfaceCoeffs[interfacei], //Amultiplier(interfaceCoeffs[interfacei]), - Pstream::defaultCommsType + commsType ); } } } - else if (Pstream::defaultCommsType == Pstream::commsTypes::scheduled) + else if (commsType == UPstream::commsTypes::scheduled) { const lduSchedule& patchSchedule = this->patchSchedule(); @@ -165,7 +168,7 @@ void Foam::LduMatrix::updateMatrixInterfaces psiif, interfaceCoeffs[interfacei], //Amultiplier(interfaceCoeffs[interfacei]), - Pstream::commsTypes::scheduled + commsType ); } else @@ -179,7 +182,7 @@ void Foam::LduMatrix::updateMatrixInterfaces psiif, interfaceCoeffs[interfacei], //Amultiplier(interfaceCoeffs[interfacei]), - Pstream::commsTypes::scheduled + commsType ); } } @@ -214,7 +217,7 @@ void Foam::LduMatrix::updateMatrixInterfaces { FatalErrorInFunction << "Unsupported communications type " - << Pstream::commsTypeNames[Pstream::defaultCommsType] + << UPstream::commsTypeNames[commsType] << exit(FatalError); } } diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduCalculatedProcessorField/lduCalculatedProcessorField.C b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduCalculatedProcessorField/lduCalculatedProcessorField.C index 2f78bd8df2..b72ad7e7b8 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduCalculatedProcessorField/lduCalculatedProcessorField.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterface/lduCalculatedProcessorField/lduCalculatedProcessorField.C @@ -71,7 +71,7 @@ bool Foam::lduCalculatedProcessorField::ready() const if ( this->outstandingSendRequest_ >= 0 - && this->outstandingSendRequest_ < Pstream::nRequests() + && this->outstandingSendRequest_ < UPstream::nRequests() ) { if (!UPstream::finishedRequest(this->outstandingSendRequest_)) @@ -84,7 +84,7 @@ bool Foam::lduCalculatedProcessorField::ready() const if ( this->outstandingRecvRequest_ >= 0 - && this->outstandingRecvRequest_ < Pstream::nRequests() + && this->outstandingRecvRequest_ < UPstream::nRequests() ) { if (!UPstream::finishedRequest(this->outstandingRecvRequest_)) @@ -210,7 +210,7 @@ void Foam::lduCalculatedProcessorField::updateInterfaceMatrix if ( outstandingRecvRequest_ >= 0 - && outstandingRecvRequest_ < Pstream::nRequests() + && outstandingRecvRequest_ < UPstream::nRequests() ) { UPstream::waitRequest(outstandingRecvRequest_); diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixATmul.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixATmul.C index 2bb8e1ee84..c0e05719fa 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixATmul.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixATmul.C @@ -56,7 +56,7 @@ void Foam::lduMatrix::Amul const scalar* const __restrict__ upperPtr = upper().begin(); const scalar* const __restrict__ lowerPtr = lower().begin(); - const label startRequest = Pstream::nRequests(); + const label startRequest = UPstream::nRequests(); // Initialise the update of interfaced interfaces initMatrixInterfaces @@ -122,7 +122,7 @@ void Foam::lduMatrix::Tmul const scalar* const __restrict__ lowerPtr = lower().begin(); const scalar* const __restrict__ upperPtr = upper().begin(); - const label startRequest = Pstream::nRequests(); + const label startRequest = UPstream::nRequests(); // Initialise the update of interfaced interfaces initMatrixInterfaces @@ -246,7 +246,7 @@ void Foam::lduMatrix::residual // To compensate for this, it is necessary to turn the // sign of the contribution. - const label startRequest = Pstream::nRequests(); + const label startRequest = UPstream::nRequests(); // Initialise the update of interfaced interfaces initMatrixInterfaces diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixUpdateMatrixInterfaces.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixUpdateMatrixInterfaces.C index e3c7421c6c..3562159057 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixUpdateMatrixInterfaces.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixUpdateMatrixInterfaces.C @@ -40,10 +40,12 @@ void Foam::lduMatrix::initMatrixInterfaces const direction cmpt ) const { + const UPstream::commsTypes commsType = UPstream::defaultCommsType; + if ( - Pstream::defaultCommsType == Pstream::commsTypes::blocking - || Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking + commsType == UPstream::commsTypes::blocking + || commsType == UPstream::commsTypes::nonBlocking ) { forAll(interfaces, interfacei) @@ -59,12 +61,12 @@ void Foam::lduMatrix::initMatrixInterfaces psiif, coupleCoeffs[interfacei], cmpt, - Pstream::defaultCommsType + commsType ); } } } - else if (Pstream::defaultCommsType == Pstream::commsTypes::scheduled) + else if (commsType == UPstream::commsTypes::scheduled) { const lduSchedule& patchSchedule = this->patchSchedule(); @@ -88,7 +90,7 @@ void Foam::lduMatrix::initMatrixInterfaces psiif, coupleCoeffs[interfacei], cmpt, - Pstream::commsTypes::blocking + UPstream::commsTypes::blocking ); } } @@ -97,7 +99,7 @@ void Foam::lduMatrix::initMatrixInterfaces { FatalErrorInFunction << "Unsupported communications type " - << Pstream::commsTypeNames[Pstream::defaultCommsType] + << UPstream::commsTypeNames[commsType] << exit(FatalError); } } @@ -114,7 +116,9 @@ void Foam::lduMatrix::updateMatrixInterfaces const label startRequest ) const { - if (Pstream::defaultCommsType == Pstream::commsTypes::blocking) + const UPstream::commsTypes commsType = UPstream::defaultCommsType; + + if (commsType == UPstream::commsTypes::blocking) { forAll(interfaces, interfacei) { @@ -129,12 +133,12 @@ void Foam::lduMatrix::updateMatrixInterfaces psiif, coupleCoeffs[interfacei], cmpt, - Pstream::defaultCommsType + commsType ); } } } - else if (Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking) + else if (commsType == UPstream::commsTypes::nonBlocking) { // Try and consume interfaces as they become available bool allUpdated = false; @@ -160,7 +164,7 @@ void Foam::lduMatrix::updateMatrixInterfaces psiif, coupleCoeffs[interfacei], cmpt, - Pstream::defaultCommsType + commsType ); } else @@ -210,12 +214,12 @@ void Foam::lduMatrix::updateMatrixInterfaces psiif, coupleCoeffs[interfacei], cmpt, - Pstream::defaultCommsType + commsType ); } } } - else if (Pstream::defaultCommsType == Pstream::commsTypes::scheduled) + else if (commsType == UPstream::commsTypes::scheduled) { const lduSchedule& patchSchedule = this->patchSchedule(); @@ -237,7 +241,7 @@ void Foam::lduMatrix::updateMatrixInterfaces psiif, coupleCoeffs[interfacei], cmpt, - Pstream::commsTypes::scheduled + commsType ); } else @@ -251,7 +255,7 @@ void Foam::lduMatrix::updateMatrixInterfaces psiif, coupleCoeffs[interfacei], cmpt, - Pstream::commsTypes::scheduled + commsType ); } } @@ -286,7 +290,7 @@ void Foam::lduMatrix::updateMatrixInterfaces { FatalErrorInFunction << "Unsupported communications type " - << Pstream::commsTypeNames[Pstream::defaultCommsType] + << UPstream::commsTypeNames[commsType] << exit(FatalError); } } diff --git a/src/OpenFOAM/matrices/lduMatrix/smoothers/GaussSeidel/GaussSeidelSmoother.C b/src/OpenFOAM/matrices/lduMatrix/smoothers/GaussSeidel/GaussSeidelSmoother.C index a547ad3cb1..5ce88656f3 100644 --- a/src/OpenFOAM/matrices/lduMatrix/smoothers/GaussSeidel/GaussSeidelSmoother.C +++ b/src/OpenFOAM/matrices/lduMatrix/smoothers/GaussSeidel/GaussSeidelSmoother.C @@ -115,7 +115,7 @@ void Foam::GaussSeidelSmoother::smooth { bPrime = source; - const label startRequest = Pstream::nRequests(); + const label startRequest = UPstream::nRequests(); matrix_.initMatrixInterfaces ( diff --git a/src/OpenFOAM/matrices/lduMatrix/smoothers/nonBlockingGaussSeidel/nonBlockingGaussSeidelSmoother.C b/src/OpenFOAM/matrices/lduMatrix/smoothers/nonBlockingGaussSeidel/nonBlockingGaussSeidelSmoother.C index 3884e17d19..8f8760fd3a 100644 --- a/src/OpenFOAM/matrices/lduMatrix/smoothers/nonBlockingGaussSeidel/nonBlockingGaussSeidelSmoother.C +++ b/src/OpenFOAM/matrices/lduMatrix/smoothers/nonBlockingGaussSeidel/nonBlockingGaussSeidelSmoother.C @@ -142,7 +142,7 @@ void Foam::nonBlockingGaussSeidelSmoother::smooth { bPrime = source; - const label startRequest = Pstream::nRequests(); + const label startRequest = UPstream::nRequests(); matrix_.initMatrixInterfaces ( diff --git a/src/OpenFOAM/matrices/lduMatrix/smoothers/symGaussSeidel/symGaussSeidelSmoother.C b/src/OpenFOAM/matrices/lduMatrix/smoothers/symGaussSeidel/symGaussSeidelSmoother.C index ef3703bc1e..e9e26efa24 100644 --- a/src/OpenFOAM/matrices/lduMatrix/smoothers/symGaussSeidel/symGaussSeidelSmoother.C +++ b/src/OpenFOAM/matrices/lduMatrix/smoothers/symGaussSeidel/symGaussSeidelSmoother.C @@ -115,7 +115,7 @@ void Foam::symGaussSeidelSmoother::smooth { bPrime = source; - const label startRequest = Pstream::nRequests(); + const label startRequest = UPstream::nRequests(); matrix_.initMatrixInterfaces ( diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomerateLduAddressing.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomerateLduAddressing.C index 09b9057ed0..fa64f1db63 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomerateLduAddressing.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomerateLduAddressing.C @@ -272,7 +272,7 @@ void Foam::GAMGAgglomeration::agglomerateLduAddressing patchFaceRestrictAddressing_[fineLevelIndex]; - const label nReq = Pstream::nRequests(); + const label startOfRequests = UPstream::nRequests(); // Initialise transfer of restrict addressing on the interface // The finest mesh uses patchAddr from the original lduAdressing. @@ -301,10 +301,7 @@ void Foam::GAMGAgglomeration::agglomerateLduAddressing } } - if (Pstream::parRun()) - { - Pstream::waitRequests(nReq); - } + UPstream::waitRequests(startOfRequests); // Add the coarse level diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/GAMGProcAgglomeration/GAMGProcAgglomeration.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/GAMGProcAgglomeration/GAMGProcAgglomeration.C index 67e8a0335b..48512f5842 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/GAMGProcAgglomeration/GAMGProcAgglomeration.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/GAMGProcAgglomeration/GAMGProcAgglomeration.C @@ -147,7 +147,7 @@ Foam::labelListList Foam::GAMGProcAgglomeration::globalCellCells // Get the interface cells PtrList nbrGlobalCells(interfaces.size()); { - const label nReq = Pstream::nRequests(); + const label startOfRequests = UPstream::nRequests(); // Initialise transfer of restrict addressing on the interface forAll(interfaces, inti) @@ -162,10 +162,7 @@ Foam::labelListList Foam::GAMGProcAgglomeration::globalCellCells } } - if (UPstream::parRun()) - { - UPstream::waitRequests(nReq); - } + UPstream::waitRequests(startOfRequests); forAll(interfaces, inti) { diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverInterpolate.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverInterpolate.C index 1620a7b7fe..12eb6b9f94 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverInterpolate.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverInterpolate.C @@ -52,7 +52,7 @@ void Foam::GAMGSolver::interpolate Apsi = 0; solveScalar* __restrict__ ApsiPtr = Apsi.begin(); - const label startRequest = Pstream::nRequests(); + const label startRequest = UPstream::nRequests(); m.initMatrixInterfaces ( diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.C index 0cf63ba1f3..bcc476d840 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.C @@ -169,7 +169,7 @@ void Foam::processorGAMGInterfaceField::updateInterfaceMatrix if ( outstandingRecvRequest_ >= 0 - && outstandingRecvRequest_ < Pstream::nRequests() + && outstandingRecvRequest_ < UPstream::nRequests() ) { UPstream::waitRequest(outstandingRecvRequest_); diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/PPCG/PPCG.C b/src/OpenFOAM/matrices/lduMatrix/solvers/PPCG/PPCG.C index dc637b97ce..ec7cb8bb25 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/PPCG/PPCG.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/PPCG/PPCG.C @@ -170,9 +170,9 @@ Foam::solverPerformance Foam::PPCG::scalarSolveCG ) { // Make sure gamma,delta are available - if (Pstream::parRun() && outstandingRequest != -1) + if (outstandingRequest != -1) { - Pstream::waitRequest(outstandingRequest); + UPstream::waitRequest(outstandingRequest); outstandingRequest = -1; } @@ -249,9 +249,9 @@ Foam::solverPerformance Foam::PPCG::scalarSolveCG } // Cleanup any outstanding requests - if (Pstream::parRun() && outstandingRequest != -1) + if (outstandingRequest != -1) { - Pstream::waitRequest(outstandingRequest); + UPstream::waitRequest(outstandingRequest); } return solverPerf; diff --git a/src/OpenFOAM/meshes/lduMesh/lduPrimitiveMesh.C b/src/OpenFOAM/meshes/lduMesh/lduPrimitiveMesh.C index 9099c5c519..5bade23b55 100644 --- a/src/OpenFOAM/meshes/lduMesh/lduPrimitiveMesh.C +++ b/src/OpenFOAM/meshes/lduMesh/lduPrimitiveMesh.C @@ -129,10 +129,8 @@ Foam::labelListList Foam::lduPrimitiveMesh::globalCellCells } } - if (Pstream::parRun()) - { - Pstream::waitRequests(); - } + // Wait for all + UPstream::waitRequests(); forAll(interfaces, inti) { diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBaseSubset.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBaseSubset.C index e45a2ed0d8..207b6852da 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBaseSubset.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBaseSubset.C @@ -186,8 +186,8 @@ void Foam::mapDistributeBase::exchangeMasks } } - // Wait for all to finish - Pstream::waitRequests(startOfRequests); + // Wait for outstanding requests + UPstream::waitRequests(startOfRequests); } // Receiving myself is just a copy diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBaseTemplates.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBaseTemplates.C index 6580cd3052..6ab2260ce3 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBaseTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeBaseTemplates.C @@ -584,8 +584,7 @@ void Foam::mapDistributeBase::distribute } - // Wait for all to finish - + // Wait for outstanding requests Pstream::waitRequests(nOutstanding); @@ -1044,8 +1043,7 @@ void Foam::mapDistributeBase::distribute } - // Wait for all to finish - + // Wait for outstanding requests Pstream::waitRequests(nOutstanding); diff --git a/src/OpenFOAM/parallel/globalIndex/globalIndexTemplates.C b/src/OpenFOAM/parallel/globalIndex/globalIndexTemplates.C index 33d0a71397..9d594ffd5c 100644 --- a/src/OpenFOAM/parallel/globalIndex/globalIndexTemplates.C +++ b/src/OpenFOAM/parallel/globalIndex/globalIndexTemplates.C @@ -142,7 +142,7 @@ void Foam::globalIndex::gatherValues if (commsType == UPstream::commsTypes::nonBlocking) { - // Wait for all to finish + // Wait for outstanding requests UPstream::waitRequests(startOfRequests); } } @@ -242,7 +242,7 @@ void Foam::globalIndex::gather if (commsType == UPstream::commsTypes::nonBlocking) { - // Wait for all to finish + // Wait for outstanding requests UPstream::waitRequests(startOfRequests); } } @@ -338,7 +338,7 @@ void Foam::globalIndex::gather if (commsType == UPstream::commsTypes::nonBlocking) { - // Wait for all to finish + // Wait for outstanding requests UPstream::waitRequests(startOfRequests); } } @@ -945,7 +945,7 @@ void Foam::globalIndex::scatter if (commsType == UPstream::commsTypes::nonBlocking) { - // Wait for all to finish + // Wait for outstanding requests UPstream::waitRequests(startOfRequests); } } diff --git a/src/Pstream/dummy/UPstream.C b/src/Pstream/dummy/UPstream.C index 5ba1a5330c..a586c1ef1a 100644 --- a/src/Pstream/dummy/UPstream.C +++ b/src/Pstream/dummy/UPstream.C @@ -87,13 +87,13 @@ void Foam::UPstream::freePstreamCommunicator(const label) {} -Foam::label Foam::UPstream::nRequests() +Foam::label Foam::UPstream::nRequests() noexcept { return 0; } -void Foam::UPstream::resetRequests(const label i) +void Foam::UPstream::resetRequests(const label n) {} @@ -107,8 +107,7 @@ void Foam::UPstream::waitRequest(const label i) bool Foam::UPstream::finishedRequest(const label i) { - NotImplemented; - return false; + return true; } diff --git a/src/Pstream/mpi/UPstream.C b/src/Pstream/mpi/UPstream.C index 87fb171a52..81fdff28ec 100644 --- a/src/Pstream/mpi/UPstream.C +++ b/src/Pstream/mpi/UPstream.C @@ -609,23 +609,28 @@ void Foam::UPstream::freePstreamCommunicator(const label communicator) } -Foam::label Foam::UPstream::nRequests() +Foam::label Foam::UPstream::nRequests() noexcept { return PstreamGlobals::outstandingRequests_.size(); } -void Foam::UPstream::resetRequests(const label i) +void Foam::UPstream::resetRequests(const label n) { - if (i < PstreamGlobals::outstandingRequests_.size()) + if (n >= 0 && n < PstreamGlobals::outstandingRequests_.size()) { - PstreamGlobals::outstandingRequests_.setSize(i); + PstreamGlobals::outstandingRequests_.resize(n); } } void Foam::UPstream::waitRequests(const label start) { + if (!UPstream::parRun()) + { + return; // No-op for non-parallel + } + if (UPstream::debug) { Pout<< "UPstream::waitRequests : starting wait for " @@ -672,6 +677,11 @@ void Foam::UPstream::waitRequests(const label start) void Foam::UPstream::waitRequest(const label i) { + if (!UPstream::parRun()) + { + return; // No-op for non-parallel + } + if (debug) { Pout<< "UPstream::waitRequest : starting wait for request:" << i @@ -717,13 +727,18 @@ void Foam::UPstream::waitRequest(const label i) bool Foam::UPstream::finishedRequest(const label i) { + if (!UPstream::parRun()) + { + return true; // No-op for non-parallel + } + if (debug) { Pout<< "UPstream::finishedRequest : checking request:" << i << endl; } - if (i >= PstreamGlobals::outstandingRequests_.size()) + if (i < 0 || i >= PstreamGlobals::outstandingRequests_.size()) { FatalErrorInFunction << "There are " << PstreamGlobals::outstandingRequests_.size() diff --git a/src/finiteArea/distributed/faMeshDistributorNew.C b/src/finiteArea/distributed/faMeshDistributorNew.C index 00e433a075..cc6efdd423 100644 --- a/src/finiteArea/distributed/faMeshDistributorNew.C +++ b/src/finiteArea/distributed/faMeshDistributorNew.C @@ -305,7 +305,7 @@ Foam::faMeshDistributor::distribute // Processor-processor connections if (Pstream::parRun()) { - const label startOfRequests = Pstream::nRequests(); + const label startOfRequests = UPstream::nRequests(); const faBoundaryMesh& oldBndMesh = oldMesh.boundary(); @@ -339,8 +339,9 @@ Foam::faMeshDistributor::distribute } } - // Wait for all to finish - Pstream::waitRequests(startOfRequests); + // Wait for outstanding requests + // (commsType == UPstream::commsTypes::nonBlocking) + UPstream::waitRequests(startOfRequests); // Receive values for (const faPatch& fap : oldBndMesh) diff --git a/src/finiteArea/faMatrices/faMatrix/faMatrixSolve.C b/src/finiteArea/faMatrices/faMatrix/faMatrixSolve.C index 63f11d4f81..f718dcf652 100644 --- a/src/finiteArea/faMatrices/faMatrix/faMatrixSolve.C +++ b/src/finiteArea/faMatrices/faMatrix/faMatrixSolve.C @@ -111,7 +111,7 @@ Foam::SolverPerformance Foam::faMatrix::solve PrecisionAdaptor sourceCmpt_ss(sourceCmpt); ConstPrecisionAdaptor psiCmpt_ss(psiCmpt); - const label startRequest = Pstream::nRequests(); + const label startRequest = UPstream::nRequests(); initMatrixInterfaces ( diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/calculatedProcessor/calculatedProcessorFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/calculatedProcessor/calculatedProcessorFvPatchField.C index ba02bd7fa5..08acdaa41b 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/calculatedProcessor/calculatedProcessorFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/calculatedProcessor/calculatedProcessorFvPatchField.C @@ -92,7 +92,7 @@ bool Foam::calculatedProcessorFvPatchField::ready() const if ( this->outstandingSendRequest_ >= 0 - && this->outstandingSendRequest_ < Pstream::nRequests() + && this->outstandingSendRequest_ < UPstream::nRequests() ) { if (!UPstream::finishedRequest(this->outstandingSendRequest_)) @@ -105,7 +105,7 @@ bool Foam::calculatedProcessorFvPatchField::ready() const if ( this->outstandingRecvRequest_ >= 0 - && this->outstandingRecvRequest_ < Pstream::nRequests() + && this->outstandingRecvRequest_ < UPstream::nRequests() ) { if (!UPstream::finishedRequest(this->outstandingRecvRequest_)) @@ -201,7 +201,7 @@ void Foam::calculatedProcessorFvPatchField::evaluate if ( outstandingRecvRequest_ >= 0 - && outstandingRecvRequest_ < Pstream::nRequests() + && outstandingRecvRequest_ < UPstream::nRequests() ) { UPstream::waitRequest(outstandingRecvRequest_); @@ -327,7 +327,7 @@ void Foam::calculatedProcessorFvPatchField::updateInterfaceMatrix if ( outstandingRecvRequest_ >= 0 - && outstandingRecvRequest_ < Pstream::nRequests() + && outstandingRecvRequest_ < UPstream::nRequests() ) { UPstream::waitRequest(outstandingRecvRequest_); diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.C index 19a38e1804..5d0e817d77 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.C @@ -283,7 +283,7 @@ void Foam::processorFvPatchField::evaluate if ( outstandingRecvRequest_ >= 0 - && outstandingRecvRequest_ < Pstream::nRequests() + && outstandingRecvRequest_ < UPstream::nRequests() ) { UPstream::waitRequest(outstandingRecvRequest_); @@ -416,7 +416,7 @@ void Foam::processorFvPatchField::updateInterfaceMatrix if ( outstandingRecvRequest_ >= 0 - && outstandingRecvRequest_ < Pstream::nRequests() + && outstandingRecvRequest_ < UPstream::nRequests() ) { UPstream::waitRequest(outstandingRecvRequest_); @@ -565,7 +565,7 @@ void Foam::processorFvPatchField::updateInterfaceMatrix if ( outstandingRecvRequest_ >= 0 - && outstandingRecvRequest_ < Pstream::nRequests() + && outstandingRecvRequest_ < UPstream::nRequests() ) { UPstream::waitRequest(outstandingRecvRequest_); @@ -606,11 +606,10 @@ bool Foam::processorFvPatchField::ready() const if ( outstandingSendRequest_ >= 0 - && outstandingSendRequest_ < Pstream::nRequests() + && outstandingSendRequest_ < UPstream::nRequests() ) { - bool finished = UPstream::finishedRequest(outstandingSendRequest_); - if (!finished) + if (!UPstream::finishedRequest(outstandingSendRequest_)) { return false; } @@ -620,11 +619,10 @@ bool Foam::processorFvPatchField::ready() const if ( outstandingRecvRequest_ >= 0 - && outstandingRecvRequest_ < Pstream::nRequests() + && outstandingRecvRequest_ < UPstream::nRequests() ) { - bool finished = UPstream::finishedRequest(outstandingRecvRequest_); - if (!finished) + if (!UPstream::finishedRequest(outstandingRecvRequest_)) { return false; } diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C index 5824d665c6..b5188075f0 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C @@ -190,7 +190,7 @@ Foam::SolverPerformance Foam::fvMatrix::solveSegregated PrecisionAdaptor sourceCmpt_ss(sourceCmpt); ConstPrecisionAdaptor psiCmpt_ss(psiCmpt); - const label startRequest = Pstream::nRequests(); + const label startRequest = UPstream::nRequests(); initMatrixInterfaces ( diff --git a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C index 43f77436c1..05a8b628ab 100644 --- a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C +++ b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C @@ -108,6 +108,7 @@ void Foam::volPointInterpolation::addSeparated } // Wait for outstanding requests + // (commsType == UPstream::commsTypes::nonBlocking) UPstream::waitRequests(startOfRequests); forAll(pfbf, patchi) diff --git a/src/functionObjects/field/mapFields/mapFieldsTemplates.C b/src/functionObjects/field/mapFields/mapFieldsTemplates.C index c5e6968d96..6de7cb7be0 100644 --- a/src/functionObjects/field/mapFields/mapFieldsTemplates.C +++ b/src/functionObjects/field/mapFields/mapFieldsTemplates.C @@ -38,7 +38,8 @@ void Foam::functionObjects::mapFields::evaluateConstraintTypes { auto& fldBf = fld.boundaryFieldRef(); - const UPstream::commsTypes commsType(UPstream::defaultCommsType); + const UPstream::commsTypes commsType = UPstream::defaultCommsType; + const label startOfRequests = UPstream::nRequests(); if ( @@ -46,8 +47,6 @@ void Foam::functionObjects::mapFields::evaluateConstraintTypes || commsType == UPstream::commsTypes::nonBlocking ) { - const label startOfRequests = UPstream::nRequests(); - forAll(fldBf, patchi) { fvPatchField& tgtField = fldBf[patchi]; @@ -63,11 +62,7 @@ void Foam::functionObjects::mapFields::evaluateConstraintTypes } // Wait for outstanding requests - if - ( - UPstream::parRun() - && commsType == UPstream::commsTypes::nonBlocking - ) + if (commsType == UPstream::commsTypes::nonBlocking) { UPstream::waitRequests(startOfRequests); } diff --git a/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.C b/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.C index f77d49d292..823ac8d9cb 100644 --- a/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.C +++ b/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.C @@ -55,7 +55,7 @@ void Foam::MGridGenGAMGAgglomeration::swap PtrList& nbrValues ) const { - const label nReq = Pstream::nRequests(); + const label startOfRequests = UPstream::nRequests(); // Initialise transfer of restrict addressing on the interface forAll(interfaces, inti) @@ -70,10 +70,10 @@ void Foam::MGridGenGAMGAgglomeration::swap } } - if (Pstream::parRun()) - { - Pstream::waitRequests(nReq); - } + // Wait for outstanding requests + // (commsType == UPstream::commsTypes::nonBlocking) + UPstream::waitRequests(startOfRequests); + // Get the interface agglomeration nbrValues.setSize(interfaces.size()); diff --git a/src/overset/dynamicOversetFvMesh/dynamicOversetFvMeshTemplates.C b/src/overset/dynamicOversetFvMesh/dynamicOversetFvMeshTemplates.C index 688913f5dd..7466878bb7 100644 --- a/src/overset/dynamicOversetFvMesh/dynamicOversetFvMeshTemplates.C +++ b/src/overset/dynamicOversetFvMesh/dynamicOversetFvMeshTemplates.C @@ -119,22 +119,19 @@ void Foam::dynamicOversetFvMesh::correctBoundaryConditions const bool typeOnly ) { + const UPstream::commsTypes commsType = UPstream::defaultCommsType; const label startOfRequests = UPstream::nRequests(); forAll(bfld, patchi) { if (typeOnly == (isA(bfld[patchi]) != nullptr)) { - bfld[patchi].initEvaluate(UPstream::defaultCommsType); + bfld[patchi].initEvaluate(commsType); } } // Wait for outstanding requests - if - ( - UPstream::parRun() - && UPstream::defaultCommsType == UPstream::commsTypes::nonBlocking - ) + if (commsType == UPstream::commsTypes::nonBlocking) { UPstream::waitRequests(startOfRequests); } @@ -143,7 +140,7 @@ void Foam::dynamicOversetFvMesh::correctBoundaryConditions { if (typeOnly == (isA(bfld[patchi]) != nullptr)) { - bfld[patchi].evaluate(UPstream::defaultCommsType); + bfld[patchi].evaluate(commsType); } } } @@ -903,6 +900,7 @@ void Foam::dynamicOversetFvMesh::correctCoupledBoundaryConditions(GeoField& fld) { typename GeoField::Boundary& bfld = fld.boundaryFieldRef(); + const UPstream::commsTypes commsType = UPstream::defaultCommsType; const label startOfRequests = UPstream::nRequests(); forAll(bfld, patchi) @@ -910,16 +908,12 @@ void Foam::dynamicOversetFvMesh::correctCoupledBoundaryConditions(GeoField& fld) if (bfld[patchi].coupled()) { //Pout<< "initEval of " << bfld[patchi].patch().name() << endl; - bfld[patchi].initEvaluate(Pstream::defaultCommsType); + bfld[patchi].initEvaluate(commsType); } } // Wait for outstanding requests - if - ( - UPstream::parRun() - && UPstream::defaultCommsType == UPstream::commsTypes::nonBlocking - ) + if (commsType == UPstream::commsTypes::nonBlocking) { UPstream::waitRequests(startOfRequests); } @@ -929,7 +923,7 @@ void Foam::dynamicOversetFvMesh::correctCoupledBoundaryConditions(GeoField& fld) if (bfld[patchi].coupled()) { //Pout<< "eval of " << bfld[patchi].patch().name() << endl; - bfld[patchi].evaluate(Pstream::defaultCommsType); + bfld[patchi].evaluate(commsType); } } } diff --git a/src/overset/lduPrimitiveProcessorInterface/GAMG/calculatedProcessorGAMGInterfaceField.C b/src/overset/lduPrimitiveProcessorInterface/GAMG/calculatedProcessorGAMGInterfaceField.C index 881cd30fdc..8d91292b58 100644 --- a/src/overset/lduPrimitiveProcessorInterface/GAMG/calculatedProcessorGAMGInterfaceField.C +++ b/src/overset/lduPrimitiveProcessorInterface/GAMG/calculatedProcessorGAMGInterfaceField.C @@ -171,7 +171,7 @@ void Foam::calculatedProcessorGAMGInterfaceField::updateInterfaceMatrix if ( outstandingRecvRequest_ >= 0 - && outstandingRecvRequest_ < Pstream::nRequests() + && outstandingRecvRequest_ < UPstream::nRequests() ) { UPstream::waitRequest(outstandingRecvRequest_); diff --git a/src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.C b/src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.C index 2dfa932c4b..6642113b7b 100644 --- a/src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.C +++ b/src/parallel/decompose/decompositionMethods/metisLikeDecomp/metisLikeDecomp.C @@ -130,9 +130,9 @@ Foam::label Foam::metisLikeDecomp::decomposeGeneral } } + // Wait for outstanding requests if (commsType == UPstream::commsTypes::nonBlocking) { - // Wait for all to finish UPstream::waitRequests(startOfRequests); }