Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

Kokkos::MinMax

Christian Trott edited this page May 1, 2020 · 1 revision

Kokkos::MinMax

Specific implementation of ReducerConcept storing both the minimum and maximum values

Header File: Kokkos_Core.hpp

Usage:

MinMax<T,S>::value_type result;
parallel_reduce(N,Functor,MinMax<T,S>(result));

.

Synopsis

template<class Scalar, class Space>
class MinMax{
  public:
    typedef MinMax reducer;
    typedef MinMaxScalar<typename std::remove_cv<Scalar>::type> value_type;
    typedef Kokkos::View<value_type, Space> result_view_type;
    
    KOKKOS_INLINE_FUNCTION
    void join(value_type& dest, const value_type& src)  const

    KOKKOS_INLINE_FUNCTION
    void join(volatile value_type& dest, const volatile value_type& src) const;

    KOKKOS_INLINE_FUNCTION
    void init( value_type& val)  const;

    KOKKOS_INLINE_FUNCTION
    value_type& reference() const;

    KOKKOS_INLINE_FUNCTION
    result_view_type view() const;

    KOKKOS_INLINE_FUNCTION
    MinMax(value_type& value_);

    KOKKOS_INLINE_FUNCTION
    MinMax(const result_view_type& value_);
};

Public Class Members

Typedefs

  • reducer: The self type.
  • value_type: The reduction scalar type (specialization of MinMaxScalar)
  • result_view_type: A Kokkos::View referencing the reduction result

Constructors

  • MinMax(value_type& result)

    Constructs a reducer which references a local variable as its result location.

  • MinMax(const result_view_type result)

    Constructs a reducer which references a specific view as its result location.

Functions

  • void join(value_type& dest, const value_type& src)  const;
    • Store minimum of src and dest into dest: dest.min_val = (src.min_val < dest.min_val) ? src.min_val : dest.min_val;.
    • Store maximum of src and dest into dest: dest.max_val = (src.max_val < dest.max_val) ? src.max_val : dest.max_val;.
  • void join(volatile value_type& dest, const volatile value_type& src) const;
    • Store minimum of src and dest into dest: dest.min_val = (src.min_val < dest.min_val) ? src.min_val : dest.min_val;.
    • Store maximum of src and dest into dest: dest.max_val = (src.max_val < dest.max_val) ? src.max_val : dest.max_val;.
  • void init( value_type& val)  const;

    Initialize val.min_val using the Kokkos::reduction_identity::min() method. The default implementation sets val=<TYPE>_MAX.

    Initialize val.max_val using the Kokkos::reduction_identity::max() method. The default implementation sets val=<TYPE>_MIN.

  • value_type& reference() const;

    Returns a reference to the result provided in class constructor.

  • result_view_type view() const;

    Returns a view of the result place provided in class constructor.

Additional Information

  • MinMax<T,S>::value_type is Specialization of MinMaxScalar on non-const T
  • MinMax<T,S>::result_view_type is Kokkos::View<T,S,Kokkos::MemoryTraits<Kokkos::Unmanaged>>. Note that the S (memory space) must be the same as the space where the result resides.
  • Requires: Scalar has operator =, operator < and operator > defined. Kokkos::reduction_identity<Scalar>::min() and Kokkos::reduction_identity<Scalar>::max() are a valid expressions.
  • In order to use MinMax with a custom type of Scalar, a template specialization of Kokkos::reduction_identity must be defined. See Using Built-in Reducers with Custom Scalar Types for details
Clone this wiki locally