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

@ -163,9 +163,7 @@ Foam::autoPtr<Foam::mapDistribute> Foam::meshToMesh::calcProcMap
procBb[Pstream::myProcNo()] = treeBoundBoxList();
}
Pstream::gatherList(procBb);
Pstream::scatterList(procBb);
Pstream::allGatherList(procBb);
if (debug)
@ -257,8 +255,7 @@ Foam::autoPtr<Foam::mapDistribute> Foam::meshToMesh::calcProcMap
{
sendSizes[Pstream::myProcNo()][proci] = sendMap[proci].size();
}
Pstream::gatherList(sendSizes);
Pstream::scatterList(sendSizes);
Pstream::allGatherList(sendSizes);
// determine order of receiving

View File

@ -165,9 +165,8 @@ void Foam::patchProbes::findElements(const fvMesh& mesh)
}
// Find nearest.
Pstream::listCombineGather(nearest, mappedPatchBase::nearestEqOp());
Pstream::broadcast(nearest);
// Find nearest - globally consistent
Pstream::listCombineAllGather(nearest, mappedPatchBase::nearestEqOp());
oldPoints_.resize(this->size());

View File

@ -111,8 +111,7 @@ Foam::patchProbes::sample(const VolumeField<Type>& vField) const
}
}
Pstream::listCombineGather(values, isNotEqOp<Type>());
Pstream::broadcast(values);
Pstream::listCombineAllGather(values, isNotEqOp<Type>());
return tvalues;
}
@ -142,8 +141,7 @@ Foam::patchProbes::sample(const SurfaceField<Type>& sField) const
}
}
Pstream::listCombineGather(values, isNotEqOp<Type>());
Pstream::broadcast(values);
Pstream::listCombineAllGather(values, isNotEqOp<Type>());
return tvalues;
}

View File

@ -225,8 +225,7 @@ Foam::probes::sample(const VolumeField<Type>& vField) const
}
}
Pstream::listCombineGather(values, isNotEqOp<Type>());
Pstream::broadcast(values);
Pstream::listCombineAllGather(values, isNotEqOp<Type>());
return tvalues;
}
@ -249,8 +248,7 @@ Foam::probes::sample(const SurfaceField<Type>& sField) const
}
}
Pstream::listCombineGather(values, isNotEqOp<Type>());
Pstream::broadcast(values);
Pstream::listCombineAllGather(values, isNotEqOp<Type>());
return tvalues;
}

View File

@ -84,11 +84,8 @@ void Foam::cloudSet::calcSamples
minFoundProc[i] = foundProc[i];
}
}
Pstream::listCombineGather(minFoundProc, minEqOp<label>());
Pstream::listCombineGather(maxFoundProc, maxEqOp<label>());
Pstream::broadcast(minFoundProc);
Pstream::broadcast(maxFoundProc);
Pstream::listCombineAllGather(minFoundProc, minEqOp<label>());
Pstream::listCombineAllGather(maxFoundProc, maxEqOp<label>());
DynamicField<point> missingPoints(sampleCoords_.size());

View File

@ -154,9 +154,8 @@ void Foam::patchCloudSet::calcSamples
}
// Find nearest.
Pstream::listCombineGather(nearest, mappedPatchBase::nearestEqOp());
Pstream::broadcast(nearest);
// Find nearest - globally consistent
Pstream::listCombineAllGather(nearest, mappedPatchBase::nearestEqOp());
if (debug && Pstream::master())

View File

@ -177,10 +177,12 @@ void Foam::patchSeedSet::calcSamples
// 2. Reduce on master. Select nearest processor.
// Find nearest. Combine on master.
Pstream::listCombineGather(nearest, mappedPatchBase::nearestEqOp());
Pstream::broadcast(nearest);
// Find nearest - globally consistent
Pstream::listCombineAllGather
(
nearest,
mappedPatchBase::nearestEqOp()
);
// 3. Pick up my local faces that have won

View File

@ -199,12 +199,9 @@ Foam::IOobjectList Foam::sampledSets::preCheckFields(unsigned request)
selected = mesh_.classes(fieldSelection_);
}
// Parallel consistency (no-op in serial)
// Probably not needed...
// if (Pstream::parRun())
// {
// Pstream::mapCombineGather(selected, HashSetOps::plusEqOp<word>());
// Pstream::broadcast(selected);
// }
/// Pstream::mapCombineAllGather(selected, HashSetOps::plusEqOp<word>());
DynamicList<label> missed(fieldSelection_.size());

View File

@ -264,7 +264,7 @@ void Foam::shortestPathSet::sync
celli,
Tuple2<point, bool>(origin, findMinDistance)
);
Foam::combineReduce
Pstream::combineAllGather
(
searchData,
[](ProcData& x, const ProcData& y)

View File

@ -227,8 +227,7 @@ bool Foam::sampledMeshedSurface::update(const meshSearch& meshSearcher)
// See which processor has the nearest. Mark and subset
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Pstream::listCombineGather(nearest, minFirstEqOp<scalar>{});
Pstream::broadcast(nearest);
Pstream::listCombineAllGather(nearest, minFirstEqOp<scalar>{});
labelList cellOrFaceLabels(fc.size(), -1);

View File

@ -118,11 +118,8 @@ Foam::IOobjectList Foam::sampledSurfaces::preCheckFields()
selected = obr_.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>());
DynamicList<label> missed(fieldSelection_.size());

View File

@ -276,9 +276,8 @@ void Foam::isoSurfacePoint::syncUnseparatedPoints
sharedPts[pd.sharedPointAddr()[i]] = pointValues[meshPointi];
}
// Combine on master.
Pstream::listCombineGather(sharedPts, minEqOp<point>());
Pstream::broadcast(sharedPts);
// Globally consistent
Pstream::listCombineAllGather(sharedPts, minEqOp<point>());
// Now we will all have the same information. Merge it back with
// my local information.