10 #ifndef vtk_m_cont_exec_ArrayHandleExecutionManager_h
11 #define vtk_m_cont_exec_ArrayHandleExecutionManager_h
29 template <
typename T,
typename Storage>
30 class ArrayHandleExecutionManagerBase
33 using StorageType = vtkm::cont::internal::Storage<T, Storage>;
36 template <
typename DeviceAdapter>
40 using ArrayTransferType = vtkm::cont::internal::ArrayTransfer<T, Storage, DeviceAdapter>;
43 using Portal =
typename ArrayTransferType::PortalExecution;
44 using PortalConst =
typename ArrayTransferType::PortalConstExecution;
53 using PortalControl =
typename StorageType::PortalType;
54 using PortalConstControl =
typename StorageType::PortalConstType;
57 virtual ~ArrayHandleExecutionManagerBase() {}
63 vtkm::Id GetNumberOfValues()
const {
return this->GetNumberOfValuesImpl(); }
71 template <
typename DeviceAdapter>
72 VTKM_CONT typename ExecutionTypes<DeviceAdapter>::PortalConst
75 this->VerifyDeviceAdapter(DeviceAdapter());
77 typename ExecutionTypes<DeviceAdapter>::PortalConst portal;
78 this->PrepareForInputImpl(updateData, &portal, token);
88 template <
typename DeviceAdapter>
89 VTKM_CONT typename ExecutionTypes<DeviceAdapter>::Portal
92 this->VerifyDeviceAdapter(DeviceAdapter());
94 typename ExecutionTypes<DeviceAdapter>::Portal portal;
95 this->PrepareForInPlaceImpl(updateData, &portal, token);
106 template <
typename DeviceAdapter>
107 VTKM_CONT typename ExecutionTypes<DeviceAdapter>::Portal
110 this->VerifyDeviceAdapter(DeviceAdapter());
112 typename ExecutionTypes<DeviceAdapter>::Portal portal;
113 this->PrepareForOutputImpl(numberOfValues, &portal, token);
125 void RetrieveOutputData(StorageType* storage)
const { this->RetrieveOutputDataImpl(storage); }
137 void Shrink(
vtkm::Id numberOfValues) { this->ShrinkImpl(numberOfValues); }
143 void ReleaseResources() { this->ReleaseResourcesImpl(); }
145 template <
typename DeviceAdapter>
146 VTKM_CONT bool IsDeviceAdapter(DeviceAdapter device)
const
148 return this->IsDeviceAdapterImpl(device);
152 DeviceAdapterId GetDeviceAdapterId()
const {
return this->GetDeviceAdapterIdImpl(); }
155 virtual vtkm::Id GetNumberOfValuesImpl()
const = 0;
157 virtual void PrepareForInputImpl(
bool updateData,
158 void* portalExecutionVoid,
161 virtual void PrepareForInPlaceImpl(
bool updateData,
162 void* portalExecutionVoid,
165 virtual void PrepareForOutputImpl(
vtkm::Id numberOfValues,
166 void* portalExecution,
169 virtual void RetrieveOutputDataImpl(StorageType* storage)
const = 0;
171 virtual void ShrinkImpl(
Id numberOfValues) = 0;
173 virtual void ReleaseResourcesImpl() = 0;
177 virtual DeviceAdapterId GetDeviceAdapterIdImpl()
const = 0;
180 template <
typename DeviceAdapter>
181 VTKM_CONT void VerifyDeviceAdapter(DeviceAdapter device)
const
183 if (!this->IsDeviceAdapter(device))
197 template <
typename T,
typename Storage,
typename DeviceAdapter>
198 class ArrayHandleExecutionManager :
public ArrayHandleExecutionManagerBase<T, Storage>
200 using Superclass = ArrayHandleExecutionManagerBase<T, Storage>;
201 using ArrayTransferType = vtkm::cont::internal::ArrayTransfer<T, Storage, DeviceAdapter>;
202 using StorageType = vtkm::cont::internal::Storage<T, Storage>;
205 using PortalControl =
typename ArrayTransferType::PortalControl;
206 using PortalConstControl =
typename ArrayTransferType::PortalConstControl;
208 using PortalExecution =
typename ArrayTransferType::PortalExecution;
209 using PortalConstExecution =
typename ArrayTransferType::PortalConstExecution;
212 ArrayHandleExecutionManager(StorageType* storage)
219 vtkm::Id GetNumberOfValuesImpl()
const {
return this->Transfer.GetNumberOfValues(); }
222 void PrepareForInputImpl(
bool updateData,
void* portalExecutionVoid,
vtkm::cont::Token& token)
224 PortalConstExecution portal = this->Transfer.PrepareForInput(updateData, token);
225 *
reinterpret_cast<PortalConstExecution*
>(portalExecutionVoid) = portal;
229 void PrepareForInPlaceImpl(
bool updateData,
void* portalExecutionVoid,
vtkm::cont::Token& token)
231 PortalExecution portal = this->Transfer.PrepareForInPlace(updateData, token);
232 *
reinterpret_cast<PortalExecution*
>(portalExecutionVoid) = portal;
236 void PrepareForOutputImpl(
vtkm::Id numberOfValues,
237 void* portalExecutionVoid,
240 PortalExecution portal = this->Transfer.PrepareForOutput(numberOfValues, token);
241 *
reinterpret_cast<PortalExecution*
>(portalExecutionVoid) = portal;
245 void RetrieveOutputDataImpl(StorageType* storage)
const
247 this->Transfer.RetrieveOutputData(storage);
251 void ShrinkImpl(
Id numberOfValues) { this->Transfer.Shrink(numberOfValues); }
254 void ReleaseResourcesImpl() { this->Transfer.ReleaseResources(); }
257 bool IsDeviceAdapterImpl(
const DeviceAdapterId&
id)
const {
return id == DeviceAdapter(); }
260 DeviceAdapterId GetDeviceAdapterIdImpl()
const {
return DeviceAdapter(); }
263 ArrayTransferType Transfer;
269 #endif //vtk_m_cont_exec_ArrayHandleExecutionManager_h