30 #ifndef HIBCUB_ROCPRIM_THREAD_THREAD_OPERATORS_HPP_
31 #define HIBCUB_ROCPRIM_THREAD_THREAD_OPERATORS_HPP_
33 #include "../../../config.hpp"
35 #include "../util_type.hpp"
37 BEGIN_HIPCUB_NAMESPACE
42 HIPCUB_HOST_DEVICE
inline
43 constexpr
bool operator()(
const T& a,
const T& b)
const
52 HIPCUB_HOST_DEVICE
inline
53 constexpr
bool operator()(
const T& a,
const T& b)
const
59 template <
class EqualityOp>
64 HIPCUB_HOST_DEVICE
inline
68 HIPCUB_HOST_DEVICE
inline
69 bool operator()(
const T &a,
const T &b)
78 HIPCUB_HOST_DEVICE
inline
79 constexpr T operator()(
const T &a,
const T &b)
const
88 HIPCUB_HOST_DEVICE
inline
89 constexpr T operator()(
const T &a,
const T &b)
const
98 HIPCUB_HOST_DEVICE
inline
99 constexpr T operator()(
const T &a,
const T &b)
const
108 HIPCUB_HOST_DEVICE
inline
109 constexpr T operator()(
const T &a,
const T &b)
const
111 return a < b ? b : a;
118 HIPCUB_HOST_DEVICE
inline
119 constexpr T operator()(
const T &a,
const T &b)
const
121 return a < b ? a : b;
131 HIPCUB_HOST_DEVICE
inline
132 constexpr KeyValuePair<Key, Value>
133 operator()(
const KeyValuePair<Key, Value>& a,
134 const KeyValuePair<Key, Value>& b)
const
136 return ((b.value > a.value) || ((a.value == b.value) && (b.key < a.key))) ? b : a;
146 HIPCUB_HOST_DEVICE
inline
147 constexpr KeyValuePair<Key, Value>
148 operator()(
const KeyValuePair<Key, Value>& a,
149 const KeyValuePair<Key, Value>& b)
const
151 return ((b.value < a.value) || ((a.value == b.value) && (b.key < a.key))) ? b : a;
155 template <
typename B>
158 template <
typename A>
159 HIPCUB_HOST_DEVICE
inline
160 B operator()(
const A &a)
const
166 template <
typename ScanOp>
173 HIPCUB_HOST_DEVICE
inline
178 template <
typename T>
179 HIPCUB_HOST_DEVICE
inline
180 T operator()(
const T &a,
const T &b)
185 return scan_op(_b, _a);
189 template <
typename ReductionOpT>
194 HIPCUB_HOST_DEVICE
inline
199 HIPCUB_HOST_DEVICE
inline
204 template <
typename KeyValuePairT>
205 HIPCUB_HOST_DEVICE
inline
206 KeyValuePairT operator()(
207 const KeyValuePairT &first,
208 const KeyValuePairT &second)
210 KeyValuePairT retval;
211 retval.key = first.key + second.key;
212 retval.value = (second.key) ?
214 op(first.value, second.value);
219 template <
typename ReductionOpT>
224 HIPCUB_HOST_DEVICE
inline
229 HIPCUB_HOST_DEVICE
inline
234 template <
typename KeyValuePairT>
235 HIPCUB_HOST_DEVICE
inline
236 KeyValuePairT operator()(
237 const KeyValuePairT &first,
238 const KeyValuePairT &second)
240 KeyValuePairT retval = second;
242 if (first.key == second.key)
244 retval.value = op(first.value, retval.value);
250 template <
typename BinaryOpT>
256 explicit BinaryFlip(BinaryOpT binary_op) : binary_op(binary_op)
260 template <
typename T,
typename U>
262 operator()(T &&t, U &&u) -> decltype(binary_op(std::forward<U>(u),
265 return binary_op(std::forward<U>(u), std::forward<T>(t));
269 template <
typename BinaryOpT>
300 class InputIteratorT,
301 class OutputIteratorT,
304 struct convert_result_type_wrapper
306 using input_type =
typename std::iterator_traits<InputIteratorT>::value_type;
307 using output_type =
typename std::iterator_traits<OutputIteratorT>::value_type;
309 typename std::conditional<
310 std::is_void<output_type>::value, input_type, output_type
313 convert_result_type_wrapper(BinaryFunction op) : op(op) {}
316 HIPCUB_HOST_DEVICE
inline
317 constexpr result_type operator()(
const T &a,
const T &b)
const
319 return static_cast<result_type
>(op(a, b));
326 class InputIteratorT,
327 class OutputIteratorT,
331 convert_result_type_wrapper<InputIteratorT, OutputIteratorT, BinaryFunction>
332 convert_result_type(BinaryFunction op)
334 return convert_result_type_wrapper<InputIteratorT, OutputIteratorT, BinaryFunction>(op);
Definition: thread_operators.hpp:168
Definition: thread_operators.hpp:126
Definition: thread_operators.hpp:141
Definition: thread_operators.hpp:252
Definition: thread_operators.hpp:157
Definition: thread_operators.hpp:86
Definition: thread_operators.hpp:96
Definition: thread_operators.hpp:40
Definition: thread_operators.hpp:61
Definition: thread_operators.hpp:50
Definition: thread_operators.hpp:106
Definition: thread_operators.hpp:116
Definition: thread_operators.hpp:221
Definition: thread_operators.hpp:191
Definition: thread_operators.hpp:76