10 #ifndef vtk_m_exec_cuda_internal_WrappedOperators_h
11 #define vtk_m_exec_cuda_internal_WrappedOperators_h
21 VTKM_THIRDPARTY_PRE_INCLUDE
22 #include <thrust/system/cuda/memory.h>
23 VTKM_THIRDPARTY_POST_INCLUDE
38 template <
typename T_,
typename Function>
39 struct WrappedUnaryPredicate
41 using T =
typename std::remove_const<T_>::type;
44 using first_argument_type = T;
45 using result_type = bool;
50 WrappedUnaryPredicate()
56 WrappedUnaryPredicate(
const Function& f)
61 VTKM_EXEC bool operator()(
const T& x)
const {
return m_f(x); }
64 VTKM_EXEC bool operator()(
const vtkm::internal::ArrayPortalValueReference<U>& x)
const
69 VTKM_EXEC bool operator()(
const T* x)
const {
return m_f(*x); }
76 template <
typename T_,
typename Function>
77 struct WrappedBinaryOperator
79 using T =
typename std::remove_const<T_>::type;
82 using first_argument_type = T;
83 using second_argument_type = T;
84 using result_type = T;
89 WrappedBinaryOperator()
95 WrappedBinaryOperator(
const Function& f)
100 VTKM_EXEC T operator()(
const T& x,
const T& y)
const {
return m_f(x, y); }
102 template <
typename U>
103 VTKM_EXEC T operator()(
const T& x,
const vtkm::internal::ArrayPortalValueReference<U>& y)
const
107 return m_f(x, y.Get());
110 template <
typename U>
111 VTKM_EXEC T operator()(
const vtkm::internal::ArrayPortalValueReference<U>& x,
const T& y)
const
113 return m_f(x.Get(), y);
116 template <
typename U,
typename V>
117 VTKM_EXEC T operator()(
const vtkm::internal::ArrayPortalValueReference<U>& x,
118 const vtkm::internal::ArrayPortalValueReference<V>& y)
const
120 return m_f(x.Get(), y.Get());
123 VTKM_EXEC T operator()(
const T*
const x,
const T& y)
const {
return m_f(*x, y); }
125 VTKM_EXEC T operator()(
const T& x,
const T*
const y)
const {
return m_f(x, *y); }
127 VTKM_EXEC T operator()(
const T*
const x,
const T*
const y)
const {
return m_f(*x, *y); }
130 template <
typename T_,
typename Function>
131 struct WrappedBinaryPredicate
133 using T =
typename std::remove_const<T_>::type;
136 using first_argument_type = T;
137 using second_argument_type = T;
138 using result_type = bool;
143 WrappedBinaryPredicate()
149 WrappedBinaryPredicate(
const Function& f)
154 VTKM_EXEC bool operator()(
const T& x,
const T& y)
const {
return m_f(x, y); }
156 template <
typename U>
157 VTKM_EXEC bool operator()(
const T& x,
const vtkm::internal::ArrayPortalValueReference<U>& y)
const
159 return m_f(x, y.Get());
162 template <
typename U>
163 VTKM_EXEC bool operator()(
const vtkm::internal::ArrayPortalValueReference<U>& x,
const T& y)
const
165 return m_f(x.Get(), y);
168 template <
typename U,
typename V>
169 VTKM_EXEC bool operator()(
const vtkm::internal::ArrayPortalValueReference<U>& x,
170 const vtkm::internal::ArrayPortalValueReference<V>& y)
const
172 return m_f(x.Get(), y.Get());
175 VTKM_EXEC bool operator()(
const T*
const x,
const T& y)
const {
return m_f(*x, y); }
177 VTKM_EXEC bool operator()(
const T& x,
const T*
const y)
const {
return m_f(x, *y); }
179 VTKM_EXEC bool operator()(
const T*
const x,
const T*
const y)
const {
return m_f(*x, *y); }
196 template <
typename T,
typename F>
197 struct is_commutative<
vtkm::exec::cuda::internal::WrappedBinaryOperator<T, F>>
198 :
public thrust::detail::is_arithmetic<T>
204 #endif //vtk_m_exec_cuda_internal_WrappedOperators_h