19 #ifndef viskores_exec_serial_internal_TaskTiling_h
20 #define viskores_exec_serial_internal_TaskTiling_h
36 template <
typename WType>
37 VISKORES_NEVER_EXPORT
void TaskTilingSetErrorBuffer(
39 const viskores::exec::internal::ErrorMessageBuffer& buffer)
41 using WorkletType =
typename std::remove_cv<WType>::type;
42 WorkletType*
const worklet =
static_cast<WorkletType*
>(w);
43 worklet->SetErrorMessageBuffer(buffer);
46 template <
typename WType,
typename IType>
47 VISKORES_NEVER_EXPORT
void TaskTiling1DExecute(
void* w,
52 using WorkletType =
typename std::remove_cv<WType>::type;
53 using InvocationType =
typename std::remove_cv<IType>::type;
55 WorkletType
const*
const worklet =
static_cast<WorkletType*
>(w);
56 InvocationType
const*
const invocation =
static_cast<InvocationType*
>(v);
61 viskores::exec::internal::detail::DoWorkletInvokeFunctor(
64 worklet->GetThreadIndices(index,
65 invocation->OutputToInputMap,
66 invocation->VisitArray,
67 invocation->ThreadToOutputMap,
68 invocation->GetInputDomain()));
72 template <
typename FType>
73 VISKORES_NEVER_EXPORT
void FunctorTiling1DExecute(
void* f,
78 using FunctorType =
typename std::remove_cv<FType>::type;
79 FunctorType
const*
const functor =
static_cast<FunctorType*
>(f);
83 functor->operator()(index);
87 template <
typename WType,
typename IType>
88 VISKORES_NEVER_EXPORT
void TaskTiling3DExecute(
void* w,
96 using WorkletType =
typename std::remove_cv<WType>::type;
97 using InvocationType =
typename std::remove_cv<IType>::type;
99 WorkletType
const*
const worklet =
static_cast<WorkletType*
>(w);
100 InvocationType
const*
const invocation =
static_cast<InvocationType*
>(v);
103 auto threadIndex1D = index[0] + maxSize[0] * (index[1] + maxSize[1] * index[2]);
104 for (
viskores::Id i = istart; i < iend; ++i, ++threadIndex1D)
108 viskores::exec::internal::detail::DoWorkletInvokeFunctor(
111 worklet->GetThreadIndices(threadIndex1D,
113 invocation->OutputToInputMap,
114 invocation->VisitArray,
115 invocation->ThreadToOutputMap,
116 invocation->GetInputDomain()));
120 template <
typename FType>
121 VISKORES_NEVER_EXPORT
void FunctorTiling3DExecute(
void* f,
129 using FunctorType =
typename std::remove_cv<FType>::type;
130 FunctorType
const*
const functor =
static_cast<FunctorType*
>(f);
136 functor->operator()(index);
152 , Invocation(
nullptr)
159 template <
typename FunctorType>
160 TaskTiling1D(FunctorType& functor)
162 , Invocation(
nullptr)
163 , ExecuteFunction(
nullptr)
164 , SetErrorBufferFunction(
nullptr)
167 this->ExecuteFunction = &FunctorTiling1DExecute<FunctorType>;
168 this->SetErrorBufferFunction = &TaskTilingSetErrorBuffer<FunctorType>;
171 this->Worklet = (
void*)&functor;
176 template <
typename WorkletType,
typename InvocationType>
177 TaskTiling1D(WorkletType& worklet, InvocationType& invocation)
179 , Invocation(
nullptr)
180 , ExecuteFunction(
nullptr)
181 , SetErrorBufferFunction(
nullptr)
184 this->ExecuteFunction = &TaskTiling1DExecute<WorkletType, InvocationType>;
185 this->SetErrorBufferFunction = &TaskTilingSetErrorBuffer<WorkletType>;
188 this->Worklet = (
void*)&worklet;
189 this->Invocation = (
void*)&invocation;
195 TaskTiling1D(TaskTiling1D& task)
196 : Worklet(task.Worklet)
197 , Invocation(task.Invocation)
198 , ExecuteFunction(task.ExecuteFunction)
199 , SetErrorBufferFunction(task.SetErrorBufferFunction)
203 TaskTiling1D(TaskTiling1D&& task) =
default;
205 void SetErrorMessageBuffer(
const viskores::exec::internal::ErrorMessageBuffer& buffer)
207 this->SetErrorBufferFunction(this->Worklet, buffer);
212 this->ExecuteFunction(this->Worklet, this->Invocation, start, end);
220 ExecuteSignature ExecuteFunction;
222 using SetErrorBufferSignature = void (*)(
void*,
223 const viskores::exec::internal::ErrorMessageBuffer&);
224 SetErrorBufferSignature SetErrorBufferFunction;
239 , Invocation(
nullptr)
246 template <
typename FunctorType>
247 TaskTiling3D(FunctorType& functor)
249 , Invocation(
nullptr)
250 , ExecuteFunction(
nullptr)
251 , SetErrorBufferFunction(
nullptr)
254 this->ExecuteFunction = &FunctorTiling3DExecute<FunctorType>;
255 this->SetErrorBufferFunction = &TaskTilingSetErrorBuffer<FunctorType>;
258 this->Worklet = (
void*)&functor;
261 template <
typename WorkletType,
typename InvocationType>
262 TaskTiling3D(WorkletType& worklet, InvocationType& invocation)
264 , Invocation(
nullptr)
265 , ExecuteFunction(
nullptr)
266 , SetErrorBufferFunction(
nullptr)
269 this->ExecuteFunction = &TaskTiling3DExecute<WorkletType, InvocationType>;
270 this->SetErrorBufferFunction = &TaskTilingSetErrorBuffer<WorkletType>;
273 this->Worklet = (
void*)&worklet;
274 this->Invocation = (
void*)&invocation;
280 TaskTiling3D(TaskTiling3D& task)
281 : Worklet(task.Worklet)
282 , Invocation(task.Invocation)
283 , ExecuteFunction(task.ExecuteFunction)
284 , SetErrorBufferFunction(task.SetErrorBufferFunction)
288 TaskTiling3D(TaskTiling3D&& task) =
default;
290 void SetErrorMessageBuffer(
const viskores::exec::internal::ErrorMessageBuffer& buffer)
292 this->SetErrorBufferFunction(this->Worklet, buffer);
301 this->ExecuteFunction(this->Worklet, this->Invocation, maxSize, istart, iend, j, k);
308 using ExecuteSignature = void (*)(
void*,
315 ExecuteSignature ExecuteFunction;
317 using SetErrorBufferSignature = void (*)(
void*,
318 const viskores::exec::internal::ErrorMessageBuffer&);
319 SetErrorBufferSignature SetErrorBufferFunction;
326 #endif //viskores_exec_serial_internal_TaskTiling_h