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

@ -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)
{

View File

@ -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;
}

View File

@ -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);

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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)
{

View File

@ -474,8 +474,11 @@ Foam::label Foam::checkTopology
}
}
Pstream::listCombineGather(regionDisconnected, andEqOp<bool>());
Pstream::broadcast(regionDisconnected);
Pstream::listCombineAllGather
(
regionDisconnected,
andEqOp<bool>()
);
}

View File

@ -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.

View File

@ -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);