COMP: native MPI reduce not triggered (fixes #2569)
- define returnReduce *after* defining all specializations for reduce so that the compiler does not take the generic templated reduce. ENH: add UPstream::reduceAnd, UPstream::reduceOr - direct wrapper of MPI_LAND, MPI_LOR intrinsics ENH: provide special purpose returnReduce for logical operations - returnReduceAnd(bool), returnReduceOr(bool) as a inline wrappers for returnReduce with andOp<bool>(), orOp<bool>() operators, respectively. These forms are more succinct and force casting of the parameter into a bool. Using MPI bool operations allows vendor/hardware MPI optimisations. * Test for existence on any rank: 1. if (returnReduceOr(list.size()) { ... } 1b. if (returnReduceOr(!list.empty()) { ... } 2. if (returnReduce(bool(list.size(), orOp<bool>())) { ... } 3. if (returnReduce(list.size(), sumOp<label>()) != 0) { ... } 3b. if (returnReduce(list.size(), sumOp<label>()) > 0) { ... } * Test for non-existence on all ranks: 1. if (returnReduceAnd(list.empty()) { ... } 1b. if (!returnReduceOr(list.size()) { ... } 2. if (returnReduce(list.empty(), andOp<bool>())) { ... } 3. if (returnReduce(list.size(), sumOp<label>()) == 0) { ... } Notes: Form 1. succinct Form 2. may require explicit bool() for correct dispatch Form 3. more expensive sumOp<label> just for testing size! There are also some places using maxOp<label> instead of sumOp<label>
Showing
- src/OpenFOAM/db/IOstreams/Pstreams/PstreamGather.C 1 addition, 1 deletionsrc/OpenFOAM/db/IOstreams/Pstreams/PstreamGather.C
- src/OpenFOAM/db/IOstreams/Pstreams/PstreamReduceOps.H 112 additions, 61 deletionssrc/OpenFOAM/db/IOstreams/Pstreams/PstreamReduceOps.H
- src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H 17 additions, 0 deletionssrc/OpenFOAM/db/IOstreams/Pstreams/UPstream.H
- src/Pstream/dummy/UPstreamReduce.C 31 additions, 21 deletionssrc/Pstream/dummy/UPstreamReduce.C
- src/Pstream/mpi/UPstreamAllToAll.C 0 additions, 1 deletionsrc/Pstream/mpi/UPstreamAllToAll.C
- src/Pstream/mpi/UPstreamGatherScatter.C 0 additions, 1 deletionsrc/Pstream/mpi/UPstreamGatherScatter.C
- src/Pstream/mpi/UPstreamReduce.C 52 additions, 41 deletionssrc/Pstream/mpi/UPstreamReduce.C
Please register or sign in to comment