ENH: more consistent naming of MPI reductions
- combineReduce (older: combineAllGather) - listCombineReduce (older: listCombineAllGather) - mapCombineReduce (older: mapCombineAllGather)
This commit is contained in:
parent
39fc7cc957
commit
cbace69896
@ -202,13 +202,14 @@ public:
|
||||
const label comm = UPstream::worldComm
|
||||
);
|
||||
|
||||
//- Gather data, applying \c cop to inplace combine \c value
|
||||
//- Reduce inplace (cf. MPI Allreduce)
|
||||
//- applying \c cop to inplace combine \c value
|
||||
//- from different processors.
|
||||
//- After completion all processors have the same data.
|
||||
// Uses the specified communication schedule.
|
||||
// Wraps combineGather/broadcast (may change in the future).
|
||||
template<class T, class CombineOp>
|
||||
static void combineAllGather
|
||||
static void combineReduce
|
||||
(
|
||||
const List<commsStruct>& comms,
|
||||
T& value,
|
||||
@ -217,19 +218,33 @@ public:
|
||||
const label comm = UPstream::worldComm
|
||||
);
|
||||
|
||||
//- Gather data, applying \c cop to inplace combine \c value
|
||||
//- Reduce inplace (cf. MPI Allreduce)
|
||||
//- applying \c cop to inplace combine \c value
|
||||
//- from different processors.
|
||||
//- After completion all processors have the same data.
|
||||
// Uses linear/tree communication.
|
||||
// Wraps combineGather/broadcast (may change in the future).
|
||||
template<class T, class CombineOp>
|
||||
static void combineReduce
|
||||
(
|
||||
T& value,
|
||||
const CombineOp& cop,
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm
|
||||
);
|
||||
|
||||
//- Same as Pstream::combineReduce
|
||||
template<class T, class CombineOp>
|
||||
static void combineAllGather
|
||||
(
|
||||
T& value,
|
||||
const CombineOp& cop,
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm
|
||||
);
|
||||
)
|
||||
{
|
||||
Pstream::combineReduce(value, cop, tag, comm);
|
||||
}
|
||||
|
||||
|
||||
// Combine variants working on whole List at a time.
|
||||
@ -256,16 +271,15 @@ public:
|
||||
|
||||
//- After completion all processors have the same data.
|
||||
template<class T, class CombineOp>
|
||||
static void listCombineAllGather
|
||||
static void listCombineReduce
|
||||
(
|
||||
const List<commsStruct>& comms,
|
||||
List<T>& values,
|
||||
const CombineOp& cop,
|
||||
const int tag,
|
||||
const label comm
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm
|
||||
);
|
||||
|
||||
//- After completion all processors have the same data.
|
||||
//- Same as Pstream::listCombineReduce
|
||||
template<class T, class CombineOp>
|
||||
static void listCombineAllGather
|
||||
(
|
||||
@ -273,7 +287,10 @@ public:
|
||||
const CombineOp& cop,
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm
|
||||
);
|
||||
)
|
||||
{
|
||||
Pstream::listCombineReduce(values, cop, tag, comm);
|
||||
}
|
||||
|
||||
|
||||
// Combine variants working on whole map at a time.
|
||||
@ -299,19 +316,23 @@ public:
|
||||
const label comm = UPstream::worldComm
|
||||
);
|
||||
|
||||
|
||||
//- Reduce inplace (cf. MPI Allreduce)
|
||||
//- applying \c cop to inplace combine map \c values
|
||||
//- from different processors.
|
||||
//- After completion all processors have the same data.
|
||||
// Uses the specified communication schedule.
|
||||
// Wraps mapCombineGather/broadcast (may change in the future).
|
||||
//- After completion all processors have the same data.
|
||||
template<class Container, class CombineOp>
|
||||
static void mapCombineAllGather
|
||||
static void mapCombineReduce
|
||||
(
|
||||
const List<commsStruct>& comms,
|
||||
Container& values,
|
||||
const CombineOp& cop,
|
||||
const int tag,
|
||||
const label comm
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm
|
||||
);
|
||||
|
||||
//- After completion all processors have the same data.
|
||||
//- Same as Pstream::mapCombineReduce
|
||||
template<class Container, class CombineOp>
|
||||
static void mapCombineAllGather
|
||||
(
|
||||
@ -319,7 +340,10 @@ public:
|
||||
const CombineOp& cop,
|
||||
const int tag = UPstream::msgType(),
|
||||
const label comm = UPstream::worldComm
|
||||
);
|
||||
)
|
||||
{
|
||||
Pstream::mapCombineReduce(values, cop, tag, comm);
|
||||
}
|
||||
|
||||
|
||||
// Gather/scatter keeping the individual processor data separate.
|
||||
@ -347,19 +371,6 @@ public:
|
||||
const label comm = UPstream::worldComm
|
||||
);
|
||||
|
||||
//- Gather data, but keep individual values separate.
|
||||
//- Uses the specified communication schedule.
|
||||
// After completion all processors have the same data.
|
||||
// Wraps gatherList/scatterList (may change in the future).
|
||||
template<class T>
|
||||
static void allGatherList
|
||||
(
|
||||
const List<commsStruct>& comms,
|
||||
List<T>& values,
|
||||
const int tag,
|
||||
const label comm
|
||||
);
|
||||
|
||||
//- Gather data, but keep individual values separate.
|
||||
//- Uses linear/tree communication.
|
||||
// After completion all processors have the same data.
|
||||
|
@ -255,13 +255,19 @@ void Foam::Pstream::combineScatter
|
||||
#ifndef Foam_Pstream_scatter_nobroadcast
|
||||
Pstream::broadcast(value, comm);
|
||||
#else
|
||||
combineScatter(UPstream::whichCommunication(comm), value, tag, comm);
|
||||
Pstream::combineScatter
|
||||
(
|
||||
UPstream::whichCommunication(comm),
|
||||
value,
|
||||
tag,
|
||||
comm
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
template<class T, class CombineOp>
|
||||
void Foam::Pstream::combineAllGather
|
||||
void Foam::Pstream::combineReduce
|
||||
(
|
||||
const List<UPstream::commsStruct>& comms,
|
||||
T& value,
|
||||
@ -276,7 +282,7 @@ void Foam::Pstream::combineAllGather
|
||||
|
||||
|
||||
template<class T, class CombineOp>
|
||||
void Foam::Pstream::combineAllGather
|
||||
void Foam::Pstream::combineReduce
|
||||
(
|
||||
T& value,
|
||||
const CombineOp& cop,
|
||||
@ -526,22 +532,7 @@ void Foam::Pstream::listCombineScatter
|
||||
|
||||
|
||||
template<class T, class CombineOp>
|
||||
void Foam::Pstream::listCombineAllGather
|
||||
(
|
||||
const List<UPstream::commsStruct>& comms,
|
||||
List<T>& values,
|
||||
const CombineOp& cop,
|
||||
const int tag,
|
||||
const label comm
|
||||
)
|
||||
{
|
||||
Pstream::listCombineGather(comms, values, cop, tag, comm);
|
||||
Pstream::broadcast(values, comm);
|
||||
}
|
||||
|
||||
|
||||
template<class T, class CombineOp>
|
||||
void Foam::Pstream::listCombineAllGather
|
||||
void Foam::Pstream::listCombineReduce
|
||||
(
|
||||
List<T>& values,
|
||||
const CombineOp& cop,
|
||||
@ -747,22 +738,7 @@ void Foam::Pstream::mapCombineScatter
|
||||
|
||||
|
||||
template<class Container, class CombineOp>
|
||||
void Foam::Pstream::mapCombineAllGather
|
||||
(
|
||||
const List<UPstream::commsStruct>& comms,
|
||||
Container& values,
|
||||
const CombineOp& cop,
|
||||
const int tag,
|
||||
const label comm
|
||||
)
|
||||
{
|
||||
Pstream::mapCombineGather(comms, values, cop, tag, comm);
|
||||
Pstream::broadcast(values, comm);
|
||||
}
|
||||
|
||||
|
||||
template<class Container, class CombineOp>
|
||||
void Foam::Pstream::mapCombineAllGather
|
||||
void Foam::Pstream::mapCombineReduce
|
||||
(
|
||||
Container& values,
|
||||
const CombineOp& cop,
|
||||
|
@ -9,34 +9,16 @@
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
InClass
|
||||
Foam
|
||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
|
||||
Description
|
||||
Combination-Reduction operation for a parallel run. The
|
||||
information from all nodes is collected on the master node,
|
||||
combined using the given combination function and the result is
|
||||
broadcast to all nodes
|
||||
Compatibility include (AUG-2022).
|
||||
Foam::combineReduce wrapper for Pstream::combineReduce
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Foam_PstreamCombineReduceOps_H
|
||||
#define Foam_PstreamCombineReduceOps_H
|
||||
#ifndef FoamCompat_PstreamCombineReduceOps_H
|
||||
#define FoamCompat_PstreamCombineReduceOps_H
|
||||
|
||||
#include "Pstream.H"
|
||||
#include "ops.H"
|
||||
@ -48,20 +30,7 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class CombineOp>
|
||||
void combineReduce
|
||||
(
|
||||
const List<UPstream::commsStruct>& comms,
|
||||
T& value,
|
||||
const CombineOp& cop,
|
||||
const int tag,
|
||||
const label comm
|
||||
)
|
||||
{
|
||||
Pstream::combineAllGather(comms, value, cop, tag, comm);
|
||||
}
|
||||
|
||||
|
||||
//- Compatibility wrapper for Pstream::combineReduce
|
||||
template<class T, class CombineOp>
|
||||
void combineReduce
|
||||
(
|
||||
@ -71,7 +40,7 @@ void combineReduce
|
||||
const label comm = UPstream::worldComm
|
||||
)
|
||||
{
|
||||
Pstream::combineAllGather(value, cop, tag, comm);
|
||||
Pstream::combineReduce(value, cop, tag, comm);
|
||||
}
|
||||
|
||||
|
||||
|
@ -253,7 +253,7 @@ void Foam::Pstream::scatterList
|
||||
{
|
||||
fromAbove >> values[leafID];
|
||||
|
||||
if (debug)
|
||||
if (debug & 2)
|
||||
{
|
||||
Pout<< " received through "
|
||||
<< myComm.above() << " data for:" << leafID
|
||||
@ -304,7 +304,7 @@ void Foam::Pstream::scatterList
|
||||
{
|
||||
toBelow << values[leafID];
|
||||
|
||||
if (debug)
|
||||
if (debug & 2)
|
||||
{
|
||||
Pout<< " sent through "
|
||||
<< belowID << " data for:" << leafID
|
||||
@ -341,20 +341,6 @@ void Foam::Pstream::scatterList
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::Pstream::allGatherList
|
||||
(
|
||||
const List<UPstream::commsStruct>& comms,
|
||||
List<T>& values,
|
||||
const int tag,
|
||||
const label comm
|
||||
)
|
||||
{
|
||||
Pstream::gatherList(comms, values, tag, comm);
|
||||
Pstream::scatterList(comms, values, tag, comm);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::Pstream::allGatherList
|
||||
(
|
||||
|
@ -35,8 +35,9 @@ Description
|
||||
#ifndef Foam_PstreamReduceOps_H
|
||||
#define Foam_PstreamReduceOps_H
|
||||
|
||||
#include "ops.H"
|
||||
#include "Pstream.H"
|
||||
#include "FixedList.H"
|
||||
#include "ops.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user