Go to the documentation of this file.
18 #ifndef viskores_cont_ArrayHandleBasic_h
19 #define viskores_cont_ArrayHandleBasic_h
42 class VISKORES_ALWAYS_EXPORT Storage<T,
viskores::cont::StorageTagBasic>
45 using ReadPortalType = viskores::internal::ArrayPortalBasicRead<T>;
46 using WritePortalType = viskores::internal::ArrayPortalBasicWrite<T>;
48 VISKORES_CONT static std::vector<viskores::cont::internal::Buffer> CreateBuffers()
50 return std::vector<viskores::cont::internal::Buffer>(1);
55 const std::vector<viskores::cont::internal::Buffer>& buffers,
59 buffers[0].SetNumberOfBytes(
60 viskores::internal::NumberOfValuesToNumberOfBytes<T>(numValues), preserve, token);
64 const std::vector<viskores::cont::internal::Buffer>&)
70 const std::vector<viskores::cont::internal::Buffer>& buffers)
73 return static_cast<viskores::Id>(buffers[0].GetNumberOfBytes() /
77 VISKORES_CONT static void Fill(
const std::vector<viskores::cont::internal::Buffer>& buffers,
87 &fillValue, fillValueSize, startIndex * fillValueSize, endIndex * fillValueSize, token);
91 const std::vector<viskores::cont::internal::Buffer>& buffers,
96 return ReadPortalType(
reinterpret_cast<const T*
>(buffers[0].ReadPointerDevice(device, token)),
97 GetNumberOfValues(buffers));
101 const std::vector<viskores::cont::internal::Buffer>& buffers,
106 return WritePortalType(
reinterpret_cast<T*
>(buffers[0].WritePointerDevice(device, token)),
107 GetNumberOfValues(buffers));
119 template <
typename T>
121 :
public ArrayHandle<T, viskores::cont::StorageTagBasic>
131 viskores::cont::internal::BufferInfo::Deleter deleter,
132 viskores::cont::internal::BufferInfo::Reallocater reallocater = internal::InvalidRealloc)
134 std::vector<
viskores::cont::internal::Buffer>{ viskores::cont::internal::MakeBuffer(
138 viskores::internal::NumberOfValuesToNumberOfBytes<T>(numberOfValues),
148 viskores::cont::internal::BufferInfo::Deleter deleter,
149 viskores::cont::internal::BufferInfo::Reallocater reallocater = internal::InvalidRealloc)
151 std::vector<
viskores::cont::internal::Buffer>{ viskores::cont::internal::MakeBuffer(
155 viskores::internal::NumberOfValuesToNumberOfBytes<T>(numberOfValues),
165 viskores::cont::internal::BufferInfo::Deleter deleter,
166 viskores::cont::internal::BufferInfo::Reallocater reallocater = internal::InvalidRealloc)
168 std::vector<
viskores::cont::internal::Buffer>{ viskores::cont::internal::MakeBuffer(
172 viskores::internal::NumberOfValuesToNumberOfBytes<T>(numberOfValues),
183 viskores::cont::internal::BufferInfo::Deleter deleter,
184 viskores::cont::internal::BufferInfo::Reallocater reallocater = internal::InvalidRealloc)
186 std::vector<
viskores::cont::internal::Buffer>{ viskores::cont::internal::MakeBuffer(
190 viskores::internal::NumberOfValuesToNumberOfBytes<T>(numberOfValues),
203 return this->GetReadPointer(token);
212 return reinterpret_cast<const T*
>(this->GetBuffers()[0].ReadPointerHost(token));
221 return this->GetWritePointer(token);
230 return reinterpret_cast<T*
>(this->GetBuffers()[0].WritePointerHost(token));
243 return this->GetReadPointer(device, token);
255 return reinterpret_cast<const T*
>(this->GetBuffers()[0].ReadPointerDevice(device, token));
267 return this->GetWritePointer(device, token);
278 return reinterpret_cast<T*
>(this->GetBuffers()[0].WritePointerDevice(device, token));
284 template <
typename T>
294 array + numberOfValues,
309 template <
typename T>
313 viskores::cont::internal::BufferInfo::Deleter deleter = internal::SimpleArrayDeleter<T>,
314 viskores::cont::internal::BufferInfo::Reallocater reallocater =
315 internal::SimpleArrayReallocater<T>)
324 template <
typename T,
typename Allocator>
326 const std::vector<T, Allocator>& array,
342 template <
typename T,
typename Allocator>
344 std::vector<T, Allocator>&& array)
346 using vector_type = std::vector<T, Allocator>;
347 vector_type* container =
new vector_type(std::move(array));
351 internal::StdVectorDeleter<T, Allocator>,
352 internal::StdVectorReallocater<T, Allocator>);
357 template <
typename T,
typename Allocator>
359 std::vector<T, Allocator>&& array,
367 template <
typename T>
369 std::initializer_list<T>&& values)
385 template <
typename T>
386 struct SerializableTypeString<
viskores::cont::ArrayHandleBasic<T>>
395 template <
typename T>
396 struct SerializableTypeString<ArrayHandle<T,
viskores::cont::StorageTagBasic>>
397 : SerializableTypeString<viskores::cont::ArrayHandleBasic<T>>
406 template <
typename T>
407 struct Serialization<
viskores::cont::ArrayHandleBasic<T>>
420 viskores::cont::internal::Buffer buffer;
424 viskores::cont::internal::CreateBuffers(buffer));
428 template <
typename T>
429 struct Serialization<
viskores::cont::ArrayHandle<T, viskores::cont::StorageTagBasic>>
430 : Serialization<viskores::cont::ArrayHandleBasic<T>>
437 #ifndef viskores_cont_ArrayHandleBasic_cxx
450 #define VISKORES_STORAGE_EXPORT(Type) \
451 extern template class VISKORES_CONT_TEMPLATE_EXPORT Storage<Type, StorageTagBasic>; \
452 extern template class VISKORES_CONT_TEMPLATE_EXPORT \
453 Storage<viskores::Vec<Type, 2>, StorageTagBasic>; \
454 extern template class VISKORES_CONT_TEMPLATE_EXPORT \
455 Storage<viskores::Vec<Type, 3>, StorageTagBasic>; \
456 extern template class VISKORES_CONT_TEMPLATE_EXPORT \
457 Storage<viskores::Vec<Type, 4>, StorageTagBasic>;
459 VISKORES_STORAGE_EXPORT(
char)
471 #undef VISKORES_STORAGE_EXPORT
475 #define VISKORES_ARRAYHANDLE_EXPORT(Type) \
476 extern template class VISKORES_CONT_TEMPLATE_EXPORT ArrayHandle<Type, StorageTagBasic>; \
477 extern template class VISKORES_CONT_TEMPLATE_EXPORT \
478 ArrayHandle<viskores::Vec<Type, 2>, StorageTagBasic>; \
479 extern template class VISKORES_CONT_TEMPLATE_EXPORT \
480 ArrayHandle<viskores::Vec<Type, 3>, StorageTagBasic>; \
481 extern template class VISKORES_CONT_TEMPLATE_EXPORT \
482 ArrayHandle<viskores::Vec<Type, 4>, StorageTagBasic>;
484 VISKORES_ARRAYHANDLE_EXPORT(
char)
496 #undef VISKORES_ARRAYHANDLE_EXPORT
502 #endif // !viskores_cont_ArrayHandleBasic_cxx
504 #endif //viskores_cont_ArrayHandleBasic_h
T load(const U &u, viskores::Id v)
Definition: FetchTagArrayDirectIn.h:44
Treat a Vec or Vec-like object as a flat Vec.
Definition: VecFlat.h:240
int16_t Int16
Base type to use for 16-bit signed integer numbers.
Definition: Types.h:181
ArrayHandleBasic(T *array, void *container, viskores::Id numberOfValues, viskores::cont::DeviceAdapterId device, viskores::cont::internal::BufferInfo::Deleter deleter, viskores::cont::internal::BufferInfo::Reallocater reallocater=internal::InvalidRealloc)
Definition: ArrayHandleBasic.h:178
int8_t Int8
Base type to use for 8-bit signed integer numbers.
Definition: Types.h:173
#define viskoresNotUsed(parameter_name)
Simple macro to identify a parameter as unused.
Definition: ExportMacros.h:136
const T * GetReadPointer() const
Gets raw access to the ArrayHandle's data.
Definition: ArrayHandleBasic.h:200
Manages an array-worth of data.
Definition: ArrayHandle.h:313
const T * GetReadPointer(viskores::cont::DeviceAdapterId device, viskores::cont::Token &token) const
Gets raw access to the ArrayHandle's data.
Definition: ArrayHandleBasic.h:252
uint16_t UInt16
Base type to use for 16-bit unsigned integer numbers.
Definition: Types.h:185
typename viskores::cont::detail::GetTypeInParentheses< void(ArrayHandle< T, viskores::cont::StorageTagBasic >) >::type Superclass
Definition: ArrayHandleBasic.h:126
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
const T * GetReadPointer(viskores::cont::DeviceAdapterId device) const
Gets raw access to the ArrayHandle's data on a particular device.
Definition: ArrayHandleBasic.h:240
const T * GetReadPointer(viskores::cont::Token &token) const
Gets raw access to the ArrayHandle's data.
Definition: ArrayHandleBasic.h:210
T * GetWritePointer() const
Gets raw write access to the ArrayHandle's data.
Definition: ArrayHandleBasic.h:218
viskores::cont::ArrayHandleBasic< T > make_ArrayHandleMove(T *&array, viskores::Id numberOfValues, viskores::cont::internal::BufferInfo::Deleter deleter=internal::SimpleArrayDeleter< T >, viskores::cont::internal::BufferInfo::Reallocater reallocater=internal::SimpleArrayReallocater< T >)
A convenience function to move a user-allocated array into an ArrayHandle.
Definition: ArrayHandleBasic.h:310
Definition: Particle.h:373
ArrayHandleBasic(T *array, void *container, viskores::Id numberOfValues, viskores::cont::internal::BufferInfo::Deleter deleter, viskores::cont::internal::BufferInfo::Reallocater reallocater=internal::InvalidRealloc)
Definition: ArrayHandleBasic.h:161
signed long long Int64
Base type to use for 64-bit signed integer numbers.
Definition: Types.h:212
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
#define VISKORES_CONT
Definition: ExportMacros.h:65
Groups connected points that have the same field value.
Definition: Atomic.h:27
float Float32
Base type to use for 32-bit floating-point numbers.
Definition: Types.h:165
viskores::cont::ArrayPortalToIterators< PortalType >::IteratorType ArrayPortalToIteratorBegin(const PortalType &portal)
Convenience function for converting an ArrayPortal to a begin iterator.
Definition: ArrayPortalToIterators.h:189
void Allocate(viskores::Id numberOfValues, viskores::CopyFlag preserve, viskores::cont::Token &token) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:504
Basic array storage for an array handle.
Definition: ArrayHandleBasic.h:120
Tag for a device adapter used to avoid specifying a device.
Definition: DeviceAdapterTag.h:201
#define VISKORES_ASSERT(condition)
Definition: Assert.h:51
WritePortalType WritePortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:468
viskores::Int64 BufferSizeType
Definition: DeviceAdapterMemoryManager.h:35
ArrayHandleBasic(T *array, viskores::Id numberOfValues, viskores::cont::DeviceAdapterId device, viskores::cont::internal::BufferInfo::Deleter deleter, viskores::cont::internal::BufferInfo::Reallocater reallocater=internal::InvalidRealloc)
Definition: ArrayHandleBasic.h:144
unsigned long long UInt64
Base type to use for 64-bit signed integer numbers.
Definition: Types.h:215
uint8_t UInt8
Base type to use for 8-bit unsigned integer numbers.
Definition: Types.h:177
An object used to specify a device.
Definition: DeviceAdapterTag.h:66
int32_t Int32
Base type to use for 32-bit signed integer numbers.
Definition: Types.h:189
T * GetWritePointer(viskores::cont::DeviceAdapterId device) const
Gets raw write access to the ArrayHandle's data.
Definition: ArrayHandleBasic.h:264
T * GetWritePointer(viskores::cont::DeviceAdapterId device, viskores::cont::Token &token) const
Gets raw write access to the ArrayHandle's data.
Definition: ArrayHandleBasic.h:276
#define VISKORES_ARRAY_HANDLE_SUBCLASS(classname, fullclasstype, superclass)
Macro to make default methods in ArrayHandle subclasses.
Definition: ArrayHandle.h:256
T * GetWritePointer(viskores::cont::Token &token) const
Gets raw write access to the ArrayHandle's data.
Definition: ArrayHandleBasic.h:228
auto Get(const viskores::Tuple< Ts... > &tuple)
Retrieve the object from a viskores::Tuple at the given index.
Definition: Tuple.h:89
ArrayHandleBasic(T *array, viskores::Id numberOfValues, viskores::cont::internal::BufferInfo::Deleter deleter, viskores::cont::internal::BufferInfo::Reallocater reallocater=internal::InvalidRealloc)
Definition: ArrayHandleBasic.h:128
CopyFlag
Identifier used to specify whether a function should deep copy data.
Definition: Flags.h:25
double Float64
Base type to use for 64-bit floating-point numbers.
Definition: Types.h:169
viskores::cont::ArrayHandleBasic< T > make_ArrayHandle(const T *array, viskores::Id numberOfValues, viskores::CopyFlag copy)
A convenience function for creating an ArrayHandle from a standard C array.
Definition: ArrayHandleBasic.h:285
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:43
const std::vector< viskores::cont::internal::Buffer > & GetBuffers() const
Returns the internal Buffer structures that hold the data.
Definition: ArrayHandle.h:738
uint32_t UInt32
Base type to use for 32-bit unsigned integer numbers.
Definition: Types.h:193