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::Viewreferencing 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
srcanddestintodest:dest = (src.min_loc_true < dest.min_loc_true) ? src :dest;.
-
KOKKOS_INLINE_FUNCTION void init(value_type &val) const;¶
Initialize
val.min_loc_trueusing theKokkos::reduction_identity<Index>::min()method. The default implementation setsval=<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.
-
type reducer¶
Additional Information¶
FirstLoc<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>::min()is a valid expression.In order to use
FirstLocwith a custom type ofIndex, a template specialization ofKokkos::reduction_identity<CustomType>must be defined. See Built-In Reducers with Custom Scalar Types for details