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>
122 template<
class T,
class BinaryOp>
164 #undef Pstream_CommonReductions 165 #define Pstream_CommonReductions(Native) \ 172 const minOp<Native>&, \ 173 const int tag = UPstream::msgType(), \ 174 const label comm = UPstream::worldComm \ 181 const minOp<Native>&, \ 182 const int tag = UPstream::msgType(), \ 183 const label comm = UPstream::worldComm \ 187 template<unsigned N> \ 190 FixedList<Native, N>& values, \ 191 const minOp<Native>&, \ 192 const int tag = UPstream::msgType(), \ 193 const label comm = UPstream::worldComm \ 196 reduce(values.data(), int(values.size()), minOp<Native>(), tag, comm); \ 204 const maxOp<Native>&, \ 213 const maxOp<Native>&, \ 214 const int tag = UPstream::msgType(), \ 215 const label comm = UPstream::worldComm \ 219 template<unsigned N> \ 222 FixedList<Native, N>& values, \ 223 const maxOp<Native>&, \ 224 const int tag = UPstream::msgType(), \ 225 const label comm = UPstream::worldComm \ 228 reduce(values.data(), int(values.size()), maxOp<Native>(), tag, comm); \ 236 const sumOp<Native>&, \ 245 const sumOp<Native>&, \ 246 const int tag = UPstream::msgType(), \ 247 const label comm = UPstream::worldComm \ 251 template<unsigned N> \ 254 FixedList<Native, N>& values, \ 255 const sumOp<Native>&, \ 256 const int tag = UPstream::msgType(), \ 257 const label comm = UPstream::worldComm \ 260 reduce(values.data(), int(values.size()), sumOp<Native>(), tag, comm); \ 268 #undef Pstream_FloatReductions 269 #define Pstream_FloatReductions(Native) \ 271 Pstream_CommonReductions(Native); \ 278 const sumOp<Native>&, \ 288 const sumOp<Native>&, \ 308 #undef Pstream_CommonReductions 309 #undef Pstream_FloatReductions 335 #undef Pstream_SumReduce 336 #define Pstream_SumReduce(Native) \ 343 const int tag = UPstream::msgType(), \ 344 const label comm = UPstream::worldComm \ 351 #undef Pstream_SumReduce 361 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.
static bool & parRun() noexcept
Test if this a parallel run.
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 (cf. 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
Default world communicator (all processors). May differ from globalComm 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 processes in communicator.
#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 (cf. MPI AllReduce)
static void printStack(Ostream &os)
Helper function to print a stack.
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.
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.