35 #ifndef Foam_PstreamReduceOps_H 36 #define Foam_PstreamReduceOps_H 51 template<
class T,
class BinaryOp>
63 Pout<<
"** reducing:" << value <<
" with comm:" << comm <<
endl;
73 template<
class T,
class BinaryOp>
91 template<
class T,
class BinaryOp>
106 template<
class T,
class BinaryOp>
121 template<
class T,
class BinaryOp>
136 template<
class T,
class BinaryOp>
152 template<
class T,
class BinaryOp>
194 #undef Pstream_CommonReductions 195 #define Pstream_CommonReductions(Native) \ 202 const minOp<Native>&, \ 203 const int tag = UPstream::msgType(), \ 204 const label comm = UPstream::worldComm \ 211 const minOp<Native>&, \ 212 const int tag = UPstream::msgType(), \ 213 const label comm = UPstream::worldComm \ 217 template<unsigned N> \ 220 FixedList<Native, N>& values, \ 221 const minOp<Native>&, \ 222 const int tag = UPstream::msgType(), \ 223 const label comm = UPstream::worldComm \ 226 reduce(values.data(), int(values.size()), minOp<Native>(), tag, comm); \ 234 const maxOp<Native>&, \ 243 const maxOp<Native>&, \ 244 const int tag = UPstream::msgType(), \ 245 const label comm = UPstream::worldComm \ 249 template<unsigned N> \ 252 FixedList<Native, N>& values, \ 253 const maxOp<Native>&, \ 254 const int tag = UPstream::msgType(), \ 255 const label comm = UPstream::worldComm \ 258 reduce(values.data(), int(values.size()), maxOp<Native>(), tag, comm); \ 266 const sumOp<Native>&, \ 275 const sumOp<Native>&, \ 276 const int tag = UPstream::msgType(), \ 277 const label comm = UPstream::worldComm \ 281 template<unsigned N> \ 284 FixedList<Native, N>& values, \ 285 const sumOp<Native>&, \ 286 const int tag = UPstream::msgType(), \ 287 const label comm = UPstream::worldComm \ 290 reduce(values.data(), int(values.size()), sumOp<Native>(), tag, comm); \ 298 #undef Pstream_FloatReductions 299 #define Pstream_FloatReductions(Native) \ 301 Pstream_CommonReductions(Native); \ 308 const sumOp<Native>&, \ 311 UPstream::Request& req \ 320 const sumOp<Native>&, \ 330 const sumOp<Native>&, \ 333 UPstream::Request& req \ 341 const sumOp<Native>&, \ 352 #undef Pstream_BitwiseReductions 353 #define Pstream_BitwiseReductions(Native) \ 360 const bitOrOp<Native>&, \ 361 const int tag = UPstream::msgType(), \ 362 const label comm = UPstream::worldComm \ 369 const bitOrOp<Native>&, \ 370 const int tag = UPstream::msgType(), \ 371 const label comm = UPstream::worldComm \ 390 #undef Pstream_CommonReductions 391 #undef Pstream_FloatReductions 392 #undef Pstream_BitwiseReductions 418 #undef Pstream_SumReduce 419 #define Pstream_SumReduce(Native) \ 426 const int tag = UPstream::msgType(), \ 427 const label comm = UPstream::worldComm \ 434 #undef Pstream_SumReduce 444 template<
class T,
class BinaryOp>
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
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 const List< commsStruct > & whichCommunication(const label communicator=worldComm)
Communication schedule for linear/tree all-to-master (proc 0). Chooses based on the value of UPstream...
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)
static void gather(const List< commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Gather (reduce) data, appyling bop to combine value from different processors. The basis for Foam::re...
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.
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 independent of 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)
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
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.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.