From aa956f4b054757fa1ee6ef06093ea7aae3e6026b Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 10 Jun 2020 12:10:02 +0100 Subject: [PATCH] ENH: Pstream: Feed through outstanding requests more. See #1626. This e.g. was giving a problem with using volPointInterpolation (in functionObjects) with non-blocking global reductions. --- .../parallelProcessing/redistributePar/redistributePar.C | 2 +- .../utilities/preProcessing/mapFieldsPar/MapVolFields.H | 2 +- src/OpenFOAM/db/IOstreams/Pstreams/exchange.C | 4 ++-- .../GeometricFields/GeometricField/GeometricBoundaryField.C | 2 +- .../fileOperations/collatedFileOperation/OFstreamCollator.C | 2 +- .../GAMGAgglomeration/GAMGAgglomerateLduAddressing.C | 4 +++- .../GAMGProcAgglomeration/GAMGProcAgglomeration.C | 4 +++- .../interpolation/volPointInterpolation/volPointInterpolate.C | 4 +++- src/functionObjects/field/mapFields/mapFieldsTemplates.C | 2 +- .../MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.C | 4 +++- .../dynamicOversetFvMesh/dynamicOversetFvMeshTemplates.C | 2 +- 11 files changed, 20 insertions(+), 12 deletions(-) diff --git a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C index a7facbdf04..9043525a32 100644 --- a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C +++ b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C @@ -763,7 +763,7 @@ void correctCoupledBoundaryConditions(fvMesh& mesh) || Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking ) { - label nReq = Pstream::nRequests(); + const label nReq = Pstream::nRequests(); forAll(bfld, patchi) { diff --git a/applications/utilities/preProcessing/mapFieldsPar/MapVolFields.H b/applications/utilities/preProcessing/mapFieldsPar/MapVolFields.H index a5f6afc484..abd4a036bc 100644 --- a/applications/utilities/preProcessing/mapFieldsPar/MapVolFields.H +++ b/applications/utilities/preProcessing/mapFieldsPar/MapVolFields.H @@ -50,7 +50,7 @@ void evaluateConstraintTypes(GeometricField& fld) || Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking ) { - label nReq = Pstream::nRequests(); + const label nReq = Pstream::nRequests(); forAll(fldBf, patchi) { diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/exchange.C b/src/OpenFOAM/db/IOstreams/Pstreams/exchange.C index c9991789ed..e5c9319c93 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/exchange.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/exchange.C @@ -46,7 +46,7 @@ void Foam::Pstream::exchangeContainer const bool block ) { - label startOfRequests = Pstream::nRequests(); + const label startOfRequests = Pstream::nRequests(); // Set up receives // ~~~~~~~~~~~~~~~ @@ -120,7 +120,7 @@ void Foam::Pstream::exchangeBuf const bool block ) { - label startOfRequests = Pstream::nRequests(); + const label startOfRequests = Pstream::nRequests(); // Set up receives // ~~~~~~~~~~~~~~~ diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C index 90870379b3..7d43c87cf2 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C @@ -414,7 +414,7 @@ void Foam::GeometricField::Boundary::evaluate() || Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking ) { - label nReq = Pstream::nRequests(); + const label nReq = Pstream::nRequests(); forAll(*this, patchi) { diff --git a/src/OpenFOAM/global/fileOperations/collatedFileOperation/OFstreamCollator.C b/src/OpenFOAM/global/fileOperations/collatedFileOperation/OFstreamCollator.C index 61474a8884..a8a1a93960 100644 --- a/src/OpenFOAM/global/fileOperations/collatedFileOperation/OFstreamCollator.C +++ b/src/OpenFOAM/global/fileOperations/collatedFileOperation/OFstreamCollator.C @@ -455,7 +455,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. - label startOfRequests = Pstream::nRequests(); + const label startOfRequests = Pstream::nRequests(); if (Pstream::master(localComm_)) { for (label proci = 1; proci < slaveData.size(); proci++) 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 a7a8bf0395..6206846271 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomerateLduAddressing.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomerateLduAddressing.C @@ -279,6 +279,8 @@ void Foam::GAMGAgglomeration::agglomerateLduAddressing patchFaceRestrictAddressing_[fineLevelIndex]; + const label nReq = Pstream::nRequests(); + // Initialise transfer of restrict addressing on the interface forAll(fineInterfaces, inti) { @@ -294,7 +296,7 @@ void Foam::GAMGAgglomeration::agglomerateLduAddressing if (Pstream::parRun()) { - Pstream::waitRequests(); + Pstream::waitRequests(nReq); } 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 6d766c061a..7fb23ff19c 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/GAMGProcAgglomeration/GAMGProcAgglomeration.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGProcAgglomerations/GAMGProcAgglomeration/GAMGProcAgglomeration.C @@ -147,6 +147,8 @@ Foam::labelListList Foam::GAMGProcAgglomeration::globalCellCells // Get the interface cells PtrList nbrGlobalCells(interfaces.size()); { + const label nReq = Pstream::nRequests(); + // Initialise transfer of restrict addressing on the interface forAll(interfaces, inti) { @@ -162,7 +164,7 @@ Foam::labelListList Foam::GAMGProcAgglomeration::globalCellCells if (Pstream::parRun()) { - Pstream::waitRequests(); + Pstream::waitRequests(nReq); } forAll(interfaces, inti) diff --git a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C index e9d979f69a..ae1d89dd20 100644 --- a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C +++ b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C @@ -95,6 +95,8 @@ void Foam::volPointInterpolation::addSeparated typename GeometricField:: Boundary& pfbf = pf.boundaryFieldRef(); + const label nReq = Pstream::nRequests(); + forAll(pfbf, patchi) { if (pfbf[patchi].coupled()) @@ -109,7 +111,7 @@ void Foam::volPointInterpolation::addSeparated } // Block for any outstanding requests - Pstream::waitRequests(); + Pstream::waitRequests(nReq); forAll(pfbf, patchi) { diff --git a/src/functionObjects/field/mapFields/mapFieldsTemplates.C b/src/functionObjects/field/mapFields/mapFieldsTemplates.C index dc89a68bef..2d1f66322a 100644 --- a/src/functionObjects/field/mapFields/mapFieldsTemplates.C +++ b/src/functionObjects/field/mapFields/mapFieldsTemplates.C @@ -46,7 +46,7 @@ void Foam::functionObjects::mapFields::evaluateConstraintTypes || Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking ) { - label nReq = Pstream::nRequests(); + const label nReq = Pstream::nRequests(); forAll(fldBf, patchi) { diff --git a/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.C b/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.C index 028702892f..f77d49d292 100644 --- a/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.C +++ b/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.C @@ -55,6 +55,8 @@ void Foam::MGridGenGAMGAgglomeration::swap PtrList& nbrValues ) const { + const label nReq = Pstream::nRequests(); + // Initialise transfer of restrict addressing on the interface forAll(interfaces, inti) { @@ -70,7 +72,7 @@ void Foam::MGridGenGAMGAgglomeration::swap if (Pstream::parRun()) { - Pstream::waitRequests(); + Pstream::waitRequests(nReq); } // Get the interface agglomeration diff --git a/src/overset/dynamicOversetFvMesh/dynamicOversetFvMeshTemplates.C b/src/overset/dynamicOversetFvMesh/dynamicOversetFvMeshTemplates.C index aeb5ed7a1c..e8e889bd7c 100644 --- a/src/overset/dynamicOversetFvMesh/dynamicOversetFvMeshTemplates.C +++ b/src/overset/dynamicOversetFvMesh/dynamicOversetFvMeshTemplates.C @@ -899,7 +899,7 @@ void Foam::dynamicOversetFvMesh::correctCoupledBoundaryConditions(GeoField& fld) { typename GeoField::Boundary& bfld = fld.boundaryFieldRef(); - label nReq = Pstream::nRequests(); + const label nReq = Pstream::nRequests(); forAll(bfld, patchi) {