mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: avoid prior communication when using mapDistribute
- in most cases can simply construct mapDistribute with the sendMap and have it take care of communication and addressing for the corresponding constructMap. This removes code duplication, which in some cases was also using much less efficient mechanisms (eg, combineReduce on list of lists, or an allGatherList on the send sizes etc) and also reduces the number of places where Pstream::exchange/exchangeSizes is being called. ENH: reduce communication in turbulentDFSEMInlet - was doing an allGatherList to populate a mapDistribute. Now simply use PstreamBuffers mechanisms directly.
This commit is contained in:
@ -54,7 +54,6 @@ Foam::DistributedDelaunayMesh<Triangulation>::buildMap
|
||||
forAll(toProc, i)
|
||||
{
|
||||
label proci = toProc[i];
|
||||
|
||||
nSend[proci]++;
|
||||
}
|
||||
|
||||
@ -64,8 +63,7 @@ Foam::DistributedDelaunayMesh<Triangulation>::buildMap
|
||||
|
||||
forAll(nSend, proci)
|
||||
{
|
||||
sendMap[proci].setSize(nSend[proci]);
|
||||
|
||||
sendMap[proci].resize_nocopy(nSend[proci]);
|
||||
nSend[proci] = 0;
|
||||
}
|
||||
|
||||
@ -73,49 +71,10 @@ Foam::DistributedDelaunayMesh<Triangulation>::buildMap
|
||||
forAll(toProc, i)
|
||||
{
|
||||
label proci = toProc[i];
|
||||
|
||||
sendMap[proci][nSend[proci]++] = i;
|
||||
}
|
||||
|
||||
// 4. Send over how many I need to receive
|
||||
labelList recvSizes;
|
||||
Pstream::exchangeSizes(sendMap, recvSizes);
|
||||
|
||||
|
||||
// Determine receive map
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
labelListList constructMap(Pstream::nProcs());
|
||||
|
||||
// Local transfers first
|
||||
constructMap[Pstream::myProcNo()] = identity
|
||||
(
|
||||
sendMap[Pstream::myProcNo()].size()
|
||||
);
|
||||
|
||||
label constructSize = constructMap[Pstream::myProcNo()].size();
|
||||
|
||||
forAll(constructMap, proci)
|
||||
{
|
||||
if (proci != Pstream::myProcNo())
|
||||
{
|
||||
label nRecv = recvSizes[proci];
|
||||
|
||||
constructMap[proci].setSize(nRecv);
|
||||
|
||||
for (label i = 0; i < nRecv; i++)
|
||||
{
|
||||
constructMap[proci][i] = constructSize++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return autoPtr<mapDistribute>::New
|
||||
(
|
||||
constructSize,
|
||||
std::move(sendMap),
|
||||
std::move(constructMap)
|
||||
);
|
||||
return autoPtr<mapDistribute>::New(std::move(sendMap));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -59,7 +59,6 @@ Foam::autoPtr<Foam::mapDistribute> Foam::backgroundMeshDecomposition::buildMap
|
||||
forAll(toProc, i)
|
||||
{
|
||||
label proci = toProc[i];
|
||||
|
||||
nSend[proci]++;
|
||||
}
|
||||
|
||||
@ -69,8 +68,7 @@ Foam::autoPtr<Foam::mapDistribute> Foam::backgroundMeshDecomposition::buildMap
|
||||
|
||||
forAll(nSend, proci)
|
||||
{
|
||||
sendMap[proci].setSize(nSend[proci]);
|
||||
|
||||
sendMap[proci].resize_nocopy(nSend[proci]);
|
||||
nSend[proci] = 0;
|
||||
}
|
||||
|
||||
@ -78,49 +76,10 @@ Foam::autoPtr<Foam::mapDistribute> Foam::backgroundMeshDecomposition::buildMap
|
||||
forAll(toProc, i)
|
||||
{
|
||||
label proci = toProc[i];
|
||||
|
||||
sendMap[proci][nSend[proci]++] = i;
|
||||
}
|
||||
|
||||
// 4. Send over how many I need to receive
|
||||
labelList recvSizes;
|
||||
Pstream::exchangeSizes(sendMap, recvSizes);
|
||||
|
||||
|
||||
// Determine receive map
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
labelListList constructMap(Pstream::nProcs());
|
||||
|
||||
// Local transfers first
|
||||
constructMap[Pstream::myProcNo()] = identity
|
||||
(
|
||||
sendMap[Pstream::myProcNo()].size()
|
||||
);
|
||||
|
||||
label constructSize = constructMap[Pstream::myProcNo()].size();
|
||||
|
||||
forAll(constructMap, proci)
|
||||
{
|
||||
if (proci != Pstream::myProcNo())
|
||||
{
|
||||
label nRecv = recvSizes[proci];
|
||||
|
||||
constructMap[proci].setSize(nRecv);
|
||||
|
||||
for (label i = 0; i < nRecv; i++)
|
||||
{
|
||||
constructMap[proci][i] = constructSize++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return autoPtr<mapDistribute>::New
|
||||
(
|
||||
constructSize,
|
||||
std::move(sendMap),
|
||||
std::move(constructMap)
|
||||
);
|
||||
return autoPtr<mapDistribute>::New(std::move(sendMap));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user