Reduction operations#
Overview#
MPL supports various communication operations that perform a reduction operation over all processes within a communicator. The reduction operation is passed as an argument to the communicator class method that realizes to communication operation. The reduction operation can be given by a user-defined two-arguments functor class, a lambda function, e.g.,
comm.reduce([](auto a, auto b) { return a + b; }, ...);
or by any of the template classes as documented below.
Class documentation#
Maximum#
Perform the reduction operation
-
template<typename T>
struct max# Function object for calculating the maximum of two values in reduction operations as
communicator::reduce
.- Template Parameters:
T – data type of the reduction operation’s arguments and its result
Minimum#
Perform the reduction operation
-
template<typename T>
struct min# Function object for calculating the minimum of two values in reduction operations as
communicator::reduce
.- Template Parameters:
T – data type of the reduction operation’s arguments and its result
Addition#
Perform the reduction operation
-
template<typename T>
struct plus# Function object for calculating the sum of two values in reduction operations as communicator::reduce.
- Template Parameters:
T – data type of the reduction operation’s arguments and its result
Multiplication#
Perform the reduction operation
-
template<typename T>
struct multiplies# Function object for calculating the product of two values in reduction operations as
communicator::reduce
.- Template Parameters:
T – data type of the reduction operation’s arguments and its result
Logical conjunction#
Perform the reduction operation
-
template<typename T>
struct logical_and# Function object for calculating the logical conjunction of two values in reduction operations as
communicator::reduce
.- Template Parameters:
T – data type of the reduction operation’s arguments and its result
Logical disjunction#
Perform the reduction operation
-
template<typename T>
struct logical_or# Function object for calculating the logical (inclusive) disjunction of two values in reduction operations as
communicator::reduce
.- Template Parameters:
T – data type of the reduction operation’s arguments and its result
Exclusive disjunction#
Perform the reduction operation
-
template<typename T>
struct logical_xor# Function object for calculating the logical exclusive disjunction of two values in reduction operations as
communicator::reduce
.- Template Parameters:
T – data type of the reduction operation’s arguments and its result
Bitwise and#
Perform for integer arguments the bitwise reduction operation
-
template<typename T>
struct bit_and# Function object for calculating the bitwise conjunction of two values in reduction operations as
communicator::reduce
.- Template Parameters:
T – data type of the reduction operation’s arguments and its result
Bitwise or#
Perform for integer arguments the bitwise reduction operation
-
template<typename T>
struct bit_or# Function object for calculating the bitwise (inclusive) disjunction of two values in reduction operations as
communicator::reduce
.- Template Parameters:
T – data type of the reduction operation’s arguments and its result
Bitwise exclusive-or#
Perform for integer arguments the bitwise reduction operation
-
template<typename T>
struct bit_xor# Function object for calculating the bitwise exclusive disjunction of two values in reduction operations as
communicator::reduce
.- Template Parameters:
T – data type of the reduction operation’s arguments and its result
Operator traits#
The application of some reduction operations can be performed more efficiently by exploiting the commutativity properties of the employed reduction operation. Partial template specializations of the class mpl::op_traits
provide information about the commutativity properties of the reduction operation. Users may provide further user-defined specializations of mpl::op_traits
for user-defined operators.
-
template<typename F>
struct op_traits# Traits class for storing meta information about reduction operations.
- Template Parameters:
F – function object type
Public Static Attributes
-
static constexpr bool is_commutative = false#
Is true if reduction operation specified in the template parameter
F
is commutative.
-
template<typename T>
struct op_traits<max<T>># Specialization of traits class
op_traits
for storing meta information about themax
reduction operation.
-
template<typename T>
struct op_traits<min<T>># Specialization of traits class
op_traits
for storing meta information about themin
reduction operation.
-
template<typename T>
struct op_traits<plus<T>># Specialization of traits class
op_traits
for storing meta information about theplus
reduction operation.
-
template<typename T>
struct op_traits<multiplies<T>># Specialization of traits class
op_traits
for storing meta information about themultiplies
reduction operation.Public Static Attributes
-
static constexpr bool is_commutative = true#
The
multiplies
reduction operation is commutative.
-
static constexpr bool is_commutative = true#
-
template<typename T>
struct op_traits<logical_and<T>># Specialization of traits class
op_traits
for storing meta information about thelogical_and
reduction operation.Public Static Attributes
-
static constexpr bool is_commutative = true#
The
logical_and
reduction operation is commutative.
-
static constexpr bool is_commutative = true#
-
template<typename T>
struct op_traits<logical_or<T>># Specialization of traits class
op_traits
for storing meta information about thelogical_or
reduction operation.Public Static Attributes
-
static constexpr bool is_commutative = true#
The
logical_or
reduction operation is commutative.
-
static constexpr bool is_commutative = true#
-
template<typename T>
struct op_traits<logical_xor<T>># Specialization of traits class
op_traits
for storing meta information about thelogical_xor
reduction operation.Public Static Attributes
-
static constexpr bool is_commutative = true#
The
logical_xor
reduction operation is commutative.
-
static constexpr bool is_commutative = true#
-
template<typename T>
struct op_traits<bit_and<T>># Specialization of traits class
op_traits
for storing meta information about thebit_and
reduction operation.