ENH: more consistent use of broadcast, combineReduce etc.

- broadcast           : (replaces scatter)
  - combineReduce       == combineGather + broadcast
  - listCombineReduce   == listCombineGather + broadcast
  - mapCombineReduce    == mapCombineGather + broadcast
  - allGatherList       == gatherList + scatterList

  Before settling on a more consistent naming convention,
  some intermediate namings were used in OpenFOAM-v2206:

    - combineReduce       (2206: combineAllGather)
    - listCombineReduce   (2206: listCombineAllGather)
    - mapCombineReduce    (2206: mapCombineAllGather)
This commit is contained in:
Mark Olesen
2022-08-23 15:58:32 +02:00
committed by Andrew Heather
parent b9c15b8585
commit 473e14418a
103 changed files with 248 additions and 307 deletions

View File

@ -223,7 +223,7 @@ bool Foam::functionObjects::Curle::execute()
pDash /= 4*mathematical::pi;
Pstream::listCombineAllGather(pDash, plusEqOp<scalar>());
Pstream::listCombineReduce(pDash, plusEqOp<scalar>());
if (surfaceWriterPtr_)
{

View File

@ -188,8 +188,8 @@ void Foam::DMDModels::STDMD::compress()
q.subColumn(i) = EVecs.subColumn(permutation[i]);
}
}
Pstream::scatter(G_);
Pstream::scatter(q);
Pstream::broadcast(G_);
Pstream::broadcast(q);
// Update "Q"
Q_ = Q_*q;
@ -357,8 +357,8 @@ reducedKoopmanOperator()
A1 = RxInv_*RMatrix(MatrixTools::pinv(Rx*(G_^Rx)));
Rx.clear();
}
Pstream::scatter(RxInv_);
Pstream::scatter(A1);
Pstream::broadcast(RxInv_);
Pstream::broadcast(A1);
Info<< tab << "Computing A2" << endl;
SMatrix A2(Qupper_ & Qlower_);
@ -452,15 +452,15 @@ bool Foam::DMDModels::STDMD::eigendecomposition(SMatrix& Atilde)
evals_ = cp;
}
}
Pstream::scatter(fail);
Pstream::broadcast(fail);
if (fail)
{
return false;
}
Pstream::scatter(evals_);
Pstream::scatter(evecs_);
Pstream::broadcast(evals_);
Pstream::broadcast(evecs_);
return true;
}
@ -503,8 +503,8 @@ void Foam::DMDModels::STDMD::frequencies()
it = std::find_if(std::next(it), freqs_.cend(), margin);
}
}
Pstream::scatter(freqs_);
Pstream::scatter(freqsi_);
Pstream::broadcast(freqs_);
Pstream::broadcast(freqsi_);
}
@ -567,7 +567,7 @@ void Foam::DMDModels::STDMD::amplitudes()
}
}
}
Pstream::scatter(amps_);
Pstream::broadcast(amps_);
}
@ -648,8 +648,8 @@ void Foam::DMDModels::STDMD::magnitudes()
std::sort(magsi_.begin(), magsi_.end(), descend);
}
Pstream::scatter(mags_);
Pstream::scatter(magsi_);
Pstream::broadcast(mags_);
Pstream::broadcast(magsi_);
}

View File

@ -87,8 +87,8 @@ bool Foam::functionObjects::columnAverage::columnAverageField
}
// Global sum
Pstream::listCombineAllGather(regionField, plusEqOp<Type>());
Pstream::listCombineAllGather(regionCount, plusEqOp<label>());
Pstream::listCombineReduce(regionField, plusEqOp<Type>());
Pstream::listCombineReduce(regionCount, plusEqOp<label>());
forAll(regionField, regioni)
{

View File

@ -430,7 +430,7 @@ void Foam::functionObjects::externalCoupled::initCoupling()
|| isFile(dir/"patchFaces");
}
Pstream::scatter(geomExists);
Pstream::broadcast(geomExists);
if (!geomExists)
{

View File

@ -333,7 +333,7 @@ void Foam::functionObjects::extractEulerianParticles::calculateAddressing
// Create map from new regions to slots in particles list
// - filter through new-to-new addressing to identify new particles
Pstream::listCombineAllGather(newToNewRegion, maxEqOp<label>());
Pstream::listCombineReduce(newToNewRegion, maxEqOp<label>());
label nParticle = -1;
labelHashSet newRegions;
@ -352,7 +352,7 @@ void Foam::functionObjects::extractEulerianParticles::calculateAddressing
// Accumulate old region data or create a new particle if there is no
// mapping from the old-to-new region
Pstream::listCombineAllGather(oldToNewRegion, maxEqOp<label>());
Pstream::listCombineReduce(oldToNewRegion, maxEqOp<label>());
List<eulerianParticle> newParticles(newRegionToParticleMap.size());
forAll(oldToNewRegion, oldRegioni)

View File

@ -66,7 +66,7 @@ static Map<Type> regionSum(const regionSplit& regions, const Field<Type>& fld)
regionToSum(regioni, Type(Zero)) += fld[celli];
}
Pstream::mapCombineAllGather(regionToSum, plusEqOp<Type>());
Pstream::mapCombineReduce(regionToSum, plusEqOp<Type>());
return regionToSum;
}
@ -214,7 +214,7 @@ Foam::functionObjects::regionSizeDistribution::findPatchRegions
// Make sure all the processors have the same set of regions
Pstream::mapCombineAllGather(patchRegions, minEqOp<label>());
Pstream::mapCombineReduce(patchRegions, minEqOp<label>());
return patchRegions;
}

View File

@ -800,7 +800,7 @@ bool Foam::functionObjects::streamLineBase::writeToFile()
// File names generated on the master but setProperty needed everywher
Pstream::scatter(outputFileNames);
Pstream::broadcast(outputFileNames);
forAllConstIters(outputFileNames, iter)
{

View File

@ -470,7 +470,7 @@ void Foam::functionObjects::propellerInfo::updateSampleDiskCells()
}
}
Pstream::listCombineAllGather(pointMask_, orEqOp<bool>());
Pstream::listCombineReduce(pointMask_, orEqOp<bool>());
}
@ -785,7 +785,7 @@ Foam::tmp<Foam::Field<Type>> Foam::functionObjects::propellerInfo::interpolate
}
}
Pstream::listCombineAllGather(field, maxEqOp<Type>());
Pstream::listCombineReduce(field, maxEqOp<Type>());
return tfield;
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -56,11 +56,8 @@ Foam::wordList Foam::functionObjects::vtkCloud::writeFields
// Thus need to resolve names between all processors.
wordList fieldNames(obrTmp.names<IOField<Type>>());
Pstream::combineGather(fieldNames, ListOps::uniqueEqOp<word>());
Pstream::broadcast(fieldNames);
// Consistent order on all processors
Foam::sort(fieldNames);
Pstream::combineReduce(fieldNames, ListOps::uniqueEqOp<word>());
Foam::sort(fieldNames); // Consistent order
for (const word& fieldName : fieldNames)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -218,9 +218,9 @@ bool Foam::functionObjects::abort::execute()
}
}
// Send to slaves. Also acts as an MPI barrier
label intAction(action);
Pstream::scatter(intAction);
// Send to sub-ranks. Also acts as an MPI barrier
int intAction(action);
Pstream::broadcast(intAction);
action = Time::stopAtControls(intAction);

View File

@ -267,7 +267,7 @@ bool Foam::areaWrite::write()
}
// Parallel consistency (no-op in serial)
Pstream::mapCombineAllGather(selected, HashSetOps::plusEqOp<word>());
Pstream::mapCombineReduce(selected, HashSetOps::plusEqOp<word>());
missed.clear();

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -73,16 +73,12 @@ void Foam::areaWrite::performAction
{
fieldNames = areaMesh.thisDb().names<GeoField>(fieldSelection_);
// With syncPar
// Synchronize names
if (Pstream::parRun())
{
// Synchronize names
Pstream::combineGather(fieldNames, ListOps::uniqueEqOp<word>());
Pstream::broadcast(fieldNames);
Pstream::combineReduce(fieldNames, ListOps::uniqueEqOp<word>());
}
// Sort for consistent order on all processors
Foam::sort(fieldNames);
Foam::sort(fieldNames); // Consistent order
}
for (const word& fieldName : fieldNames)

View File

@ -27,7 +27,6 @@ License
#include "parProfiling.H"
#include "addToRunTimeSelectionTable.H"
#include "UPstream.H"
#include "Pstream.H"
#include "PstreamReduceOps.H"
#include "profilingPstream.H"

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -73,7 +73,7 @@ Foam::label Foam::functionObjects::systemCall::dispatch(const stringList& calls)
// MPI barrier
if (masterOnly_)
{
Pstream::scatter(nCalls);
Pstream::broadcast(nCalls);
}
return nCalls;