VTK-m  2.0
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>
28 class TaskBasic1D : public vtkm::exec::TaskBase
29 {
30 public:
31  TaskBasic1D(const WType& worklet, const IType& invocation)
32  : Worklet(worklet)
33  , Invocation(invocation)
34  {
35  }
36 
37  void SetErrorMessageBuffer(const vtkm::exec::internal::ErrorMessageBuffer& buffer)
38  {
39  this->Worklet.SetErrorMessageBuffer(buffer);
40  }
41 
42  VTKM_EXEC
43  void operator()(vtkm::Id index) const
44  {
45  vtkm::exec::internal::detail::DoWorkletInvokeFunctor(
46  this->Worklet,
47  this->Invocation,
48  this->Worklet.GetThreadIndices(index,
49  this->Invocation.OutputToInputMap,
50  this->Invocation.VisitArray,
51  this->Invocation.ThreadToOutputMap,
52  this->Invocation.GetInputDomain()));
53  }
54 
55 private:
56  typename std::remove_const<WType>::type Worklet;
57  IType Invocation;
58 };
59 
60 template <typename WType>
61 class TaskBasic1D<WType, vtkm::internal::NullType> : public vtkm::exec::TaskBase
62 {
63 public:
64  explicit TaskBasic1D(const WType& worklet)
65  : Worklet(worklet)
66  {
67  }
68 
69  void SetErrorMessageBuffer(const vtkm::exec::internal::ErrorMessageBuffer& buffer)
70  {
71  this->Worklet.SetErrorMessageBuffer(buffer);
72  }
73 
74  VTKM_EXEC
75  void operator()(vtkm::Id index) const { this->Worklet(index); }
76 
77 private:
78  typename std::remove_const<WType>::type Worklet;
79 };
80 
81 template <typename WType, typename IType>
82 class TaskBasic3D : public vtkm::exec::TaskBase
83 {
84 public:
85  TaskBasic3D(const WType& worklet, const IType& invocation)
86  : Worklet(worklet)
87  , Invocation(invocation)
88  {
89  }
90 
91  void SetErrorMessageBuffer(const vtkm::exec::internal::ErrorMessageBuffer& buffer)
92  {
93  this->Worklet.SetErrorMessageBuffer(buffer);
94  }
95 
96  VTKM_EXEC
97  void operator()(vtkm::Id3 idx, vtkm::Id flatIdx) const
98  {
99  vtkm::exec::internal::detail::DoWorkletInvokeFunctor(
100  this->Worklet,
101  this->Invocation,
102  this->Worklet.GetThreadIndices(flatIdx,
103  idx,
104  this->Invocation.OutputToInputMap,
105  this->Invocation.VisitArray,
106  this->Invocation.ThreadToOutputMap,
107  this->Invocation.GetInputDomain()));
108  }
109 
110 private:
111  typename std::remove_const<WType>::type Worklet;
112  IType Invocation;
113 };
114 
115 template <typename WType>
116 class TaskBasic3D<WType, vtkm::internal::NullType> : public vtkm::exec::TaskBase
117 {
118 public:
119  explicit TaskBasic3D(const WType& worklet)
120  : Worklet(worklet)
121  {
122  }
123 
124  void SetErrorMessageBuffer(const vtkm::exec::internal::ErrorMessageBuffer& buffer)
125  {
126  this->Worklet.SetErrorMessageBuffer(buffer);
127  }
128 
129  VTKM_EXEC
130  void operator()(vtkm::Id3 idx, vtkm::Id) const { this->Worklet(idx); }
131 
132 private:
133  typename std::remove_const<WType>::type Worklet;
134 };
135 }
136 }
137 }
138 } // vtkm::exec::kokkos::internal
139 
140 #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::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
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:24
vtkm::Vec< vtkm::Id, 3 >
TaskBase.h