Go to the documentation of this file.
10 #ifndef vtk_m_cont_ArrayHandleBasic_h
11 #define vtk_m_cont_ArrayHandleBasic_h
37 using ReadPortalType = vtkm::internal::ArrayPortalBasicRead<T>;
38 using WritePortalType = vtkm::internal::ArrayPortalBasicWrite<T>;
40 VTKM_CONT static std::vector<vtkm::cont::internal::Buffer> CreateBuffers()
42 return std::vector<vtkm::cont::internal::Buffer>(1);
46 const std::vector<vtkm::cont::internal::Buffer>& buffers,
50 buffers[0].SetNumberOfBytes(
51 vtkm::internal::NumberOfValuesToNumberOfBytes<T>(numValues), preserve, token);
55 const std::vector<vtkm::cont::internal::Buffer>&)
61 const std::vector<vtkm::cont::internal::Buffer>& buffers)
64 return static_cast<vtkm::Id>(buffers[0].GetNumberOfBytes() /
68 VTKM_CONT static void Fill(
const std::vector<vtkm::cont::internal::Buffer>& buffers,
78 &fillValue, fillValueSize, startIndex * fillValueSize, endIndex * fillValueSize, token);
81 VTKM_CONT static ReadPortalType CreateReadPortal(
82 const std::vector<vtkm::cont::internal::Buffer>& buffers,
87 return ReadPortalType(
reinterpret_cast<const T*
>(buffers[0].ReadPointerDevice(device, token)),
88 GetNumberOfValues(buffers));
91 VTKM_CONT static WritePortalType CreateWritePortal(
92 const std::vector<vtkm::cont::internal::Buffer>& buffers,
97 return WritePortalType(
reinterpret_cast<T*
>(buffers[0].WritePointerDevice(device, token)),
98 GetNumberOfValues(buffers));
110 template <
typename T>
121 vtkm::cont::internal::BufferInfo::Deleter deleter,
122 vtkm::cont::internal::BufferInfo::Reallocater reallocater = internal::InvalidRealloc)
123 :
Superclass(std::vector<
vtkm::cont::internal::Buffer>{ vtkm::cont::internal::MakeBuffer(
127 vtkm::internal::NumberOfValuesToNumberOfBytes<T>(numberOfValues),
137 vtkm::cont::internal::BufferInfo::Deleter deleter,
138 vtkm::cont::internal::BufferInfo::Reallocater reallocater = internal::InvalidRealloc)
139 :
Superclass(std::vector<
vtkm::cont::internal::Buffer>{ vtkm::cont::internal::MakeBuffer(
143 vtkm::internal::NumberOfValuesToNumberOfBytes<T>(numberOfValues),
153 vtkm::cont::internal::BufferInfo::Deleter deleter,
154 vtkm::cont::internal::BufferInfo::Reallocater reallocater = internal::InvalidRealloc)
155 :
Superclass(std::vector<
vtkm::cont::internal::Buffer>{ vtkm::cont::internal::MakeBuffer(
159 vtkm::internal::NumberOfValuesToNumberOfBytes<T>(numberOfValues),
170 vtkm::cont::internal::BufferInfo::Deleter deleter,
171 vtkm::cont::internal::BufferInfo::Reallocater reallocater = internal::InvalidRealloc)
172 :
Superclass(std::vector<
vtkm::cont::internal::Buffer>{ vtkm::cont::internal::MakeBuffer(
176 vtkm::internal::NumberOfValuesToNumberOfBytes<T>(numberOfValues),
189 return this->GetReadPointer(token);
198 return reinterpret_cast<const T*
>(this->GetBuffers()[0].ReadPointerHost(token));
207 return this->GetWritePointer(token);
216 return reinterpret_cast<T*
>(this->GetBuffers()[0].WritePointerHost(token));
229 return this->GetReadPointer(device, token);
240 return reinterpret_cast<const T*
>(this->GetBuffers()[0].ReadPointerDevice(device, token));
252 return this->GetWritePointer(device, token);
263 return reinterpret_cast<T*
>(this->GetBuffers()[0].WritePointerDevice(device, token));
269 template <
typename T>
293 template <
typename T>
297 vtkm::cont::internal::BufferInfo::Deleter deleter = internal::SimpleArrayDeleter<T>,
298 vtkm::cont::internal::BufferInfo::Reallocater reallocater = internal::SimpleArrayReallocater<T>)
307 template <
typename T,
typename Allocator>
324 template <
typename T,
typename Allocator>
327 using vector_type = std::vector<T, Allocator>;
328 vector_type* container =
new vector_type(std::move(array));
331 static_cast<vtkm::Id>(container->size()),
332 internal::StdVectorDeleter<T, Allocator>,
333 internal::StdVectorReallocater<T, Allocator>);
338 template <
typename T,
typename Allocator>
347 template <
typename T>
363 template <
typename T>
364 struct SerializableTypeString<
vtkm::cont::ArrayHandleBasic<T>>
373 template <
typename T>
374 struct SerializableTypeString<ArrayHandle<T,
vtkm::cont::StorageTagBasic>>
375 : SerializableTypeString<vtkm::cont::ArrayHandleBasic<T>>
384 template <
typename T>
385 struct Serialization<
vtkm::cont::ArrayHandleBasic<T>>
387 static VTKM_CONT void save(BinaryBuffer& bb,
396 vtkm::cont::internal::Buffer buffer;
400 vtkm::cont::internal::CreateBuffers(buffer));
404 template <
typename T>
405 struct Serialization<
vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagBasic>>
406 : Serialization<vtkm::cont::ArrayHandleBasic<T>>
413 #ifndef vtk_m_cont_ArrayHandleBasic_cxx
426 #define VTKM_STORAGE_EXPORT(Type) \
427 extern template class VTKM_CONT_TEMPLATE_EXPORT Storage<Type, StorageTagBasic>; \
428 extern template class VTKM_CONT_TEMPLATE_EXPORT Storage<vtkm::Vec<Type, 2>, StorageTagBasic>; \
429 extern template class VTKM_CONT_TEMPLATE_EXPORT Storage<vtkm::Vec<Type, 3>, StorageTagBasic>; \
430 extern template class VTKM_CONT_TEMPLATE_EXPORT Storage<vtkm::Vec<Type, 4>, StorageTagBasic>;
432 VTKM_STORAGE_EXPORT(
char)
444 #undef VTKM_STORAGE_EXPORT
448 #define VTKM_ARRAYHANDLE_EXPORT(Type) \
449 extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<Type, StorageTagBasic>; \
450 extern template class VTKM_CONT_TEMPLATE_EXPORT \
451 ArrayHandle<vtkm::Vec<Type, 2>, StorageTagBasic>; \
452 extern template class VTKM_CONT_TEMPLATE_EXPORT \
453 ArrayHandle<vtkm::Vec<Type, 3>, StorageTagBasic>; \
454 extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<vtkm::Vec<Type, 4>, StorageTagBasic>;
456 VTKM_ARRAYHANDLE_EXPORT(
char)
468 #undef VTKM_ARRAYHANDLE_EXPORT
474 #endif // !vtk_m_cont_ArrayHandleBasic_cxx
476 #endif //vtk_m_cont_ArrayHandleBasic_h
typename vtkm::cont::detail::GetTypeInParentheses< void(ArrayHandle< T, vtkm::cont::StorageTagBasic >) >::type Superclass
Definition: ArrayHandleBasic.h:116
Manages an array-worth of data.
Definition: ArrayHandle.h:300
const T * GetReadPointer() const
Gets raw access to the ArrayHandle's data.
Definition: ArrayHandleBasic.h:186
const std::vector< vtkm::cont::internal::Buffer > & GetBuffers() const
Returns the internal Buffer structures that hold the data.
Definition: ArrayHandle.h:721
T load(const U &u, vtkm::Id v)
Definition: FetchTagArrayDirectIn.h:36
Groups connected points that have the same field value.
Definition: Atomic.h:19
auto Get(const vtkm::Tuple< Ts... > &tuple)
Retrieve the object from a vtkm::Tuple at the given index.
Definition: Tuple.h:81
#define VTKM_ARRAY_HANDLE_SUBCLASS(classname, fullclasstype, superclass)
Macro to make default methods in ArrayHandle subclasses.
Definition: ArrayHandle.h:243
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
T * GetWritePointer(vtkm::cont::DeviceAdapterId device) const
Gets raw write access to the ArrayHandle's data.
Definition: ArrayHandleBasic.h:249
const T * GetReadPointer(vtkm::cont::DeviceAdapterId device) const
Gets raw access to the ArrayHandle's data on a particular device.
Definition: ArrayHandleBasic.h:226
int16_t Int16
Base type to use for 16-bit signed integer numbers.
Definition: Types.h:173
ArrayHandleBasic(T *array, void *container, vtkm::Id numberOfValues, vtkm::cont::DeviceAdapterId device, vtkm::cont::internal::BufferInfo::Deleter deleter, vtkm::cont::internal::BufferInfo::Reallocater reallocater=internal::InvalidRealloc)
Definition: ArrayHandleBasic.h:165
const T * GetReadPointer(vtkm::cont::Token &token) const
Gets raw access to the ArrayHandle's data.
Definition: ArrayHandleBasic.h:196
vtkm::cont::ArrayHandleBasic< T > make_ArrayHandleMove(T *&array, vtkm::Id numberOfValues, vtkm::cont::internal::BufferInfo::Deleter deleter=internal::SimpleArrayDeleter< T >, vtkm::cont::internal::BufferInfo::Reallocater reallocater=internal::SimpleArrayReallocater< T >)
A convenience function to move a user-allocated array into an ArrayHandle.
Definition: ArrayHandleBasic.h:294
vtkm::Int64 BufferSizeType
Definition: DeviceAdapterMemoryManager.h:27
T * GetWritePointer(vtkm::cont::Token &token) const
Gets raw write access to the ArrayHandle's data.
Definition: ArrayHandleBasic.h:214
Definition: Particle.h:351
ArrayHandleBasic(T *array, vtkm::Id numberOfValues, vtkm::cont::DeviceAdapterId device, vtkm::cont::internal::BufferInfo::Deleter deleter, vtkm::cont::internal::BufferInfo::Reallocater reallocater=internal::InvalidRealloc)
Definition: ArrayHandleBasic.h:133
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
ArrayHandleBasic(T *array, void *container, vtkm::Id numberOfValues, vtkm::cont::internal::BufferInfo::Deleter deleter, vtkm::cont::internal::BufferInfo::Reallocater reallocater=internal::InvalidRealloc)
Definition: ArrayHandleBasic.h:149
const T * GetReadPointer(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Gets raw access to the ArrayHandle's data.
Definition: ArrayHandleBasic.h:238
int8_t Int8
Base type to use for 8-bit signed integer numbers.
Definition: Types.h:165
T * GetWritePointer(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Gets raw write access to the ArrayHandle's data.
Definition: ArrayHandleBasic.h:261
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
signed long long Int64
Base type to use for 64-bit signed integer numbers.
Definition: Types.h:204
Treat a Vec or Vec-like object as a flat Vec.
Definition: VecFlat.h:224
uint8_t UInt8
Base type to use for 8-bit unsigned integer numbers.
Definition: Types.h:169
#define vtkmNotUsed(parameter_name)
Simple macro to identify a parameter as unused.
Definition: ExportMacros.h:128
ArrayHandleBasic(T *array, vtkm::Id numberOfValues, vtkm::cont::internal::BufferInfo::Deleter deleter, vtkm::cont::internal::BufferInfo::Reallocater reallocater=internal::InvalidRealloc)
Definition: ArrayHandleBasic.h:118
An object used to specify a device.
Definition: DeviceAdapterTag.h:58
T * GetWritePointer() const
Gets raw write access to the ArrayHandle's data.
Definition: ArrayHandleBasic.h:204
uint32_t UInt32
Base type to use for 32-bit unsigned integer numbers.
Definition: Types.h:185
Tag for a device adapter used to avoid specifying a device.
Definition: DeviceAdapterTag.h:187
float Float32
Base type to use for 32-bit floating-point numbers.
Definition: Types.h:157
unsigned long long UInt64
Base type to use for 64-bit signed integer numbers.
Definition: Types.h:207
vtkm::cont::ArrayPortalToIterators< PortalType >::IteratorType ArrayPortalToIteratorBegin(const PortalType &portal)
Convenience function for converting an ArrayPortal to a begin iterator.
Definition: ArrayPortalToIterators.h:178
int32_t Int32
Base type to use for 32-bit signed integer numbers.
Definition: Types.h:181
double Float64
Base type to use for 64-bit floating-point numbers.
Definition: Types.h:161
CopyFlag
Identifier used to specify whether a function should deep copy data.
Definition: Flags.h:17
void Allocate(vtkm::Id numberOfValues, vtkm::CopyFlag preserve, vtkm::cont::Token &token) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:490
Basic array storage for an array handle.
Definition: ArrayHandleBasic.h:111
#define VTKM_ALWAYS_EXPORT
Definition: ExportMacros.h:89
vtkm::cont::ArrayHandleBasic< T > make_ArrayHandle(const T *array, vtkm::Id numberOfValues, vtkm::CopyFlag copy)
A convenience function for creating an ArrayHandle from a standard C array.
Definition: ArrayHandleBasic.h:270
uint16_t UInt16
Base type to use for 16-bit unsigned integer numbers.
Definition: Types.h:177
WritePortalType WritePortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:454