MinMaxLoc¶
Specific implementation of ReducerConcept storing both the minimum and maximum values with corresponding indices
Header File: <Kokkos_Core.hpp>
Usage¶
MinMaxLoc<T,I,S>::value_type result;
parallel_reduce(N,Functor,MinMaxLoc<T,I,S>(result));
Synopsis¶
template<class Scalar, class Space>
class MinMaxLoc{
public:
typedef MinMaxLoc reducer;
typedef MinMaxLocScalar<typename std::remove_cv<Scalar>::type,
typename std::remove_cv<Index>::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 init(value_type& val) const;
KOKKOS_INLINE_FUNCTION
value_type& reference() const;
KOKKOS_INLINE_FUNCTION
result_view_type view() const;
KOKKOS_INLINE_FUNCTION
MinMaxLoc(value_type& value_);
KOKKOS_INLINE_FUNCTION
MinMaxLoc(const result_view_type& value_);
};
Interface¶
-
template<class Scalar, class Space>
class MinMaxLoc¶ Public Types
-
type reducer¶
The self type
-
type value_type¶
The reduction scalar type (specialization of MinMaxLocScalar)
-
type result_view_type¶
A
Kokkos::Viewreferencing the reduction result
Constructors
-
KOKKOS_INLINE_FUNCTION MinMaxLoc(value_type &value_);¶
Constructs a reducer which references a local variable as its result location.
-
KOKKOS_INLINE_FUNCTION MinMaxLoc(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 minimum with location of
srcanddestintodest. Store maximum with location ofsrcanddestintodest.
-
KOKKOS_INLINE_FUNCTION void init(value_type &val) const;¶
Initialize
val.min_valusing theKokkos::reduction_identity<Scalar>::min()method. The default implementation setsval=<TYPE>_MAX.Initialize
val.max_valusing theKokkos::reduction_identity<Index>::max()method. The default implementation setsval=<TYPE>_MIN.Initialize
val.min_locusing theKokkos::reduction_identity<Scalar>::min()method. The default implementation setsval=<TYPE>_MAX.Initialize
val.max_locusing theKokkos::reduction_identity<Index>::max()method. The default implementation setsval=<TYPE>_MAX.
-
KOKKOS_INLINE_FUNCTION value_type &reference() const;¶
Returns a reference to the result provided in class constructor.
-
KOKKOS_INLINE_FUNCTION result_view_type view() const;¶
Returns a view of the result place provided in class constructor.
-
type reducer¶
Additional Information¶
MinMaxLoc<T,I,S>::value_typeis Specialization of MinMaxLocScalar on non-constTand non-constIMinMaxLoc<T,I,S>::result_view_typeisKokkos::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:
Scalarhasoperator =,operator <andoperator >defined.Kokkos::reduction_identity<Scalar>::min()andKokkos::reduction_identity<Scalar>::max()are a valid expressions.Requires:
Indexhasoperator =defined.Kokkos::reduction_identity<Scalar>::min()is a valid expressions.In order to use MinMaxLoc with a custom type of either
ScalarorIndex, a template specialization ofKokkos::reduction_identity<CustomType>must be defined. See Built-In Reducers with Custom Scalar Types for details.