LastLoc¶
Specific implementation of ReducerConcept storing the last index satisfying a condition.
Header File: <Kokkos_Core.hpp>
Usage¶
LastLoc<I,S>::value_type result;
parallel_reduce(N,Functor,LastLoc<I,S>(result));
Synopsis¶
template<class Index, class Space>
class LastLoc{
public:
using reducer = LastLoc;
using value_type = LastLocScalar<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
LastLoc(value_type& value_);
KOKKOS_INLINE_FUNCTION
LastLoc(const result_view_type& value_);
};
Interface¶
-
template<class Index, class Space>
class LastLoc¶ Public Types
-
type reducer¶
The self type.
-
type value_type¶
The reduction scalar type (specialization of LastLocScalar)
-
type result_view_type¶
A
Kokkos::Viewreferencing the reduction result
Constructors
-
KOKKOS_INLINE_FUNCTION LastLoc(value_type &value_);¶
Constructs a reducer which references a local variable as its result location.
-
KOKKOS_INLINE_FUNCTION LastLoc(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 last index of
srcanddestintodest:dest = (src.max_loc_true > dest.max_loc_true) ? src :dest;.
-
KOKKOS_INLINE_FUNCTION void init(value_type &val) const;¶
Initialize
val.max_loc_trueusing theKokkos::reduction_identity<Index>::max()method. The default implementation setsval=<TYPE>_MIN.
-
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.
-
type reducer¶
Additional Information¶
LastLoc<I,S>::result_view_typeisKokkos::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:
Indexhasoperator =defined.Kokkos::reduction_identity<Index>::max()is a valid expression.In order to use
LastLocwith a custom type ofIndex, a template specialization ofKokkos::reduction_identity<CustomType>must be defined. See Built-In Reducers with Custom Scalar Types for details