18 #ifndef viskores_exec_cuda_internal_WrappedOperators_h
19 #define viskores_exec_cuda_internal_WrappedOperators_h
30 #include <thrust/system/cuda/memory.h>
33 #if THRUST_VERSION >= 200500
34 #include <cuda/std/type_traits>
50 template <
typename T_,
typename Function>
51 struct WrappedUnaryPredicate
53 using T =
typename std::remove_const<T_>::type;
56 using first_argument_type = T;
57 using result_type = bool;
62 WrappedUnaryPredicate()
68 WrappedUnaryPredicate(
const Function& f)
73 VISKORES_EXEC bool operator()(
const T& x)
const {
return m_f(x); }
76 VISKORES_EXEC bool operator()(
const viskores::internal::ArrayPortalValueReference<U>& x)
const
81 VISKORES_EXEC bool operator()(
const T* x)
const {
return m_f(*x); }
88 template <
typename T_,
typename Function>
89 struct WrappedBinaryOperator
91 using T =
typename std::remove_const<T_>::type;
94 using first_argument_type = T;
95 using second_argument_type = T;
96 using result_type = T;
101 WrappedBinaryOperator()
107 WrappedBinaryOperator(
const Function& f)
112 VISKORES_EXEC T operator()(
const T& x,
const T& y)
const {
return m_f(x, y); }
114 template <
typename U>
116 const viskores::internal::ArrayPortalValueReference<U>& y)
const
120 return m_f(x, y.Get());
123 template <
typename U>
124 VISKORES_EXEC T operator()(
const viskores::internal::ArrayPortalValueReference<U>& x,
127 return m_f(x.Get(), y);
130 template <
typename U,
typename V>
131 VISKORES_EXEC T operator()(
const viskores::internal::ArrayPortalValueReference<U>& x,
132 const viskores::internal::ArrayPortalValueReference<V>& y)
const
134 return m_f(x.Get(), y.Get());
137 VISKORES_EXEC T operator()(
const T*
const x,
const T& y)
const {
return m_f(*x, y); }
139 VISKORES_EXEC T operator()(
const T& x,
const T*
const y)
const {
return m_f(x, *y); }
141 VISKORES_EXEC T operator()(
const T*
const x,
const T*
const y)
const {
return m_f(*x, *y); }
144 template <
typename T_,
typename Function>
145 struct WrappedBinaryPredicate
147 using T =
typename std::remove_const<T_>::type;
150 using first_argument_type = T;
151 using second_argument_type = T;
152 using result_type = bool;
157 WrappedBinaryPredicate()
163 WrappedBinaryPredicate(
const Function& f)
168 VISKORES_EXEC bool operator()(
const T& x,
const T& y)
const {
return m_f(x, y); }
170 template <
typename U>
172 const viskores::internal::ArrayPortalValueReference<U>& y)
const
174 return m_f(x, y.Get());
177 template <
typename U>
178 VISKORES_EXEC bool operator()(
const viskores::internal::ArrayPortalValueReference<U>& x,
181 return m_f(x.Get(), y);
184 template <
typename U,
typename V>
185 VISKORES_EXEC bool operator()(
const viskores::internal::ArrayPortalValueReference<U>& x,
186 const viskores::internal::ArrayPortalValueReference<V>& y)
const
188 return m_f(x.Get(), y.Get());
191 VISKORES_EXEC bool operator()(
const T*
const x,
const T& y)
const {
return m_f(*x, y); }
193 VISKORES_EXEC bool operator()(
const T& x,
const T*
const y)
const {
return m_f(x, *y); }
195 VISKORES_EXEC bool operator()(
const T*
const x,
const T*
const y)
const {
return m_f(*x, *y); }
212 #if THRUST_VERSION >= 200500
213 template <
typename T,
typename F>
214 struct is_commutative<
viskores::exec::cuda::internal::WrappedBinaryOperator<T, F>>
215 :
public ::cuda::std::is_arithmetic<T>
219 template <
typename T,
typename F>
220 struct is_commutative<
viskores::exec::cuda::internal::WrappedBinaryOperator<T, F>>
221 :
public thrust::detail::is_arithmetic<T>
228 #endif //viskores_exec_cuda_internal_WrappedOperators_h