10 #ifndef vtk_m_exec_cuda_internal_WrappedOperators_h
11 #define vtk_m_exec_cuda_internal_WrappedOperators_h
22 #include <thrust/system/cuda/memory.h>
25 #if THRUST_VERSION >= 200500
26 #include <cuda/std/type_traits>
42 template <
typename T_,
typename Function>
43 struct WrappedUnaryPredicate
45 using T =
typename std::remove_const<T_>::type;
48 using first_argument_type = T;
49 using result_type = bool;
54 WrappedUnaryPredicate()
60 WrappedUnaryPredicate(
const Function& f)
65 VTKM_EXEC bool operator()(
const T& x)
const {
return m_f(x); }
68 VTKM_EXEC bool operator()(
const vtkm::internal::ArrayPortalValueReference<U>& x)
const
73 VTKM_EXEC bool operator()(
const T* x)
const {
return m_f(*x); }
80 template <
typename T_,
typename Function>
81 struct WrappedBinaryOperator
83 using T =
typename std::remove_const<T_>::type;
86 using first_argument_type = T;
87 using second_argument_type = T;
88 using result_type = T;
93 WrappedBinaryOperator()
99 WrappedBinaryOperator(
const Function& f)
104 VTKM_EXEC T operator()(
const T& x,
const T& y)
const {
return m_f(x, y); }
106 template <
typename U>
107 VTKM_EXEC T operator()(
const T& x,
const vtkm::internal::ArrayPortalValueReference<U>& y)
const
111 return m_f(x, y.Get());
114 template <
typename U>
115 VTKM_EXEC T operator()(
const vtkm::internal::ArrayPortalValueReference<U>& x,
const T& y)
const
117 return m_f(x.Get(), y);
120 template <
typename U,
typename V>
121 VTKM_EXEC T operator()(
const vtkm::internal::ArrayPortalValueReference<U>& x,
122 const vtkm::internal::ArrayPortalValueReference<V>& y)
const
124 return m_f(x.Get(), y.Get());
127 VTKM_EXEC T operator()(
const T*
const x,
const T& y)
const {
return m_f(*x, y); }
129 VTKM_EXEC T operator()(
const T& x,
const T*
const y)
const {
return m_f(x, *y); }
131 VTKM_EXEC T operator()(
const T*
const x,
const T*
const y)
const {
return m_f(*x, *y); }
134 template <
typename T_,
typename Function>
135 struct WrappedBinaryPredicate
137 using T =
typename std::remove_const<T_>::type;
140 using first_argument_type = T;
141 using second_argument_type = T;
142 using result_type = bool;
147 WrappedBinaryPredicate()
153 WrappedBinaryPredicate(
const Function& f)
158 VTKM_EXEC bool operator()(
const T& x,
const T& y)
const {
return m_f(x, y); }
160 template <
typename U>
161 VTKM_EXEC bool operator()(
const T& x,
const vtkm::internal::ArrayPortalValueReference<U>& y)
const
163 return m_f(x, y.Get());
166 template <
typename U>
167 VTKM_EXEC bool operator()(
const vtkm::internal::ArrayPortalValueReference<U>& x,
const T& y)
const
169 return m_f(x.Get(), y);
172 template <
typename U,
typename V>
173 VTKM_EXEC bool operator()(
const vtkm::internal::ArrayPortalValueReference<U>& x,
174 const vtkm::internal::ArrayPortalValueReference<V>& y)
const
176 return m_f(x.Get(), y.Get());
179 VTKM_EXEC bool operator()(
const T*
const x,
const T& y)
const {
return m_f(*x, y); }
181 VTKM_EXEC bool operator()(
const T& x,
const T*
const y)
const {
return m_f(x, *y); }
183 VTKM_EXEC bool operator()(
const T*
const x,
const T*
const y)
const {
return m_f(*x, *y); }
200 #if THRUST_VERSION >= 200500
201 template <
typename T,
typename F>
202 struct is_commutative<
vtkm::exec::cuda::internal::WrappedBinaryOperator<T, F>>
203 :
public ::cuda::std::is_arithmetic<T>
207 template <
typename T,
typename F>
208 struct is_commutative<
vtkm::exec::cuda::internal::WrappedBinaryOperator<T, F>>
209 :
public thrust::detail::is_arithmetic<T>
216 #endif //vtk_m_exec_cuda_internal_WrappedOperators_h