mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: broadcast for Foam::scatter() instead of manual tree communication
- use MPI_Bcast intrinsic instead of manual tree to reduce the overall
number of messages.
Old behaviour can be re-enabled with
`#define Foam_Pstream_scatter_nobroadcast`
This commit is contained in:
committed by
Andrew Heather
parent
8478595a15
commit
d37cb64efe
@ -45,6 +45,9 @@ SourceFiles
|
|||||||
#include "UPstream.H"
|
#include "UPstream.H"
|
||||||
#include "DynamicList.H"
|
#include "DynamicList.H"
|
||||||
|
|
||||||
|
// Legacy
|
||||||
|
// #define Foam_Pstream_scatter_nobroadcast
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
|
|||||||
@ -32,9 +32,7 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "UOPstream.H"
|
|
||||||
#include "OPstream.H"
|
#include "OPstream.H"
|
||||||
#include "UIPstream.H"
|
|
||||||
#include "IPstream.H"
|
#include "IPstream.H"
|
||||||
#include "contiguous.H"
|
#include "contiguous.H"
|
||||||
|
|
||||||
@ -147,6 +145,34 @@ void Pstream::scatter
|
|||||||
const label comm
|
const label comm
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
#ifndef Foam_Pstream_scatter_nobroadcast
|
||||||
|
if (UPstream::parRun() && UPstream::nProcs(comm) > 1)
|
||||||
|
{
|
||||||
|
if (is_contiguous<T>::value)
|
||||||
|
{
|
||||||
|
UPstream::broadcast
|
||||||
|
(
|
||||||
|
reinterpret_cast<char*>(&Value),
|
||||||
|
sizeof(T),
|
||||||
|
comm,
|
||||||
|
UPstream::masterNo()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (UPstream::master(comm))
|
||||||
|
{
|
||||||
|
OPBstream toAll(UPstream::masterNo(), comm);
|
||||||
|
toAll << Value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IPBstream fromMaster(UPstream::masterNo(), comm);
|
||||||
|
fromMaster >> Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (UPstream::parRun() && UPstream::nProcs(comm) > 1)
|
if (UPstream::parRun() && UPstream::nProcs(comm) > 1)
|
||||||
{
|
{
|
||||||
// Get my communication order
|
// Get my communication order
|
||||||
@ -212,6 +238,7 @@ void Pstream::scatter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user