ENH: bundle Pstream:: AllGather methods

- bundles frequently used 'gather/scatter' patterns more consistently.

  - combineAllGather     -> combineGather + broadcast
  - listCombineAllGather -> listCombineGather + broadcast
  - mapCombineAllGather  -> mapCombineGather + broadcast
  - allGatherList        -> gatherList + scatterList
  - reduce               -> gather + broadcast (ie, allreduce)

- The allGatherList currently wraps gatherList/scatterList, but may be
  replaced with a different algorithm in the future.

STYLE: PstreamCombineReduceOps.H is mostly unneeded now
This commit is contained in:
Mark Olesen
2022-03-28 16:30:51 +02:00
parent e98acdc4fc
commit d38de84d21
105 changed files with 935 additions and 605 deletions

View File

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

View File

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

View File

@ -333,8 +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::listCombineGather(newToNewRegion, maxEqOp<label>());
Pstream::broadcast(newToNewRegion);
Pstream::listCombineAllGather(newToNewRegion, maxEqOp<label>());
label nParticle = -1;
labelHashSet newRegions;
@ -353,8 +352,8 @@ 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::listCombineGather(oldToNewRegion, maxEqOp<label>());
Pstream::broadcast(oldToNewRegion);
Pstream::listCombineAllGather(oldToNewRegion, maxEqOp<label>());
List<eulerianParticle> newParticles(newRegionToParticleMap.size());
forAll(oldToNewRegion, oldRegioni)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -186,19 +186,13 @@ void Foam::functionObjects::fieldMinMax::calcMinMaxFieldType
}
// Collect info from all processors and output
Pstream::gatherList(minVs);
Pstream::scatterList(minVs);
Pstream::gatherList(minCells);
Pstream::scatterList(minCells);
Pstream::gatherList(minCs);
Pstream::scatterList(minCs);
Pstream::allGatherList(minVs);
Pstream::allGatherList(minCells);
Pstream::allGatherList(minCs);
Pstream::gatherList(maxVs);
Pstream::scatterList(maxVs);
Pstream::gatherList(maxCells);
Pstream::scatterList(maxCells);
Pstream::gatherList(maxCs);
Pstream::scatterList(maxCs);
Pstream::allGatherList(maxVs);
Pstream::allGatherList(maxCells);
Pstream::allGatherList(maxCs);
minId = findMin(minVs);
const Type& minValue = minVs[minId];

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2017 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -40,8 +40,7 @@ void Foam::functionObjects::fieldValue::combineFields(Field<Type>& field)
List<Field<Type>> allValues(Pstream::nProcs());
allValues[Pstream::myProcNo()] = field;
Pstream::gatherList(allValues);
Pstream::scatterList(allValues);
Pstream::allGatherList(allValues);
field =
ListListOps::combine<Field<Type>>

View File

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

View File

@ -1063,10 +1063,8 @@ void Foam::functionObjects::forces::calcForcesMoment()
}
}
Pstream::listCombineGather(force_, plusEqOp<vectorField>());
Pstream::listCombineGather(moment_, plusEqOp<vectorField>());
Pstream::broadcast(force_);
Pstream::broadcast(moment_);
Pstream::listCombineAllGather(force_, plusEqOp<vectorField>());
Pstream::listCombineAllGather(moment_, plusEqOp<vectorField>());
}

View File

@ -468,8 +468,7 @@ void Foam::functionObjects::propellerInfo::updateSampleDiskCells()
}
}
Pstream::listCombineGather(pointMask_, orEqOp<bool>());
Pstream::broadcast(pointMask_);
Pstream::listCombineAllGather(pointMask_, orEqOp<bool>());
}
@ -774,8 +773,7 @@ Foam::tmp<Foam::Field<Type>> Foam::functionObjects::propellerInfo::interpolate
}
}
Pstream::listCombineGather(field, maxEqOp<Type>());
Pstream::broadcast(field);
Pstream::listCombineAllGather(field, maxEqOp<Type>());
return tfield;
}

View File

@ -266,11 +266,8 @@ bool Foam::areaWrite::write()
selected = areaMesh.thisDb().classes(fieldSelection_);
}
if (Pstream::parRun())
{
Pstream::mapCombineGather(selected, HashSetOps::plusEqOp<word>());
Pstream::broadcast(selected);
}
// Parallel consistency (no-op in serial)
Pstream::mapCombineAllGather(selected, HashSetOps::plusEqOp<word>());
missed.clear();