mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -661,11 +661,8 @@ void countExtrudePatches
|
||||
}
|
||||
// Synchronise decision. Actual numbers are not important, just make
|
||||
// sure that they're > 0 on all processors.
|
||||
Pstream::listCombineGather(zoneSidePatch, plusEqOp<label>());
|
||||
Pstream::listCombineGather(zoneZonePatch, plusEqOp<label>());
|
||||
|
||||
Pstream::broadcast(zoneSidePatch);
|
||||
Pstream::broadcast(zoneZonePatch);
|
||||
Pstream::listCombineAllGather(zoneSidePatch, plusEqOp<label>());
|
||||
Pstream::listCombineAllGather(zoneZonePatch, plusEqOp<label>());
|
||||
}
|
||||
|
||||
|
||||
@ -1465,8 +1462,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
List<wordList> allNames(Pstream::nProcs());
|
||||
allNames[Pstream::myProcNo()] = mesh.boundaryMesh().names();
|
||||
Pstream::gatherList(allNames);
|
||||
Pstream::scatterList(allNames);
|
||||
Pstream::allGatherList(allNames);
|
||||
|
||||
FatalErrorInFunction
|
||||
<< "Patches are not synchronised on all processors."
|
||||
@ -1858,8 +1854,7 @@ int main(int argc, char *argv[])
|
||||
const primitiveFacePatch extrudePatch(std::move(zoneFaces), mesh.points());
|
||||
|
||||
|
||||
Pstream::listCombineGather(isInternal, orEqOp<bool>());
|
||||
Pstream::broadcast(isInternal);
|
||||
Pstream::listCombineAllGather(isInternal, orEqOp<bool>());
|
||||
|
||||
// Check zone either all internal or all external faces
|
||||
checkZoneInside(mesh, zoneNames, zoneID, extrudeMeshFaces, isInternal);
|
||||
@ -2320,8 +2315,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// Reduce
|
||||
Pstream::mapCombineGather(globalSum, plusEqOp<point>());
|
||||
Pstream::broadcast(globalSum);
|
||||
Pstream::mapCombineAllGather(globalSum, plusEqOp<point>());
|
||||
|
||||
forAll(localToGlobalRegion, localRegionI)
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -157,8 +157,7 @@ bool Foam::DistributedDelaunayMesh<Triangulation>::distributeBoundBoxes
|
||||
// Give the bounds of every processor to every other processor
|
||||
allBackgroundMeshBounds_()[Pstream::myProcNo()] = bb;
|
||||
|
||||
Pstream::gatherList(allBackgroundMeshBounds_());
|
||||
Pstream::scatterList(allBackgroundMeshBounds_());
|
||||
Pstream::allGatherList(allBackgroundMeshBounds_());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -713,8 +713,7 @@ void Foam::backgroundMeshDecomposition::buildPatchAndTree()
|
||||
// Give the bounds of every processor to every other processor
|
||||
allBackgroundMeshBounds_[Pstream::myProcNo()] = overallBb;
|
||||
|
||||
Pstream::gatherList(allBackgroundMeshBounds_);
|
||||
Pstream::scatterList(allBackgroundMeshBounds_);
|
||||
Pstream::allGatherList(allBackgroundMeshBounds_);
|
||||
|
||||
// find global bounding box
|
||||
globalBackgroundBounds_ = treeBoundBox(boundBox::invertedBox);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -1564,8 +1564,7 @@ Foam::label Foam::conformalVoronoiMesh::createPatchInfo
|
||||
}
|
||||
|
||||
// Because the previous test was insufficient, combine the lists.
|
||||
Pstream::gatherList(procUsedList);
|
||||
Pstream::scatterList(procUsedList);
|
||||
Pstream::allGatherList(procUsedList);
|
||||
|
||||
forAll(procUsedList, proci)
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -692,11 +692,8 @@ Foam::label Foam::conformalVoronoiMesh::synchroniseSurfaceTrees
|
||||
);
|
||||
|
||||
List<pointIndexHitAndFeatureDynList> procSurfLocations(Pstream::nProcs());
|
||||
|
||||
procSurfLocations[Pstream::myProcNo()] = surfaceHits;
|
||||
|
||||
Pstream::gatherList(procSurfLocations);
|
||||
Pstream::scatterList(procSurfLocations);
|
||||
Pstream::allGatherList(procSurfLocations);
|
||||
|
||||
List<labelHashSet> hits(Pstream::nProcs());
|
||||
|
||||
@ -732,8 +729,7 @@ Foam::label Foam::conformalVoronoiMesh::synchroniseSurfaceTrees
|
||||
}
|
||||
}
|
||||
|
||||
Pstream::listCombineGather(hits, plusEqOp<labelHashSet>());
|
||||
Pstream::broadcast(hits);
|
||||
Pstream::listCombineAllGather(hits, plusEqOp<labelHashSet>());
|
||||
|
||||
forAll(surfaceHits, eI)
|
||||
{
|
||||
@ -780,11 +776,8 @@ Foam::label Foam::conformalVoronoiMesh::synchroniseEdgeTrees
|
||||
);
|
||||
|
||||
List<pointIndexHitAndFeatureDynList> procEdgeLocations(Pstream::nProcs());
|
||||
|
||||
procEdgeLocations[Pstream::myProcNo()] = featureEdgeHits;
|
||||
|
||||
Pstream::gatherList(procEdgeLocations);
|
||||
Pstream::scatterList(procEdgeLocations);
|
||||
Pstream::allGatherList(procEdgeLocations);
|
||||
|
||||
List<labelHashSet> hits(Pstream::nProcs());
|
||||
|
||||
@ -823,8 +816,7 @@ Foam::label Foam::conformalVoronoiMesh::synchroniseEdgeTrees
|
||||
}
|
||||
}
|
||||
|
||||
Pstream::listCombineGather(hits, plusEqOp<labelHashSet>());
|
||||
Pstream::broadcast(hits);
|
||||
Pstream::listCombineAllGather(hits, plusEqOp<labelHashSet>());
|
||||
|
||||
forAll(featureEdgeHits, eI)
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2018 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -142,10 +142,7 @@ Foam::List<Vb::Point> Foam::pointFile::initialPoints() const
|
||||
List<boolList> allProcPt(Pstream::nProcs());
|
||||
|
||||
allProcPt[Pstream::myProcNo()] = procPt;
|
||||
|
||||
Pstream::gatherList(allProcPt);
|
||||
|
||||
Pstream::scatterList(allProcPt);
|
||||
Pstream::allGatherList(allProcPt);
|
||||
|
||||
forAll(procPt, ptI)
|
||||
{
|
||||
|
||||
@ -474,8 +474,11 @@ Foam::label Foam::checkTopology
|
||||
}
|
||||
}
|
||||
|
||||
Pstream::listCombineGather(regionDisconnected, andEqOp<bool>());
|
||||
Pstream::broadcast(regionDisconnected);
|
||||
Pstream::listCombineAllGather
|
||||
(
|
||||
regionDisconnected,
|
||||
andEqOp<bool>()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -713,9 +713,8 @@ void syncPoints
|
||||
sharedPts[pd.sharedPointAddr()[i]] = points[meshPointi];
|
||||
}
|
||||
|
||||
// Combine on master.
|
||||
Pstream::listCombineGather(sharedPts, cop);
|
||||
Pstream::broadcast(sharedPts);
|
||||
// Combine - globally consistent
|
||||
Pstream::listCombineAllGather(sharedPts, cop);
|
||||
|
||||
// Now we will all have the same information. Merge it back with
|
||||
// my local information.
|
||||
|
||||
@ -1111,8 +1111,7 @@ label findCorrespondingRegion
|
||||
}
|
||||
}
|
||||
|
||||
Pstream::listCombineGather(cellsInZone, plusEqOp<label>());
|
||||
Pstream::broadcast(cellsInZone);
|
||||
Pstream::listCombineAllGather(cellsInZone, plusEqOp<label>());
|
||||
|
||||
// Pick region with largest overlap of zoneI
|
||||
label regionI = findMax(cellsInZone);
|
||||
|
||||
@ -223,7 +223,7 @@ bool writeOptionalMeshObject
|
||||
|
||||
// Make sure all know if there is a valid class name
|
||||
wordList classNames(1, io.headerClassName());
|
||||
combineReduce(classNames, uniqueEqOp<word>());
|
||||
Pstream::combineAllGather(classNames, uniqueEqOp<word>());
|
||||
|
||||
// Check for correct type
|
||||
if (classNames[0] == T::typeName)
|
||||
@ -422,7 +422,7 @@ int main(int argc, char *argv[])
|
||||
)
|
||||
);
|
||||
|
||||
combineReduce(lagrangianDirs, uniqueEqOp<fileName>());
|
||||
Pstream::combineAllGather(lagrangianDirs, uniqueEqOp<fileName>());
|
||||
|
||||
if (!lagrangianDirs.empty())
|
||||
{
|
||||
@ -459,7 +459,7 @@ int main(int argc, char *argv[])
|
||||
)
|
||||
);
|
||||
|
||||
combineReduce(cloudDirs, uniqueEqOp<fileName>());
|
||||
Pstream::combineAllGather(cloudDirs, uniqueEqOp<fileName>());
|
||||
|
||||
forAll(cloudDirs, i)
|
||||
{
|
||||
@ -485,7 +485,7 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
|
||||
// Combine with all other cloud objects
|
||||
combineReduce(cloudFields, uniqueEqOp<word>());
|
||||
Pstream::combineAllGather(cloudFields, uniqueEqOp<word>());
|
||||
|
||||
for (const word& name : cloudFields)
|
||||
{
|
||||
|
||||
@ -286,7 +286,7 @@ Foam::parLagrangianRedistributor::redistributeLagrangianPositions
|
||||
nsTransPs[sendProcI] = subMap[sendProcI].size();
|
||||
}
|
||||
// Send sizes across. Note: blocks.
|
||||
combineReduce(sizes, Pstream::listEq());
|
||||
Pstream::combineAllGather(sizes, Pstream::listEq());
|
||||
|
||||
labelListList constructMap(Pstream::nProcs());
|
||||
label constructSize = 0;
|
||||
|
||||
@ -2649,7 +2649,7 @@ int main(int argc, char *argv[])
|
||||
bool nfs = true;
|
||||
{
|
||||
List<fileName> roots(1, args.rootPath());
|
||||
combineReduce(roots, ListOps::uniqueEqOp<fileName>());
|
||||
Pstream::combineAllGather(roots, ListOps::uniqueEqOp<fileName>());
|
||||
nfs = (roots.size() == 1);
|
||||
}
|
||||
|
||||
@ -3280,8 +3280,7 @@ int main(int argc, char *argv[])
|
||||
)
|
||||
);
|
||||
meshDir[Pstream::myProcNo()] = fName.path();
|
||||
Pstream::gatherList(meshDir);
|
||||
Pstream::scatterList(meshDir);
|
||||
Pstream::allGatherList(meshDir);
|
||||
//Info<< "Per processor faces dirs:" << nl
|
||||
// << " " << meshDir << nl << endl;
|
||||
}
|
||||
|
||||
@ -104,12 +104,11 @@ if (timeDirs.size() && doLagrangian)
|
||||
{
|
||||
for (auto& cloudFields : regionCloudFields)
|
||||
{
|
||||
Pstream::mapCombineGather
|
||||
Pstream::mapCombineAllGather
|
||||
(
|
||||
cloudFields,
|
||||
HashTableOps::plusEqOp<word>()
|
||||
);
|
||||
Pstream::broadcast(cloudFields);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ Usage
|
||||
#include "IOobjectList.H"
|
||||
#include "IOmanip.H"
|
||||
#include "OFstream.H"
|
||||
#include "PstreamCombineReduceOps.H"
|
||||
#include "Pstream.H"
|
||||
#include "HashOps.H"
|
||||
#include "regionProperties.H"
|
||||
|
||||
|
||||
@ -187,8 +187,7 @@ int main(int argc, char *argv[])
|
||||
const label maxNProcs = returnReduce(maxIds.size(), maxOp<label>());
|
||||
maxIds.resize(maxNProcs, -1);
|
||||
|
||||
Pstream::listCombineGather(maxIds, maxEqOp<label>());
|
||||
Pstream::broadcast(maxIds);
|
||||
Pstream::listCombineAllGather(maxIds, maxEqOp<label>());
|
||||
|
||||
// From ids to count
|
||||
const labelList numIds = maxIds + 1;
|
||||
|
||||
@ -40,8 +40,7 @@ Foam::Field<T> Foam::channelIndex::regionSum(const Field<T>& cellField) const
|
||||
}
|
||||
|
||||
// Global sum
|
||||
Pstream::listCombineGather(regionField, plusEqOp<T>());
|
||||
Pstream::broadcast(regionField);
|
||||
Pstream::listCombineAllGather(regionField, plusEqOp<T>());
|
||||
|
||||
return regionField;
|
||||
}
|
||||
|
||||
@ -287,8 +287,7 @@ bool setFaceFieldType
|
||||
}
|
||||
}
|
||||
|
||||
Pstream::listCombineGather(nChanged, plusEqOp<label>());
|
||||
Pstream::broadcast(nChanged);
|
||||
Pstream::listCombineAllGather(nChanged, plusEqOp<label>());
|
||||
|
||||
auto& fieldBf = field.boundaryFieldRef();
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -456,12 +456,9 @@ int main(int argc, char *argv[])
|
||||
remoteCoarseSf[Pstream::myProcNo()] = localCoarseSf;
|
||||
remoteCoarseAgg[Pstream::myProcNo()] = localAgg;
|
||||
|
||||
Pstream::gatherList(remoteCoarseCf);
|
||||
Pstream::scatterList(remoteCoarseCf);
|
||||
Pstream::gatherList(remoteCoarseSf);
|
||||
Pstream::scatterList(remoteCoarseSf);
|
||||
Pstream::gatherList(remoteCoarseAgg);
|
||||
Pstream::scatterList(remoteCoarseAgg);
|
||||
Pstream::allGatherList(remoteCoarseCf);
|
||||
Pstream::allGatherList(remoteCoarseSf);
|
||||
Pstream::allGatherList(remoteCoarseAgg);
|
||||
|
||||
|
||||
globalIndex globalNumbering(nCoarseFaces);
|
||||
|
||||
@ -198,8 +198,7 @@ int main(int argc, char *argv[])
|
||||
boundBox(mesh.points(), false)
|
||||
).extend(rndGen, 1e-3)
|
||||
);
|
||||
Pstream::gatherList(meshBb);
|
||||
Pstream::scatterList(meshBb);
|
||||
Pstream::allGatherList(meshBb);
|
||||
}
|
||||
|
||||
IOobject io
|
||||
|
||||
Reference in New Issue
Block a user