VTK-m  2.2
TaskBasic.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 #ifndef vtk_m_exec_kokkos_internal_TaskBasic_h
11 #define vtk_m_exec_kokkos_internal_TaskBasic_h
12 
13 #include <vtkm/exec/TaskBase.h>
14 
15 //Todo: rename this header to TaskInvokeWorkletDetail.h
17 
18 namespace vtkm
19 {
20 namespace exec
21 {
22 namespace kokkos
23 {
24 namespace internal
25 {
26 
27 template <typename WType, typename IType, typename Hints>
28 class TaskBasic1D : public vtkm::exec::TaskBase
29 {
30  VTKM_IS_HINT_LIST(Hints);
31 
32 public:
33  TaskBasic1D(const WType& worklet, const IType& invocation)
34  : Worklet(worklet)
35  , Invocation(invocation)
36  {
37  }
38 
39  void SetErrorMessageBuffer(const vtkm::exec::internal::ErrorMessageBuffer& buffer)
40  {
41  this->Worklet.SetErrorMessageBuffer(buffer);
42  }
43 
44  VTKM_EXEC
45  void operator()(vtkm::Id index) const
46  {
47  vtkm::exec::internal::detail::DoWorkletInvokeFunctor(
48  this->Worklet,
49  this->Invocation,
50  this->Worklet.GetThreadIndices(index,
51  this->Invocation.OutputToInputMap,
52  this->Invocation.VisitArray,
53  this->Invocation.ThreadToOutputMap,
54  this->Invocation.GetInputDomain()));
55  }
56 
57 private:
58  typename std::remove_const<WType>::type Worklet;
59  IType Invocation;
60 };
61 
62 template <typename WType, typename Hints>
63 class TaskBasic1D<WType, vtkm::internal::NullType, Hints> : public vtkm::exec::TaskBase
64 {
65  VTKM_IS_HINT_LIST(Hints);
66 
67 public:
68  explicit TaskBasic1D(const WType& worklet)
69  : Worklet(worklet)
70  {
71  }
72 
73  void SetErrorMessageBuffer(const vtkm::exec::internal::ErrorMessageBuffer& buffer)
74  {
75  this->Worklet.SetErrorMessageBuffer(buffer);
76  }
77 
78  VTKM_EXEC
79  void operator()(vtkm::Id index) const { this->Worklet(index); }
80 
81 private:
82  typename std::remove_const<WType>::type Worklet;
83 };
84 
85 template <typename WType, typename IType, typename Hints>
86 class TaskBasic3D : public vtkm::exec::TaskBase
87 {
88  VTKM_IS_HINT_LIST(Hints);
89 
90 public:
91  TaskBasic3D(const WType& worklet, const IType& invocation)
92  : Worklet(worklet)
93  , Invocation(invocation)
94  {
95  }
96 
97  void SetErrorMessageBuffer(const vtkm::exec::internal::ErrorMessageBuffer& buffer)
98  {
99  this->Worklet.SetErrorMessageBuffer(buffer);
100  }
101 
102  VTKM_EXEC
103  void operator()(vtkm::Id3 idx, vtkm::Id flatIdx) const
104  {
105  vtkm::exec::internal::detail::DoWorkletInvokeFunctor(
106  this->Worklet,
107  this->Invocation,
108  this->Worklet.GetThreadIndices(flatIdx,
109  idx,
110  this->Invocation.OutputToInputMap,
111  this->Invocation.VisitArray,
112  this->Invocation.ThreadToOutputMap,
113  this->Invocation.GetInputDomain()));
114  }
115 
116 private:
117  typename std::remove_const<WType>::type Worklet;
118  IType Invocation;
119 };
120 
121 template <typename WType, typename Hints>
122 class TaskBasic3D<WType, vtkm::internal::NullType, Hints> : public vtkm::exec::TaskBase
123 {
124  VTKM_IS_HINT_LIST(Hints);
125 
126 public:
127  explicit TaskBasic3D(const WType& worklet)
128  : Worklet(worklet)
129  {
130  }
131 
132  void SetErrorMessageBuffer(const vtkm::exec::internal::ErrorMessageBuffer& buffer)
133  {
134  this->Worklet.SetErrorMessageBuffer(buffer);
135  }
136 
137  VTKM_EXEC
138  void operator()(vtkm::Id3 idx, vtkm::Id) const { this->Worklet(idx); }
139 
140 private:
141  typename std::remove_const<WType>::type Worklet;
142 };
143 }
144 }
145 }
146 } // vtkm::exec::kokkos::internal
147 
148 #endif //vtk_m_exec_kokkos_internal_TaskBasic_h
WorkletInvokeFunctorDetail.h
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::exec::TaskBase
Base class for all classes that are used to marshal data from the invocation parameters to the user w...
Definition: TaskBase.h:26
vtkm::Id
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
VTKM_IS_HINT_LIST
#define VTKM_IS_HINT_LIST(T)
Performs a static assert that the given object is a hint list.
Definition: Hints.h:85
vtkm::Vec< vtkm::Id, 3 >
TaskBase.h