35#ifndef Foam_PstreamReduceOps_H
36#define Foam_PstreamReduceOps_H
53template<
class T,
class BinaryOp>
57 [[maybe_unused]] BinaryOp bop,
82 Perr<<
"** reducing:" << value <<
" comm:" << communicator <<
endl;
95template<
class T,
class BinaryOp>
100 [[maybe_unused]] BinaryOp bop,
101 [[maybe_unused]]
const int tag,
127 "only for specific, contiguous, known data types"
135template<
class T,
unsigned N,
class BinaryOp>
144 reduce(values.data(),
int(values.size()), bop, tag, communicator);
150template<
class T,
class BinaryOp>
155 [[maybe_unused]] BinaryOp bop,
156 [[maybe_unused]]
const int tag,
157 const int communicator,
184 "only for specific, contiguous, known data types"
192template<
class T,
class BinaryOp>
198 const int communicator,
203 reduce(&value, 1, tag, communicator, req);
239template<
class T,
class CountType =
int>
250 static_assert(std::is_arithmetic_v<CountType>,
"Counter not arithmetic");
257 else if constexpr (std::is_floating_point_v<T>)
262 work[1] =
static_cast<T>(count);
274 count =
static_cast<CountType
>(work[1]);
279 && std::is_floating_point_v<typename pTraits_cmptType<T>::type>
288 work[nCmpts] =
static_cast<cmpt
>(
count);
300 count =
static_cast<CountType
>(work[nCmpts]);
316template<
class T,
class BinaryOp>
A 1D vector of objects of type <T> with a fixed length <N>.
An opaque wrapper for MPI_Request with a vendor-independent representation without any <mpi....
static label warnComm
Debugging: warn for use of any communicator differing from warnComm.
static int & msgType() noexcept
Message tag of standard messages.
static void reduceAnd(bool &value, const int communicator=worldComm)
Logical (and) reduction (MPI_AllReduce).
static void mpiAllReduce(T values[], int count, const UPstream::opCodes opCodeId, const int communicator)
MPI_Allreduce (blocking) for known operators.
static void reduceOr(bool &value, const int communicator=worldComm)
Logical (or) reduction (MPI_AllReduce).
static bool is_parallel(const label communicator=worldComm)
True if parallel algorithm or exchange is required.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
@ gather
gather/all-gather [MPI]
@ broadcast
broadcast [MPI]
static void printStack(Ostream &os, int size=-1)
Helper function to print a stack, with optional upper limit.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Ostream & endl(Ostream &os)
Add newline and flush stream.
constexpr bool is_vectorspace_v
The is_vectorspace value of Type.
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
bool returnReduceAnd(const bool value, const int communicator=UPstream::worldComm)
Perform logical (and) MPI Allreduce on a copy. Uses UPstream::reduceAnd.
void sumReduce(T &value, CountType &count, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) the sum of value and counter (eg, for averaging).
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
constexpr bool dependent_false_v
Map any dependent type to false (workaround before CWG2518).
Various functors for unary and binary operations. Can be used for parallel combine-reduce operations ...
Combined query of opType and the underlying basic data type.
static constexpr auto opcode_id
static void copy_n(Input input, Output result)
Somewhat equivalent to std::copy_n() but with templated loops.
The vector-space number of components: default is 1.