KaMPIng 0.2.1
(Near) zero-overhead MPI wrapper for C++
Loading...
Searching...
No Matches
reduce_ops.hpp File Reference

MPI reduction operation functor vocabulary, type traits, and RAII handle. More...

#include <algorithm>
#include <functional>
#include <limits>
#include <type_traits>
#include <mpi.h>
#include "kamping/kassert/kassert.hpp"
#include "kamping/types/builtin_types.hpp"
Include dependency graph for reduce_ops.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  kamping::ops::internal::max_impl< T >
 Wrapper struct for std::max. More...
 
struct  kamping::ops::internal::max_impl< void >
 Template specialization of max_impl without type parameter, leaving the operand type to be deduced. More...
 
struct  kamping::ops::internal::min_impl< T >
 Wrapper struct for std::min (same rationale as max_impl). More...
 
struct  kamping::ops::internal::min_impl< void >
 Template specialization of min_impl without type parameter, leaving the operand type to be deduced. More...
 
struct  kamping::ops::internal::logical_xor_impl< T >
 Logical XOR function object (no STL equivalent). More...
 
struct  kamping::ops::internal::logical_xor_impl< void >
 Template specialization of logical_xor_impl without type parameter, leaving operand types to be deduced. More...
 
struct  kamping::ops::internal::commutative_tag
 Tag for a commutative user-defined reduce operation. More...
 
struct  kamping::ops::internal::non_commutative_tag
 Tag for a non-commutative user-defined reduce operation. More...
 
struct  kamping::ops::internal::undefined_commutative_tag
 Tag for a reduce operation without a manually declared commutativity (builtin ops only). More...
 
struct  kamping::ops::null< T >
 Null operation (MPI_OP_NULL). More...
 
struct  kamping::types::mpi_operation_traits< Op, T >
 Type trait that maps a (functor type, element type) pair to its builtin MPI_Op. More...
 
class  kamping::types::ScopedOp
 RAII wrapper for an MPI_Op. More...
 
class  kamping::types::ScopedFunctorOp< is_commutative, T, Op >
 RAII handle that creates an MPI_Op from a default-constructible C++ functor. More...
 
class  kamping::types::ScopedCallbackOp< is_commutative >
 RAII handle that creates an MPI_Op from a raw MPI callback function pointer. More...
 

Typedefs

template<typename T = void>
using kamping::ops::max = kamping::ops::internal::max_impl<T>
 Builtin maximum operation (MPI_MAX).
 
template<typename T = void>
using kamping::ops::min = kamping::ops::internal::min_impl<T>
 Builtin minimum operation (MPI_MIN).
 
template<typename T = void>
using kamping::ops::plus = std::plus<T>
 Builtin summation (MPI_SUM).
 
template<typename T = void>
using kamping::ops::multiplies = std::multiplies<T>
 Builtin multiplication (MPI_PROD).
 
template<typename T = void>
using kamping::ops::logical_and = std::logical_and<T>
 Builtin logical AND (MPI_LAND).
 
template<typename T = void>
using kamping::ops::bit_and = std::bit_and<T>
 Builtin bitwise AND (MPI_BAND).
 
template<typename T = void>
using kamping::ops::logical_or = std::logical_or<T>
 Builtin logical OR (MPI_LOR).
 
template<typename T = void>
using kamping::ops::bit_or = std::bit_or<T>
 Builtin bitwise OR (MPI_BOR).
 
template<typename T = void>
using kamping::ops::logical_xor = kamping::ops::internal::logical_xor_impl<T>
 Builtin logical XOR (MPI_LXOR).
 
template<typename T = void>
using kamping::ops::bit_xor = std::bit_xor<T>
 Builtin bitwise XOR (MPI_BXOR).
 

Functions

template<typename Functor >
auto kamping::types::with_operation_functor (MPI_Op op, Functor &&func)
 Calls func with the functor object corresponding to the given builtin MPI_Op.
 

Variables

constexpr internal::commutative_tag kamping::ops::commutative {}
 Tag: operation is commutative.
 
constexpr internal::non_commutative_tag kamping::ops::non_commutative {}
 Tag: operation is non-commutative.
 

Detailed Description

MPI reduction operation functor vocabulary, type traits, and RAII handle.

Provides:

Function Documentation

◆ with_operation_functor()

template<typename Functor >
auto kamping::types::with_operation_functor ( MPI_Op op,
Functor && func )

Calls func with the functor object corresponding to the given builtin MPI_Op.

For unknown ops, calls func(kamping::ops::null<>{}). Useful for implementing MPI_Reduce_local-style helpers that need a C++ callable for a runtime MPI_Op.

Template Parameters
FunctorCallable accepting any kamping::ops::* functor type.