11 #ifndef vtk_m_exec_serial_internal_TaskTiling_h
12 #define vtk_m_exec_serial_internal_TaskTiling_h
28 template <
typename WType>
31 const vtkm::exec::internal::ErrorMessageBuffer& buffer)
33 using WorkletType =
typename std::remove_cv<WType>::type;
34 WorkletType*
const worklet =
static_cast<WorkletType*
>(w);
35 worklet->SetErrorMessageBuffer(buffer);
38 template <
typename WType,
typename IType>
41 using WorkletType =
typename std::remove_cv<WType>::type;
42 using InvocationType =
typename std::remove_cv<IType>::type;
44 WorkletType
const*
const worklet =
static_cast<WorkletType*
>(w);
45 InvocationType
const*
const invocation =
static_cast<InvocationType*
>(v);
47 for (
vtkm::Id index = start; index < end; ++index)
50 vtkm::exec::internal::detail::DoWorkletInvokeFunctor(
53 worklet->GetThreadIndices(index,
54 invocation->OutputToInputMap,
55 invocation->VisitArray,
56 invocation->ThreadToOutputMap,
57 invocation->GetInputDomain()));
61 template <
typename FType>
64 using FunctorType =
typename std::remove_cv<FType>::type;
65 FunctorType
const*
const functor =
static_cast<FunctorType*
>(f);
67 for (
vtkm::Id index = start; index < end; ++index)
69 functor->operator()(index);
73 template <
typename WType,
typename IType>
82 using WorkletType =
typename std::remove_cv<WType>::type;
83 using InvocationType =
typename std::remove_cv<IType>::type;
85 WorkletType
const*
const worklet =
static_cast<WorkletType*
>(w);
86 InvocationType
const*
const invocation =
static_cast<InvocationType*
>(v);
89 auto threadIndex1D = index[0] + maxSize[0] * (index[1] + maxSize[1] * index[2]);
90 for (
vtkm::Id i = istart; i < iend; ++i, ++threadIndex1D)
94 vtkm::exec::internal::detail::DoWorkletInvokeFunctor(
97 worklet->GetThreadIndices(threadIndex1D,
99 invocation->OutputToInputMap,
100 invocation->VisitArray,
101 invocation->ThreadToOutputMap,
102 invocation->GetInputDomain()));
106 template <
typename FType>
115 using FunctorType =
typename std::remove_cv<FType>::type;
116 FunctorType
const*
const functor =
static_cast<FunctorType*
>(f);
119 for (
vtkm::Id i = istart; i < iend; ++i)
122 functor->operator()(index);
138 , Invocation(
nullptr)
145 template <
typename FunctorType>
146 TaskTiling1D(FunctorType& functor)
148 , Invocation(
nullptr)
149 , ExecuteFunction(
nullptr)
150 , SetErrorBufferFunction(
nullptr)
153 this->ExecuteFunction = &FunctorTiling1DExecute<FunctorType>;
154 this->SetErrorBufferFunction = &TaskTilingSetErrorBuffer<FunctorType>;
157 this->Worklet = (
void*)&functor;
162 template <
typename WorkletType,
typename InvocationType>
163 TaskTiling1D(WorkletType& worklet, InvocationType& invocation)
165 , Invocation(
nullptr)
166 , ExecuteFunction(
nullptr)
167 , SetErrorBufferFunction(
nullptr)
170 this->ExecuteFunction = &TaskTiling1DExecute<WorkletType, InvocationType>;
171 this->SetErrorBufferFunction = &TaskTilingSetErrorBuffer<WorkletType>;
174 this->Worklet = (
void*)&worklet;
175 this->Invocation = (
void*)&invocation;
181 TaskTiling1D(TaskTiling1D& task)
182 : Worklet(task.Worklet)
183 , Invocation(task.Invocation)
184 , ExecuteFunction(task.ExecuteFunction)
185 , SetErrorBufferFunction(task.SetErrorBufferFunction)
189 TaskTiling1D(TaskTiling1D&& task) =
default;
191 void SetErrorMessageBuffer(
const vtkm::exec::internal::ErrorMessageBuffer& buffer)
193 this->SetErrorBufferFunction(this->Worklet, buffer);
198 this->ExecuteFunction(this->Worklet, this->Invocation, start, end);
206 ExecuteSignature ExecuteFunction;
208 using SetErrorBufferSignature = void (*)(
void*,
const vtkm::exec::internal::ErrorMessageBuffer&);
209 SetErrorBufferSignature SetErrorBufferFunction;
224 , Invocation(
nullptr)
231 template <
typename FunctorType>
232 TaskTiling3D(FunctorType& functor)
234 , Invocation(
nullptr)
235 , ExecuteFunction(
nullptr)
236 , SetErrorBufferFunction(
nullptr)
239 this->ExecuteFunction = &FunctorTiling3DExecute<FunctorType>;
240 this->SetErrorBufferFunction = &TaskTilingSetErrorBuffer<FunctorType>;
243 this->Worklet = (
void*)&functor;
246 template <
typename WorkletType,
typename InvocationType>
247 TaskTiling3D(WorkletType& worklet, InvocationType& invocation)
249 , Invocation(
nullptr)
250 , ExecuteFunction(
nullptr)
251 , SetErrorBufferFunction(
nullptr)
254 this->ExecuteFunction = &TaskTiling3DExecute<WorkletType, InvocationType>;
255 this->SetErrorBufferFunction = &TaskTilingSetErrorBuffer<WorkletType>;
258 this->Worklet = (
void*)&worklet;
259 this->Invocation = (
void*)&invocation;
265 TaskTiling3D(TaskTiling3D& task)
266 : Worklet(task.Worklet)
267 , Invocation(task.Invocation)
268 , ExecuteFunction(task.ExecuteFunction)
269 , SetErrorBufferFunction(task.SetErrorBufferFunction)
273 TaskTiling3D(TaskTiling3D&& task) =
default;
275 void SetErrorMessageBuffer(
const vtkm::exec::internal::ErrorMessageBuffer& buffer)
277 this->SetErrorBufferFunction(this->Worklet, buffer);
280 void operator()(
const vtkm::Id3& maxSize,
286 this->ExecuteFunction(this->Worklet, this->Invocation, maxSize, istart, iend, j, k);
293 using ExecuteSignature =
295 ExecuteSignature ExecuteFunction;
297 using SetErrorBufferSignature = void (*)(
void*,
const vtkm::exec::internal::ErrorMessageBuffer&);
298 SetErrorBufferSignature SetErrorBufferFunction;
305 #endif //vtk_m_exec_serial_internal_TaskTiling_h