mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: use broadcasting Pstreams for one-to-all sends
This commit is contained in:
committed by
Andrew Heather
parent
d37cb64efe
commit
1348cd7e7b
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2012-2017 OpenFOAM Foundation
|
Copyright (C) 2012-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2015-2021 OpenCFD Ltd.
|
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -88,25 +88,23 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
|
|||||||
);
|
);
|
||||||
|
|
||||||
Pstream::parRun(oldParRun);
|
Pstream::parRun(oldParRun);
|
||||||
|
}
|
||||||
|
|
||||||
// Send patches
|
if (Pstream::parRun())
|
||||||
for (const int slave : Pstream::subProcs())
|
{
|
||||||
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
OPstream toSlave(Pstream::commsTypes::scheduled, slave);
|
// Broadcast: send patches
|
||||||
toSlave << patchEntries;
|
OPBstream toAll(Pstream::masterNo());
|
||||||
|
toAll << patchEntries;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Broadcast: receive patches
|
||||||
|
IPBstream fromMaster(Pstream::masterNo());
|
||||||
|
fromMaster >> patchEntries;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// Receive patches
|
|
||||||
IPstream fromMaster
|
|
||||||
(
|
|
||||||
Pstream::commsTypes::scheduled,
|
|
||||||
Pstream::masterNo()
|
|
||||||
);
|
|
||||||
fromMaster >> patchEntries;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Dummy meshes
|
// Dummy meshes
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2015-2021 OpenCFD Ltd.
|
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -388,20 +388,20 @@ void Foam::globalMeshData::calcSharedEdges() const
|
|||||||
}
|
}
|
||||||
countSharedEdges(localShared, globalShared, sharedEdgeI);
|
countSharedEdges(localShared, globalShared, sharedEdgeI);
|
||||||
|
|
||||||
// Receive data from slaves and insert
|
// Receive data and insert
|
||||||
if (Pstream::parRun())
|
if (Pstream::parRun())
|
||||||
{
|
{
|
||||||
for (const int slave : Pstream::subProcs())
|
for (const int proci : Pstream::subProcs())
|
||||||
{
|
{
|
||||||
// Receive the edges using shared points from the slave.
|
// Receive the edges using shared points from the slave.
|
||||||
IPstream fromSlave(Pstream::commsTypes::blocking, slave);
|
IPstream fromProc(Pstream::commsTypes::blocking, proci);
|
||||||
EdgeMap<labelList> procSharedEdges(fromSlave);
|
EdgeMap<labelList> procSharedEdges(fromProc);
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< "globalMeshData::calcSharedEdges : "
|
Pout<< "globalMeshData::calcSharedEdges : "
|
||||||
<< "Merging in from proc"
|
<< "Merging in from proc"
|
||||||
<< Foam::name(slave) << " : " << procSharedEdges.size()
|
<< proci << " : " << procSharedEdges.size()
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
countSharedEdges(procSharedEdges, globalShared, sharedEdgeI);
|
countSharedEdges(procSharedEdges, globalShared, sharedEdgeI);
|
||||||
@ -432,36 +432,32 @@ void Foam::globalMeshData::calcSharedEdges() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Send back to slaves.
|
// Broadcast: send back to all
|
||||||
if (Pstream::parRun())
|
if (Pstream::parRun())
|
||||||
{
|
{
|
||||||
for (const int slave : Pstream::subProcs())
|
OPBstream toAll(Pstream::masterNo()); // == worldComm
|
||||||
{
|
toAll << globalShared;
|
||||||
// Receive the edges using shared points from the slave.
|
|
||||||
OPstream toSlave(Pstream::commsTypes::blocking, slave);
|
|
||||||
toSlave << globalShared;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Send local edges to master
|
if (Pstream::parRun())
|
||||||
{
|
{
|
||||||
OPstream toMaster
|
// Send local edges to master
|
||||||
(
|
{
|
||||||
Pstream::commsTypes::blocking,
|
OPstream toMaster
|
||||||
Pstream::masterNo()
|
(
|
||||||
);
|
Pstream::commsTypes::blocking,
|
||||||
toMaster << localShared;
|
Pstream::masterNo()
|
||||||
}
|
);
|
||||||
// Receive merged edges from master.
|
toMaster << localShared;
|
||||||
{
|
}
|
||||||
IPstream fromMaster
|
|
||||||
(
|
// Broadcast: receive merged edges from master
|
||||||
Pstream::commsTypes::blocking,
|
{
|
||||||
Pstream::masterNo()
|
IPBstream fromMaster(Pstream::masterNo()); // == worldComm
|
||||||
);
|
fromMaster >> globalShared;
|
||||||
fromMaster >> globalShared;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1896,14 +1892,14 @@ Foam::pointField Foam::globalMeshData::sharedPoints() const
|
|||||||
sharedPoints[sharedPointi] = mesh_.points()[pointLabels[i]];
|
sharedPoints[sharedPointi] = mesh_.points()[pointLabels[i]];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Receive data from slaves and insert
|
// Receive data and insert
|
||||||
for (const int slave : Pstream::subProcs())
|
for (const int proci : Pstream::subProcs())
|
||||||
{
|
{
|
||||||
IPstream fromSlave(Pstream::commsTypes::blocking, slave);
|
IPstream fromProc(Pstream::commsTypes::blocking, proci);
|
||||||
|
|
||||||
labelList nbrSharedPointAddr;
|
labelList nbrSharedPointAddr;
|
||||||
pointField nbrSharedPoints;
|
pointField nbrSharedPoints;
|
||||||
fromSlave >> nbrSharedPointAddr >> nbrSharedPoints;
|
fromProc >> nbrSharedPointAddr >> nbrSharedPoints;
|
||||||
|
|
||||||
forAll(nbrSharedPointAddr, i)
|
forAll(nbrSharedPointAddr, i)
|
||||||
{
|
{
|
||||||
@ -1913,22 +1909,15 @@ Foam::pointField Foam::globalMeshData::sharedPoints() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send back
|
// Broadcast: send back
|
||||||
for (const int slave : Pstream::subProcs())
|
|
||||||
{
|
{
|
||||||
OPstream toSlave
|
OPBstream toAll(Pstream::masterNo()); // == worldComm
|
||||||
(
|
toAll << sharedPoints;
|
||||||
Pstream::commsTypes::blocking,
|
|
||||||
slave,
|
|
||||||
sharedPoints.size_bytes()
|
|
||||||
);
|
|
||||||
toSlave << sharedPoints;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Slave:
|
// Send address and points
|
||||||
// send points
|
|
||||||
{
|
{
|
||||||
OPstream toMaster
|
OPstream toMaster
|
||||||
(
|
(
|
||||||
@ -1940,13 +1929,9 @@ Foam::pointField Foam::globalMeshData::sharedPoints() const
|
|||||||
<< UIndirectList<point>(mesh_.points(), pointLabels)();
|
<< UIndirectList<point>(mesh_.points(), pointLabels)();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Receive sharedPoints
|
// Broadcast: receive sharedPoints
|
||||||
{
|
{
|
||||||
IPstream fromMaster
|
IPBstream fromMaster(Pstream::masterNo()); // == worldComm
|
||||||
(
|
|
||||||
Pstream::commsTypes::blocking,
|
|
||||||
Pstream::masterNo()
|
|
||||||
);
|
|
||||||
fromMaster >> sharedPoints;
|
fromMaster >> sharedPoints;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2015-2017 OpenFOAM Foundation
|
Copyright (C) 2015-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2015-2021 OpenCFD Ltd.
|
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -106,18 +106,11 @@ Foam::List<Foam::labelPair> Foam::mapDistributeBase::schedule
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Send back
|
|
||||||
for (const int slave : Pstream::subProcs(comm))
|
// Broadcast: send merged to all
|
||||||
{
|
{
|
||||||
OPstream toSlave
|
OPBstream toAll(Pstream::masterNo(), comm);
|
||||||
(
|
toAll << allComms;
|
||||||
Pstream::commsTypes::scheduled,
|
|
||||||
slave,
|
|
||||||
0,
|
|
||||||
tag,
|
|
||||||
comm
|
|
||||||
);
|
|
||||||
toSlave << allComms;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -133,15 +126,10 @@ Foam::List<Foam::labelPair> Foam::mapDistributeBase::schedule
|
|||||||
);
|
);
|
||||||
toMaster << allComms;
|
toMaster << allComms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Broadcast: receive merged
|
||||||
{
|
{
|
||||||
IPstream fromMaster
|
IPBstream fromMaster(Pstream::masterNo(), comm);
|
||||||
(
|
|
||||||
Pstream::commsTypes::scheduled,
|
|
||||||
Pstream::masterNo(),
|
|
||||||
0,
|
|
||||||
tag,
|
|
||||||
comm
|
|
||||||
);
|
|
||||||
fromMaster >> allComms;
|
fromMaster >> allComms;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2015-2021 OpenCFD Ltd.
|
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -286,11 +286,11 @@ void Foam::syncTools::syncPointMap
|
|||||||
{
|
{
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
// Receive the edges using shared points from the slave.
|
// Receive the edges using shared points from other procs
|
||||||
for (const int slave : Pstream::subProcs())
|
for (const int proci : Pstream::subProcs())
|
||||||
{
|
{
|
||||||
IPstream fromSlave(Pstream::commsTypes::scheduled, slave);
|
IPstream fromProc(Pstream::commsTypes::scheduled, proci);
|
||||||
Map<T> nbrValues(fromSlave);
|
Map<T> nbrValues(fromProc);
|
||||||
|
|
||||||
// Merge neighbouring values with my values
|
// Merge neighbouring values with my values
|
||||||
forAllConstIters(nbrValues, iter)
|
forAllConstIters(nbrValues, iter)
|
||||||
@ -305,16 +305,15 @@ void Foam::syncTools::syncPointMap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send back
|
// Broadcast: send merged values to all
|
||||||
for (const int slave : Pstream::subProcs())
|
|
||||||
{
|
{
|
||||||
OPstream toSlave(Pstream::commsTypes::scheduled, slave);
|
OPBstream toAll(Pstream::masterNo()); // == worldComm
|
||||||
toSlave << sharedPointValues;
|
toAll << sharedPointValues;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Slave: send to master
|
// Send to master
|
||||||
{
|
{
|
||||||
OPstream toMaster
|
OPstream toMaster
|
||||||
(
|
(
|
||||||
@ -323,13 +322,10 @@ void Foam::syncTools::syncPointMap
|
|||||||
);
|
);
|
||||||
toMaster << sharedPointValues;
|
toMaster << sharedPointValues;
|
||||||
}
|
}
|
||||||
// Receive merged values
|
|
||||||
|
// Broadcast: receive merged values
|
||||||
{
|
{
|
||||||
IPstream fromMaster
|
IPBstream fromMaster(Pstream::masterNo()); // == worldComm
|
||||||
(
|
|
||||||
Pstream::commsTypes::scheduled,
|
|
||||||
Pstream::masterNo()
|
|
||||||
);
|
|
||||||
fromMaster >> sharedPointValues;
|
fromMaster >> sharedPointValues;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -640,11 +636,11 @@ void Foam::syncTools::syncEdgeMap
|
|||||||
{
|
{
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
// Receive the edges using shared points from the slave.
|
// Receive the edges using shared points from other procs
|
||||||
for (const int slave : Pstream::subProcs())
|
for (const int proci : Pstream::subProcs())
|
||||||
{
|
{
|
||||||
IPstream fromSlave(Pstream::commsTypes::scheduled, slave);
|
IPstream fromProc(Pstream::commsTypes::scheduled, proci);
|
||||||
EdgeMap<T> nbrValues(fromSlave);
|
EdgeMap<T> nbrValues(fromProc);
|
||||||
|
|
||||||
// Merge neighbouring values with my values
|
// Merge neighbouring values with my values
|
||||||
forAllConstIters(nbrValues, iter)
|
forAllConstIters(nbrValues, iter)
|
||||||
@ -659,11 +655,10 @@ void Foam::syncTools::syncEdgeMap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send back
|
// Broadcast: send merged values to all
|
||||||
for (const int slave : Pstream::subProcs())
|
|
||||||
{
|
{
|
||||||
OPstream toSlave(Pstream::commsTypes::scheduled, slave);
|
OPBstream toAll(Pstream::masterNo()); // == worldComm
|
||||||
toSlave << sharedEdgeValues;
|
toAll << sharedEdgeValues;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -677,13 +672,10 @@ void Foam::syncTools::syncEdgeMap
|
|||||||
);
|
);
|
||||||
toMaster << sharedEdgeValues;
|
toMaster << sharedEdgeValues;
|
||||||
}
|
}
|
||||||
// Receive merged values
|
|
||||||
|
// Broadcast: receive merged values
|
||||||
{
|
{
|
||||||
IPstream fromMaster
|
IPBstream fromMaster(Pstream::masterNo()); // == worldComm
|
||||||
(
|
|
||||||
Pstream::commsTypes::scheduled,
|
|
||||||
Pstream::masterNo()
|
|
||||||
);
|
|
||||||
fromMaster >> sharedEdgeValues;
|
fromMaster >> sharedEdgeValues;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -478,23 +478,22 @@ Foam::autoPtr<Foam::fvMesh> Foam::fvMeshTools::newMesh
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
Pstream::parRun(oldParRun);
|
Pstream::parRun(oldParRun);
|
||||||
|
|
||||||
// Send patches
|
|
||||||
for (const int slave : Pstream::subProcs())
|
|
||||||
{
|
|
||||||
OPstream toSlave(Pstream::commsTypes::scheduled, slave);
|
|
||||||
toSlave << patchEntries;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (Pstream::parRun())
|
||||||
{
|
{
|
||||||
// Receive patches
|
if (Pstream::master())
|
||||||
IPstream fromMaster
|
{
|
||||||
(
|
// Broadcast: send patches to all
|
||||||
Pstream::commsTypes::scheduled,
|
OPBstream toAll(Pstream::masterNo()); // == worldComm
|
||||||
Pstream::masterNo()
|
toAll << patchEntries;
|
||||||
);
|
}
|
||||||
fromMaster >> patchEntries;
|
else
|
||||||
|
{
|
||||||
|
// Broadcast: receive patches
|
||||||
|
IPBstream fromMaster(Pstream::masterNo()); // == worldComm
|
||||||
|
fromMaster >> patchEntries;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Pstream::scatter(facesInstance);
|
Pstream::scatter(facesInstance);
|
||||||
|
|||||||
Reference in New Issue
Block a user