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