10 #ifndef vtk_m_cont_ArrayHandleBasic_h
11 #define vtk_m_cont_ArrayHandleBasic_h
35 using ReadPortalType = vtkm::internal::ArrayPortalBasicRead<T>;
36 using WritePortalType = vtkm::internal::ArrayPortalBasicWrite<T>;
38 VTKM_CONT static std::vector<vtkm::cont::internal::Buffer> CreateBuffers()
40 return std::vector<vtkm::cont::internal::Buffer>(1);
44 const std::vector<vtkm::cont::internal::Buffer>& buffers,
48 buffers[0].SetNumberOfBytes(
49 vtkm::internal::NumberOfValuesToNumberOfBytes<T>(numValues), preserve, token);
53 const std::vector<vtkm::cont::internal::Buffer>& buffers)
56 return static_cast<vtkm::Id>(buffers[0].GetNumberOfBytes() /
60 VTKM_CONT static void Fill(
const std::vector<vtkm::cont::internal::Buffer>& buffers,
70 &fillValue, fillValueSize, startIndex * fillValueSize, endIndex * fillValueSize, token);
73 VTKM_CONT static ReadPortalType CreateReadPortal(
74 const std::vector<vtkm::cont::internal::Buffer>& buffers,
79 return ReadPortalType(
reinterpret_cast<const T*
>(buffers[0].ReadPointerDevice(device, token)),
80 GetNumberOfValues(buffers));
83 VTKM_CONT static WritePortalType CreateWritePortal(
84 const std::vector<vtkm::cont::internal::Buffer>& buffers,
89 return WritePortalType(
reinterpret_cast<T*
>(buffers[0].WritePointerDevice(device, token)),
90 GetNumberOfValues(buffers));
107 vtkm::cont::internal::BufferInfo::Deleter deleter,
108 vtkm::cont::internal::BufferInfo::Reallocater reallocater = internal::InvalidRealloc)
109 : Superclass(std::vector<
vtkm::cont::internal::Buffer>{ vtkm::cont::internal::MakeBuffer(
110 vtkm::cont::DeviceAdapterTagUndefined{},
113 vtkm::internal::NumberOfValuesToNumberOfBytes<T>(numberOfValues),
123 vtkm::cont::internal::BufferInfo::Deleter deleter,
124 vtkm::cont::internal::BufferInfo::Reallocater reallocater = internal::InvalidRealloc)
125 : Superclass(std::vector<
vtkm::cont::internal::Buffer>{ vtkm::cont::internal::MakeBuffer(
129 vtkm::internal::NumberOfValuesToNumberOfBytes<T>(numberOfValues),
139 vtkm::cont::internal::BufferInfo::Deleter deleter,
140 vtkm::cont::internal::BufferInfo::Reallocater reallocater = internal::InvalidRealloc)
141 : Superclass(std::vector<
vtkm::cont::internal::Buffer>{ vtkm::cont::internal::MakeBuffer(
142 vtkm::cont::DeviceAdapterTagUndefined{},
145 vtkm::internal::NumberOfValuesToNumberOfBytes<T>(numberOfValues),
156 vtkm::cont::internal::BufferInfo::Deleter deleter,
157 vtkm::cont::internal::BufferInfo::Reallocater reallocater = internal::InvalidRealloc)
158 : Superclass(std::vector<
vtkm::cont::internal::Buffer>{ vtkm::cont::internal::MakeBuffer(
162 vtkm::internal::NumberOfValuesToNumberOfBytes<T>(numberOfValues),
176 return reinterpret_cast<const T*
>(this->GetBuffers()[0].ReadPointerHost(token));
181 return this->GetReadPointer(token);
185 return reinterpret_cast<T*
>(this->GetBuffers()[0].WritePointerHost(token));
190 return this->GetWritePointer(token);
195 return reinterpret_cast<const T*
>(this->GetBuffers()[0].ReadPointerDevice(device, token));
200 return this->GetReadPointer(device, token);
204 return reinterpret_cast<T*
>(this->GetBuffers()[0].WritePointerDevice(device, token));
209 return this->GetWritePointer(device, token);
216 template <
typename T>
240 template <
typename T>
244 vtkm::cont::internal::BufferInfo::Deleter deleter = internal::SimpleArrayDeleter<T>,
245 vtkm::cont::internal::BufferInfo::Reallocater reallocater = internal::SimpleArrayReallocater<T>)
254 template <
typename T,
typename Allocator>
271 template <
typename T,
typename Allocator>
278 static_cast<vtkm::Id>(container->size()),
279 internal::StdVectorDeleter<T, Allocator>,
280 internal::StdVectorReallocater<T, Allocator>);
283 template <
typename T,
typename Allocator>
292 template <
typename T>
308 template <
typename T>
309 struct SerializableTypeString<
vtkm::cont::ArrayHandleBasic<T>>
318 template <
typename T>
319 struct SerializableTypeString<ArrayHandle<T,
vtkm::cont::StorageTagBasic>>
320 : SerializableTypeString<vtkm::cont::ArrayHandleBasic<T>>
329 template <
typename T>
330 struct Serialization<
vtkm::cont::ArrayHandleBasic<T>>
332 static VTKM_CONT void save(BinaryBuffer& bb,
341 vtkm::cont::internal::Buffer buffer;
345 vtkm::cont::internal::CreateBuffers(buffer));
349 template <
typename T>
350 struct Serialization<
vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagBasic>>
351 : Serialization<vtkm::cont::ArrayHandleBasic<T>>
358 #ifndef vtk_m_cont_ArrayHandleBasic_cxx
370 #define VTKM_STORAGE_EXPORT(Type) \
371 extern template class VTKM_CONT_TEMPLATE_EXPORT Storage<Type, StorageTagBasic>; \
372 extern template class VTKM_CONT_TEMPLATE_EXPORT Storage<vtkm::Vec<Type, 2>, StorageTagBasic>; \
373 extern template class VTKM_CONT_TEMPLATE_EXPORT Storage<vtkm::Vec<Type, 3>, StorageTagBasic>; \
374 extern template class VTKM_CONT_TEMPLATE_EXPORT Storage<vtkm::Vec<Type, 4>, StorageTagBasic>;
376 VTKM_STORAGE_EXPORT(
char)
383 VTKM_STORAGE_EXPORT(vtkm::Int64)
384 VTKM_STORAGE_EXPORT(vtkm::UInt64)
388 #undef VTKM_STORAGE_EXPORT
393 #define VTKM_ARRAYHANDLE_EXPORT(Type) \
394 extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<Type, StorageTagBasic>; \
395 extern template class VTKM_CONT_TEMPLATE_EXPORT \
396 ArrayHandle<vtkm::Vec<Type, 2>, StorageTagBasic>; \
397 extern template class VTKM_CONT_TEMPLATE_EXPORT \
398 ArrayHandle<vtkm::Vec<Type, 3>, StorageTagBasic>; \
399 extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<vtkm::Vec<Type, 4>, StorageTagBasic>;
413 #undef VTKM_ARRAYHANDLE_EXPORT
417 #endif // !vtk_m_cont_ArrayHandleBasic_cxx
419 #endif //vtk_m_cont_ArrayHandleBasic_h