Loading...
Searching...
No Matches
UPstreamReduceOffsets.H File Reference
Include dependency graph for UPstreamReduceOffsets.H:

Go to the source code of this file.

Namespaces

namespace  Foam
 Namespace for OpenFOAM.
namespace  Foam::PstreamDetail
 Implementation details for UPstream/Pstream/MPI etc.

Functions

template<class IntType>
void reduce_offsetRange (Foam::OffsetRange< IntType > &range, const int communicator)
template<class IntType, std::size_t... Is, class... OffsetRanges>
void reduce_offsetRanges (const int communicator, std::index_sequence< Is... >, OffsetRanges &... items)
template<class IntType>
void reduceOffset (Foam::OffsetRange< IntType > &range, const int communicator=UPstream::worldComm)
 Parallel reduction of OffsetRange (eg, GlobalOffset) on its size value to yield the globally-consistent offset and the total size across all ranks.
template<class OffsetRangeT, class... Rest, class = std::enable_if_t < ( std::is_integral_v<typename OffsetRangeT::value_type> && std::is_base_of_v <Foam::OffsetRange<typename OffsetRangeT::value_type>, OffsetRangeT> && (std::is_base_of_v <Foam::OffsetRange<typename OffsetRangeT::value_type>, Rest> && ...) )>>
void reduceOffsets (const int communicator, OffsetRangeT &first, Rest &... rest)
 Parallel reduction of multiple OffsetRange (eg, GlobalOffset) items.
template<class OffsetRangeT, class = std::enable_if_t < ( std::is_integral_v<typename OffsetRangeT::value_type> && std::is_base_of_v <Foam::OffsetRange<typename OffsetRangeT::value_type>, OffsetRangeT> )>>
void reduceOffsets (const int communicator, Foam::UList< OffsetRangeT > &ranges)
 Parallel reduction of multiple OffsetRange (eg, GlobalOffset) items.

Detailed Description

Original source file UPstreamReduceOffsets.H

Note
Creating globally consistent offsets and total uses the following process:
  • apply MPI_Exscan(MPI_SUM) using the rank-local size to produce the offsets. Although MPI_Exscan() does not specify what value rank0 will have, our own mpiExscan_sum() does and assigns 0 for rank0.
  • determine the total size as the offset + local size. This value is only correct on the (nProcs-1) rank.
  • broad cast the total size from the (nProcs-1) rank to all ranks.

The reduceOffsets() version uses exactly the same process, except with a work array to bundle/unbundle values and use the same two MPI calls.

Definition in file UPstreamReduceOffsets.H.