FirstLoc

Specific implementation of ReducerConcept storing the first index satisfying a condition.

Header File: <Kokkos_Core.hpp>

Usage

FirstLoc<I,S>::value_type result;
parallel_reduce(N,Functor,FirstLoc<I,S>(result));

Synopsis

template<class Index, class Space>
class FirstLoc{
  public:
    using reducer = FirstLoc;
    using value_type = FirstLocScalar<typename std::remove_cv<Index>::type>;
    using result_view_type = Kokkos::View<value_type, Space>;

    KOKKOS_INLINE_FUNCTION
    void join(value_type& dest, const 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
    FirstLoc(value_type& value_);

    KOKKOS_INLINE_FUNCTION
    FirstLoc(const result_view_type& value_);
};

Interface

template<class Index, class Space>
class FirstLoc

Public Types

type reducer

The self type.

type value_type

The reduction scalar type (specialization of FirstLocScalar)

type result_view_type

A Kokkos::View referencing the reduction result

Constructors

KOKKOS_INLINE_FUNCTION FirstLoc(value_type &value_);

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

KOKKOS_INLINE_FUNCTION FirstLoc(const result_view_type &value_);

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

Public Member Functions

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

Store maximum with the first index of src and dest into dest: dest = (src.min_loc_true < dest.min_loc_true) ? src :dest;.

KOKKOS_INLINE_FUNCTION void init(value_type &val) const;

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

KOKKOS_INLINE_FUNCTION value_type &reference() const;

Returns a reference to the result provided in the class constructor.

KOKKOS_INLINE_FUNCTION result_view_type view() const;

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

Additional Information

  • FirstLoc<I,S>::result_view_type is Kokkos::View<I,S,Kokkos::MemoryTraits<Kokkos::Unmanaged>>. Note that the S (memory space) must be the same as the space where the result resides.

  • Requires: Index has operator = defined. Kokkos::reduction_identity<Index>::min() is a valid expression.

  • In order to use FirstLoc with a custom type of Index, a template specialization of Kokkos::reduction_identity<CustomType> must be defined. See Built-In Reducers with Custom Scalar Types for details