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));
104 template <
typename T>
115 vtkm::cont::internal::BufferInfo::Deleter deleter,
116 vtkm::cont::internal::BufferInfo::Reallocater reallocater = internal::InvalidRealloc)
117 :
Superclass(std::vector<
vtkm::cont::internal::Buffer>{ vtkm::cont::internal::MakeBuffer(
121 vtkm::internal::NumberOfValuesToNumberOfBytes<T>(numberOfValues),
131 vtkm::cont::internal::BufferInfo::Deleter deleter,
132 vtkm::cont::internal::BufferInfo::Reallocater reallocater = internal::InvalidRealloc)
133 :
Superclass(std::vector<
vtkm::cont::internal::Buffer>{ vtkm::cont::internal::MakeBuffer(
137 vtkm::internal::NumberOfValuesToNumberOfBytes<T>(numberOfValues),
147 vtkm::cont::internal::BufferInfo::Deleter deleter,
148 vtkm::cont::internal::BufferInfo::Reallocater reallocater = internal::InvalidRealloc)
149 :
Superclass(std::vector<
vtkm::cont::internal::Buffer>{ vtkm::cont::internal::MakeBuffer(
153 vtkm::internal::NumberOfValuesToNumberOfBytes<T>(numberOfValues),
164 vtkm::cont::internal::BufferInfo::Deleter deleter,
165 vtkm::cont::internal::BufferInfo::Reallocater reallocater = internal::InvalidRealloc)
166 :
Superclass(std::vector<
vtkm::cont::internal::Buffer>{ vtkm::cont::internal::MakeBuffer(
170 vtkm::internal::NumberOfValuesToNumberOfBytes<T>(numberOfValues),
184 return reinterpret_cast<const T*
>(this->GetBuffers()[0].ReadPointerHost(token));
189 return this->GetReadPointer(token);
193 return reinterpret_cast<T*
>(this->GetBuffers()[0].WritePointerHost(token));
198 return this->GetWritePointer(token);
203 return reinterpret_cast<const T*
>(this->GetBuffers()[0].ReadPointerDevice(device, token));
208 return this->GetReadPointer(device, token);
212 return reinterpret_cast<T*
>(this->GetBuffers()[0].WritePointerDevice(device, token));
217 return this->GetWritePointer(device, token);
224 template <
typename T>
248 template <
typename T>
252 vtkm::cont::internal::BufferInfo::Deleter deleter = internal::SimpleArrayDeleter<T>,
253 vtkm::cont::internal::BufferInfo::Reallocater reallocater = internal::SimpleArrayReallocater<T>)
262 template <
typename T,
typename Allocator>
279 template <
typename T,
typename Allocator>
282 using vector_type = std::vector<T, Allocator>;
283 vector_type* container =
new vector_type(std::move(array));
286 static_cast<vtkm::Id>(container->size()),
287 internal::StdVectorDeleter<T, Allocator>,
288 internal::StdVectorReallocater<T, Allocator>);
293 template <
typename T,
typename Allocator>
302 template <
typename T>
318 template <
typename T>
319 struct SerializableTypeString<
vtkm::cont::ArrayHandleBasic<T>>
328 template <
typename T>
329 struct SerializableTypeString<ArrayHandle<T,
vtkm::cont::StorageTagBasic>>
330 : SerializableTypeString<vtkm::cont::ArrayHandleBasic<T>>
339 template <
typename T>
340 struct Serialization<
vtkm::cont::ArrayHandleBasic<T>>
342 static VTKM_CONT void save(BinaryBuffer& bb,
351 vtkm::cont::internal::Buffer buffer;
355 vtkm::cont::internal::CreateBuffers(buffer));
359 template <
typename T>
360 struct Serialization<
vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagBasic>>
361 : Serialization<vtkm::cont::ArrayHandleBasic<T>>
368 #ifndef vtk_m_cont_ArrayHandleBasic_cxx
381 #define VTKM_STORAGE_EXPORT(Type) \
382 extern template class VTKM_CONT_TEMPLATE_EXPORT Storage<Type, StorageTagBasic>; \
383 extern template class VTKM_CONT_TEMPLATE_EXPORT Storage<vtkm::Vec<Type, 2>, StorageTagBasic>; \
384 extern template class VTKM_CONT_TEMPLATE_EXPORT Storage<vtkm::Vec<Type, 3>, StorageTagBasic>; \
385 extern template class VTKM_CONT_TEMPLATE_EXPORT Storage<vtkm::Vec<Type, 4>, StorageTagBasic>;
387 VTKM_STORAGE_EXPORT(
char)
399 #undef VTKM_STORAGE_EXPORT
403 #define VTKM_ARRAYHANDLE_EXPORT(Type) \
404 extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<Type, StorageTagBasic>; \
405 extern template class VTKM_CONT_TEMPLATE_EXPORT \
406 ArrayHandle<vtkm::Vec<Type, 2>, StorageTagBasic>; \
407 extern template class VTKM_CONT_TEMPLATE_EXPORT \
408 ArrayHandle<vtkm::Vec<Type, 3>, StorageTagBasic>; \
409 extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<vtkm::Vec<Type, 4>, StorageTagBasic>;
411 VTKM_ARRAYHANDLE_EXPORT(
char)
423 #undef VTKM_ARRAYHANDLE_EXPORT
429 #endif // !vtk_m_cont_ArrayHandleBasic_cxx
431 #endif //vtk_m_cont_ArrayHandleBasic_h
typename vtkm::cont::detail::GetTypeInParentheses< void(ArrayHandle< T, vtkm::cont::StorageTagBasic >) >::type Superclass
Definition: ArrayHandleBasic.h:110
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:719
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 access to the ArrayHandle's data.
Definition: ArrayHandleBasic.h:214
const T * GetReadPointer(vtkm::cont::DeviceAdapterId device) const
Gets raw access to the ArrayHandle's data.
Definition: ArrayHandleBasic.h:205
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:159
const T * GetReadPointer(vtkm::cont::Token &token) const
Gets raw access to the ArrayHandle's data.
Definition: ArrayHandleBasic.h:182
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:249
vtkm::Int64 BufferSizeType
Definition: DeviceAdapterMemoryManager.h:27
T * GetWritePointer(vtkm::cont::Token &token) const
Gets raw access to the ArrayHandle's data.
Definition: ArrayHandleBasic.h:191
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:127
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:143
const T * GetReadPointer(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Gets raw access to the ArrayHandle's data.
Definition: ArrayHandleBasic.h:201
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 access to the ArrayHandle's data.
Definition: ArrayHandleBasic.h:210
#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:112
An object used to specify a device.
Definition: DeviceAdapterTag.h:58
T * GetWritePointer() const
Gets raw access to the ArrayHandle's data.
Definition: ArrayHandleBasic.h:195
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:488
Definition: ArrayHandleBasic.h:105
#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:225
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:452