35 #ifndef Foam_PstreamReduceOps_H 36 #define Foam_PstreamReduceOps_H 51 template<
class T,
class BinaryOp>
64 Perr<<
"** reducing:" << value <<
" with comm:" << comm <<
endl;
75 template<
class T,
class BinaryOp>
90 template<
class T,
class BinaryOp>
105 template<
class T,
class BinaryOp>
120 template<
class T,
class BinaryOp>
136 template<
class T,
class BinaryOp>
178 #undef Pstream_CommonReductions 179 #define Pstream_CommonReductions(Native) \ 186 const minOp<Native>&, \ 187 const int tag = UPstream::msgType(), \ 188 const label comm = UPstream::worldComm \ 195 const minOp<Native>&, \ 196 const int tag = UPstream::msgType(), \ 197 const label comm = UPstream::worldComm \ 201 template<unsigned N> \ 204 FixedList<Native, N>& values, \ 205 const minOp<Native>&, \ 206 const int tag = UPstream::msgType(), \ 207 const label comm = UPstream::worldComm \ 210 reduce(values.data(), int(values.size()), minOp<Native>(), tag, comm); \ 218 const maxOp<Native>&, \ 227 const maxOp<Native>&, \ 228 const int tag = UPstream::msgType(), \ 229 const label comm = UPstream::worldComm \ 233 template<unsigned N> \ 236 FixedList<Native, N>& values, \ 237 const maxOp<Native>&, \ 238 const int tag = UPstream::msgType(), \ 239 const label comm = UPstream::worldComm \ 242 reduce(values.data(), int(values.size()), maxOp<Native>(), tag, comm); \ 250 const sumOp<Native>&, \ 259 const sumOp<Native>&, \ 260 const int tag = UPstream::msgType(), \ 261 const label comm = UPstream::worldComm \ 265 template<unsigned N> \ 268 FixedList<Native, N>& values, \ 269 const sumOp<Native>&, \ 270 const int tag = UPstream::msgType(), \ 271 const label comm = UPstream::worldComm \ 274 reduce(values.data(), int(values.size()), sumOp<Native>(), tag, comm); \ 282 #undef Pstream_FloatReductions 283 #define Pstream_FloatReductions(Native) \ 285 Pstream_CommonReductions(Native); \ 292 const sumOp<Native>&, \ 295 UPstream::Request& req \ 304 const sumOp<Native>&, \ 314 const sumOp<Native>&, \ 317 UPstream::Request& req \ 325 const sumOp<Native>&, \ 336 #undef Pstream_BitwiseReductions 337 #define Pstream_BitwiseReductions(Native) \ 344 const bitOrOp<Native>&, \ 345 const int tag = UPstream::msgType(), \ 346 const label comm = UPstream::worldComm \ 353 const bitOrOp<Native>&, \ 354 const int tag = UPstream::msgType(), \ 355 const label comm = UPstream::worldComm \ 374 #undef Pstream_CommonReductions 375 #undef Pstream_FloatReductions 376 #undef Pstream_BitwiseReductions 402 #undef Pstream_SumReduce 403 #define Pstream_SumReduce(Native) \ 410 const int tag = UPstream::msgType(), \ 411 const label comm = UPstream::worldComm \ 418 #undef Pstream_SumReduce 427 template<
class T,
class BinaryOp>
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
void sumReduce(T &value, label &count, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) the sum of both value and count (for averaging) ...
Ostream & endl(Ostream &os)
Add newline and flush stream.
Various functors for unary and binary operations. Can be used for parallel combine-reduce operations ...
static void reduceOr(bool &value, const label communicator=worldComm)
Logical (or) reduction (MPI_AllReduce)
static int & msgType() noexcept
Message tag of standard messages.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all communicator ranks. Does nothing in non-paral...
#define Pstream_FloatReductions(Native)
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
static void gather(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Gather (reduce) data, applying bop to combine value from different processors. The basis for Foam::re...
bool returnReduceAnd(const bool value, const label comm=UPstream::worldComm)
Perform logical (and) MPI Allreduce on a copy. Uses UPstream::reduceAnd.
static void reduceAnd(bool &value, const label communicator=worldComm)
Logical (and) reduction (MPI_AllReduce)
#define Pstream_BitwiseReductions(Native)
An opaque wrapper for MPI_Request with a vendor-independent representation without any <mpi...
static bool is_parallel(const label communicator=worldComm)
True if parallel algorithm or exchange is required.
static label warnComm
Debugging: warn for use of any communicator differing from warnComm.
#define Pstream_CommonReductions(Native)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
#define Pstream_SumReduce(Native)
static void printStack(Ostream &os, int size=-1)
Helper function to print a stack, with optional upper limit.
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
void reduce(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) using linear/tree communication schedule.