VTK-m  2.0
ArrayHandleSOA.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 #ifndef vtk_m_cont_ArrayHandleSOA_h
11 #define vtk_m_cont_ArrayHandleSOA_h
12 
14 #include <vtkm/cont/ArrayHandle.h>
15 
16 #include <vtkm/Math.h>
17 #include <vtkm/VecTraits.h>
18 
21 
22 #include <vtkmstd/integer_sequence.h>
23 
24 #include <array>
25 #include <limits>
26 #include <type_traits>
27 
28 namespace vtkm
29 {
30 
31 namespace internal
32 {
33 
38 template <typename ValueType_, typename ComponentPortalType>
39 class ArrayPortalSOA
40 {
41 public:
42  using ValueType = ValueType_;
43 
44 private:
45  using ComponentType = typename ComponentPortalType::ValueType;
46 
48  using VTraits = vtkm::VecTraits<ValueType>;
49  VTKM_STATIC_ASSERT((std::is_same<typename VTraits::ComponentType, ComponentType>::value));
50  static constexpr vtkm::IdComponent NUM_COMPONENTS = VTraits::NUM_COMPONENTS;
51 
52  ComponentPortalType Portals[NUM_COMPONENTS];
53  vtkm::Id NumberOfValues;
54 
55 public:
57  VTKM_EXEC_CONT explicit ArrayPortalSOA(vtkm::Id numValues = 0)
58  : NumberOfValues(numValues)
59  {
60  }
61 
63  VTKM_EXEC_CONT void SetPortal(vtkm::IdComponent index, const ComponentPortalType& portal)
64  {
65  this->Portals[index] = portal;
66  }
67 
68  VTKM_EXEC_CONT vtkm::Id GetNumberOfValues() const { return this->NumberOfValues; }
69 
70  template <typename SPT = ComponentPortalType,
71  typename Supported = typename vtkm::internal::PortalSupportsGets<SPT>::type,
72  typename = typename std::enable_if<Supported::value>::type>
73  VTKM_EXEC_CONT ValueType Get(vtkm::Id valueIndex) const
74  {
75  return this->Get(valueIndex, vtkmstd::make_index_sequence<NUM_COMPONENTS>());
76  }
77 
78  template <typename SPT = ComponentPortalType,
79  typename Supported = typename vtkm::internal::PortalSupportsSets<SPT>::type,
80  typename = typename std::enable_if<Supported::value>::type>
81  VTKM_EXEC_CONT void Set(vtkm::Id valueIndex, const ValueType& value) const
82  {
83  this->Set(valueIndex, value, vtkmstd::make_index_sequence<NUM_COMPONENTS>());
84  }
85 
86 private:
88  template <std::size_t I>
89  VTKM_EXEC_CONT ComponentType GetComponent(vtkm::Id valueIndex) const
90  {
91  return this->Portals[I].Get(valueIndex);
92  }
93 
94  template <std::size_t... I>
95  VTKM_EXEC_CONT ValueType Get(vtkm::Id valueIndex, vtkmstd::index_sequence<I...>) const
96  {
97  return ValueType{ this->GetComponent<I>(valueIndex)... };
98  }
99 
101  template <std::size_t I>
102  VTKM_EXEC_CONT bool SetComponent(vtkm::Id valueIndex, const ValueType& value) const
103  {
104  this->Portals[I].Set(valueIndex,
105  VTraits::GetComponent(value, static_cast<vtkm::IdComponent>(I)));
106  return true;
107  }
108 
109  template <std::size_t... I>
110  VTKM_EXEC_CONT void Set(vtkm::Id valueIndex,
111  const ValueType& value,
112  vtkmstd::index_sequence<I...>) const
113  {
114  // Is there a better way to unpack an expression and execute them with no other side effects?
115  (void)std::initializer_list<bool>{ this->SetComponent<I>(valueIndex, value)... };
116  }
117 };
118 
119 } // namespace internal
120 
121 namespace cont
122 {
123 
125 {
126 };
127 
128 namespace internal
129 {
130 
131 template <typename ComponentType, vtkm::IdComponent NUM_COMPONENTS>
132 class VTKM_ALWAYS_EXPORT
133  Storage<vtkm::Vec<ComponentType, NUM_COMPONENTS>, vtkm::cont::StorageTagSOA>
134 {
136 
137 public:
138  using ReadPortalType =
139  vtkm::internal::ArrayPortalSOA<ValueType, vtkm::internal::ArrayPortalBasicRead<ComponentType>>;
140  using WritePortalType =
141  vtkm::internal::ArrayPortalSOA<ValueType, vtkm::internal::ArrayPortalBasicWrite<ComponentType>>;
142 
143  VTKM_CONT static std::vector<vtkm::cont::internal::Buffer> CreateBuffers()
144  {
145  return std::vector<vtkm::cont::internal::Buffer>(static_cast<std::size_t>(NUM_COMPONENTS));
146  }
147 
148  VTKM_CONT static void ResizeBuffers(vtkm::Id numValues,
149  const std::vector<vtkm::cont::internal::Buffer>& buffers,
150  vtkm::CopyFlag preserve,
151  vtkm::cont::Token& token)
152  {
153  vtkm::BufferSizeType numBytes =
154  vtkm::internal::NumberOfValuesToNumberOfBytes<ComponentType>(numValues);
155  for (vtkm::IdComponent componentIndex = 0; componentIndex < NUM_COMPONENTS; ++componentIndex)
156  {
157  buffers[componentIndex].SetNumberOfBytes(numBytes, preserve, token);
158  }
159  }
160 
161  VTKM_CONT static vtkm::Id GetNumberOfValues(
162  const std::vector<vtkm::cont::internal::Buffer>& buffers)
163  {
164  // Assume all buffers are the same size.
165  return static_cast<vtkm::Id>(buffers[0].GetNumberOfBytes()) /
166  static_cast<vtkm::Id>(sizeof(ComponentType));
167  }
168 
169  VTKM_CONT static void Fill(const std::vector<vtkm::cont::internal::Buffer>& buffers,
170  const ValueType& fillValue,
171  vtkm::Id startIndex,
172  vtkm::Id endIndex,
173  vtkm::cont::Token& token)
174  {
175  constexpr vtkm::BufferSizeType sourceSize =
176  static_cast<vtkm::BufferSizeType>(sizeof(ComponentType));
177  vtkm::BufferSizeType startByte = startIndex * sourceSize;
178  vtkm::BufferSizeType endByte = endIndex * sourceSize;
179  for (vtkm::IdComponent componentIndex = 0; componentIndex < NUM_COMPONENTS; ++componentIndex)
180  {
181  ComponentType source = fillValue[componentIndex];
182  buffers[componentIndex].Fill(&source, sourceSize, startByte, endByte, token);
183  }
184  }
185 
186  VTKM_CONT static ReadPortalType CreateReadPortal(
187  const std::vector<vtkm::cont::internal::Buffer>& buffers,
189  vtkm::cont::Token& token)
190  {
191  vtkm::Id numValues = GetNumberOfValues(buffers);
192  ReadPortalType portal(numValues);
193  for (vtkm::IdComponent componentIndex = 0; componentIndex < NUM_COMPONENTS; ++componentIndex)
194  {
195  VTKM_ASSERT(buffers[0].GetNumberOfBytes() == buffers[componentIndex].GetNumberOfBytes());
196  portal.SetPortal(componentIndex,
197  vtkm::internal::ArrayPortalBasicRead<ComponentType>(
198  reinterpret_cast<const ComponentType*>(
199  buffers[componentIndex].ReadPointerDevice(device, token)),
200  numValues));
201  }
202  return portal;
203  }
204 
205  VTKM_CONT static WritePortalType CreateWritePortal(
206  const std::vector<vtkm::cont::internal::Buffer>& buffers,
208  vtkm::cont::Token& token)
209  {
210  vtkm::Id numValues = GetNumberOfValues(buffers);
211  WritePortalType portal(numValues);
212  for (vtkm::IdComponent componentIndex = 0; componentIndex < NUM_COMPONENTS; ++componentIndex)
213  {
214  VTKM_ASSERT(buffers[0].GetNumberOfBytes() == buffers[componentIndex].GetNumberOfBytes());
215  portal.SetPortal(componentIndex,
216  vtkm::internal::ArrayPortalBasicWrite<ComponentType>(
217  reinterpret_cast<ComponentType*>(
218  buffers[componentIndex].WritePointerDevice(device, token)),
219  numValues));
220  }
221  return portal;
222  }
223 };
224 
225 } // namespace internal
226 
244 template <typename T>
245 class ArrayHandleSOA : public ArrayHandle<T, vtkm::cont::StorageTagSOA>
246 {
249 
250  using StorageType = vtkm::cont::internal::Storage<T, vtkm::cont::StorageTagSOA>;
251 
253 
254 public:
258 
259  ArrayHandleSOA(std::initializer_list<vtkm::cont::internal::Buffer>&& componentBuffers)
260  : Superclass(std::move(componentBuffers))
261  {
262  }
263 
264  ArrayHandleSOA(const std::array<ComponentArrayType, NUM_COMPONENTS>& componentArrays)
265  {
266  for (vtkm::IdComponent componentIndex = 0; componentIndex < NUM_COMPONENTS; ++componentIndex)
267  {
268  this->SetArray(componentIndex, componentArrays[componentIndex]);
269  }
270  }
271 
272  ArrayHandleSOA(const std::vector<ComponentArrayType>& componentArrays)
273  {
274  VTKM_ASSERT(componentArrays.size() == NUM_COMPONENTS);
275  for (vtkm::IdComponent componentIndex = 0; componentIndex < NUM_COMPONENTS; ++componentIndex)
276  {
277  this->SetArray(componentIndex, componentArrays[componentIndex]);
278  }
279  }
280 
281  ArrayHandleSOA(std::initializer_list<ComponentArrayType>&& componentArrays)
282  {
283  VTKM_ASSERT(componentArrays.size() == NUM_COMPONENTS);
284  vtkm::IdComponent componentIndex = 0;
285  for (auto&& array : componentArrays)
286  {
287  this->SetArray(componentIndex, array);
288  ++componentIndex;
289  }
290  }
291 
292  ArrayHandleSOA(std::initializer_list<std::vector<ComponentType>>&& componentVectors)
293  {
294  VTKM_ASSERT(componentVectors.size() == NUM_COMPONENTS);
295  vtkm::IdComponent componentIndex = 0;
296  for (auto&& vector : componentVectors)
297  {
298  // Note, std::vectors that come from std::initializer_list must be copied because the scope
299  // of the objects in the initializer list disappears.
300  this->SetArray(componentIndex, vtkm::cont::make_ArrayHandle(vector, vtkm::CopyFlag::On));
301  ++componentIndex;
302  }
303  }
304 
305  // This only works if all the templated arguments are of type std::vector<ComponentType>.
306  template <typename Allocator, typename... RemainingVectors>
308  const std::vector<ComponentType, Allocator>& vector0,
309  RemainingVectors&&... componentVectors)
310  : Superclass(std::vector<vtkm::cont::internal::Buffer>{
311  vtkm::cont::make_ArrayHandle(vector0, copy).GetBuffers()[0],
312  vtkm::cont::make_ArrayHandle(std::forward<RemainingVectors>(componentVectors), copy)
313  .GetBuffers()[0]... })
314  {
315  VTKM_STATIC_ASSERT(sizeof...(RemainingVectors) + 1 == NUM_COMPONENTS);
316  }
317 
318  // This only works if all the templated arguments are of type std::vector<ComponentType>.
319  template <typename... RemainingVectors>
321  std::vector<ComponentType>&& vector0,
322  RemainingVectors&&... componentVectors)
323  : Superclass(std::vector<vtkm::cont::internal::Buffer>{
324  vtkm::cont::make_ArrayHandle(std::move(vector0), copy),
325  vtkm::cont::make_ArrayHandle(std::forward<RemainingVectors>(componentVectors), copy)
326  .GetBuffers()[0]... })
327  {
328  VTKM_STATIC_ASSERT(sizeof...(RemainingVectors) + 1 == NUM_COMPONENTS);
329  }
330 
331  ArrayHandleSOA(std::initializer_list<const ComponentType*> componentArrays,
332  vtkm::Id length,
333  vtkm::CopyFlag copy)
334  {
335  VTKM_ASSERT(componentArrays.size() == NUM_COMPONENTS);
336  vtkm::IdComponent componentIndex = 0;
337  for (auto&& vectorIter = componentArrays.begin(); vectorIter != componentArrays.end();
338  ++vectorIter)
339  {
340  this->SetArray(componentIndex, vtkm::cont::make_ArrayHandle(*vectorIter, length, copy));
341  ++componentIndex;
342  }
343  }
344 
345  // This only works if all the templated arguments are of type std::vector<ComponentType>.
346  template <typename... RemainingArrays>
348  vtkm::CopyFlag copy,
349  const ComponentType* array0,
350  const RemainingArrays&... componentArrays)
351  : Superclass(std::vector<vtkm::cont::internal::Buffer>{
352  vtkm::cont::make_ArrayHandle(array0, length, copy).GetBuffers()[0],
353  vtkm::cont::make_ArrayHandle(componentArrays, length, copy).GetBuffers()[0]... })
354  {
355  VTKM_STATIC_ASSERT(sizeof...(RemainingArrays) + 1 == NUM_COMPONENTS);
356  }
357 
359  {
360  return ComponentArrayType({ this->GetBuffers()[index] });
361  }
362 
364  {
365  this->SetBuffer(index, array.GetBuffers()[0]);
366  }
367 };
368 
369 template <typename ValueType>
372  vtkm::cont::StorageTagBasic>>&& componentArrays)
373 {
374  return ArrayHandleSOA<ValueType>(std::move(componentArrays));
375 }
376 
377 template <typename ComponentType, typename... RemainingArrays>
378 VTKM_CONT
379  ArrayHandleSOA<vtkm::Vec<ComponentType, vtkm::IdComponent(sizeof...(RemainingArrays) + 1)>>
382  const RemainingArrays&... componentArrays)
383 {
384  return { componentArray0, componentArrays... };
385 }
386 
387 template <typename ValueType>
389  std::initializer_list<std::vector<typename vtkm::VecTraits<ValueType>::ComponentType>>&&
390  componentVectors)
391 {
392  return ArrayHandleSOA<ValueType>(std::move(componentVectors));
393 }
394 
395 // This only works if all the templated arguments are of type std::vector<ComponentType>.
396 template <typename ComponentType, typename... RemainingVectors>
397 VTKM_CONT
398  ArrayHandleSOA<vtkm::Vec<ComponentType, vtkm::IdComponent(sizeof...(RemainingVectors) + 1)>>
400  const std::vector<ComponentType>& vector0,
401  RemainingVectors&&... componentVectors)
402 {
403  // Convert std::vector to ArrayHandle first so that it correctly handles a mix of rvalue args.
404  return { vtkm::cont::make_ArrayHandle(vector0, copy),
405  vtkm::cont::make_ArrayHandle(std::forward<RemainingVectors>(componentVectors),
406  copy)... };
407 }
408 
409 // This only works if all the templated arguments are of type std::vector<ComponentType>.
410 template <typename ComponentType, typename... RemainingVectors>
411 VTKM_CONT
412  ArrayHandleSOA<vtkm::Vec<ComponentType, vtkm::IdComponent(sizeof...(RemainingVectors) + 1)>>
414  std::vector<ComponentType>&& vector0,
415  RemainingVectors&&... componentVectors)
416 {
417  // Convert std::vector to ArrayHandle first so that it correctly handles a mix of rvalue args.
418  return ArrayHandleSOA<
419  vtkm::Vec<ComponentType, vtkm::IdComponent(sizeof...(RemainingVectors) + 1)>>(
420  vtkm::cont::make_ArrayHandle(std::move(vector0), copy),
421  vtkm::cont::make_ArrayHandle(std::forward<RemainingVectors>(componentVectors), copy)...);
422 }
423 
424 // This only works if all the templated arguments are rvalues of std::vector<ComponentType>.
425 template <typename ComponentType, typename... RemainingVectors>
426 VTKM_CONT
427  ArrayHandleSOA<vtkm::Vec<ComponentType, vtkm::IdComponent(sizeof...(RemainingVectors) + 1)>>
428  make_ArrayHandleSOAMove(std::vector<ComponentType>&& vector0,
429  RemainingVectors&&... componentVectors)
430 {
431  return { vtkm::cont::make_ArrayHandleMove(std::move(vector0)),
432  vtkm::cont::make_ArrayHandleMove(std::forward<RemainingVectors>(componentVectors))... };
433 }
434 
435 template <typename ValueType>
437  std::initializer_list<const typename vtkm::VecTraits<ValueType>::ComponentType*>&&
438  componentVectors,
439  vtkm::Id length,
440  vtkm::CopyFlag copy)
441 {
442  return ArrayHandleSOA<ValueType>(std::move(componentVectors), length, copy);
443 }
444 
445 // This only works if all the templated arguments are of type std::vector<ComponentType>.
446 template <typename ComponentType, typename... RemainingArrays>
447 VTKM_CONT
448  ArrayHandleSOA<vtkm::Vec<ComponentType, vtkm::IdComponent(sizeof...(RemainingArrays) + 1)>>
450  vtkm::CopyFlag copy,
451  const ComponentType* array0,
452  const RemainingArrays*... componentArrays)
453 {
454  return ArrayHandleSOA<
455  vtkm::Vec<ComponentType, vtkm::IdComponent(sizeof...(RemainingArrays) + 1)>>(
456  length, copy, array0, componentArrays...);
457 }
458 
459 namespace internal
460 {
461 
462 template <>
463 struct ArrayExtractComponentImpl<vtkm::cont::StorageTagSOA>
464 {
465  template <typename T>
467  vtkm::IdComponent componentIndex,
468  vtkm::CopyFlag allowCopy) const
469  -> decltype(
470  ArrayExtractComponentImpl<vtkm::cont::StorageTagBasic>{}(vtkm::cont::ArrayHandleBasic<T>{},
471  componentIndex,
472  allowCopy))
473  {
474  using FirstLevelComponentType = typename vtkm::VecTraits<T>::ComponentType;
476  constexpr vtkm::IdComponent NUM_SUB_COMPONENTS =
478  return ArrayExtractComponentImpl<vtkm::cont::StorageTagBasic>{}(
479  array.GetArray(componentIndex / NUM_SUB_COMPONENTS),
480  componentIndex % NUM_SUB_COMPONENTS,
481  allowCopy);
482  }
483 };
484 
485 } // namespace internal
486 
487 }
488 } // namespace vtkm::cont
489 
490 //=============================================================================
491 // Specializations of serialization related classes
493 
494 namespace vtkm
495 {
496 namespace cont
497 {
498 
499 template <typename ValueType>
500 struct SerializableTypeString<vtkm::cont::ArrayHandleSOA<ValueType>>
501 {
502  static VTKM_CONT const std::string& Get()
503  {
504  static std::string name = "AH_SOA<" + SerializableTypeString<ValueType>::Get() + ">";
505  return name;
506  }
507 };
508 
509 template <typename ValueType>
510 struct SerializableTypeString<vtkm::cont::ArrayHandle<ValueType, vtkm::cont::StorageTagSOA>>
511  : SerializableTypeString<vtkm::cont::ArrayHandleSOA<ValueType>>
512 {
513 };
514 }
515 } // namespace vtkm::cont
516 
517 namespace mangled_diy_namespace
518 {
519 
520 template <typename ValueType>
521 struct Serialization<vtkm::cont::ArrayHandleSOA<ValueType>>
522 {
524  static constexpr vtkm::IdComponent NUM_COMPONENTS = vtkm::VecTraits<ValueType>::NUM_COMPONENTS;
525 
526  static VTKM_CONT void save(BinaryBuffer& bb, const BaseType& obj)
527  {
528  for (vtkm::IdComponent componentIndex = 0; componentIndex < NUM_COMPONENTS; ++componentIndex)
529  {
530  vtkmdiy::save(bb, obj.GetBuffers()[componentIndex]);
531  }
532  }
533 
534  static VTKM_CONT void load(BinaryBuffer& bb, BaseType& obj)
535  {
536  std::vector<vtkm::cont::internal::Buffer> buffers(NUM_COMPONENTS);
537  for (std::size_t componentIndex = 0; componentIndex < NUM_COMPONENTS; ++componentIndex)
538  {
539  vtkmdiy::load(bb, buffers[componentIndex]);
540  }
541  obj = BaseType(buffers);
542  }
543 };
544 
545 template <typename ValueType>
546 struct Serialization<vtkm::cont::ArrayHandle<ValueType, vtkm::cont::StorageTagSOA>>
547  : Serialization<vtkm::cont::ArrayHandleSOA<ValueType>>
548 {
549 };
550 
551 } // namespace mangled_diy_namespace
552 // @endcond SERIALIZATION
553 
554 //=============================================================================
555 // Precompiled instances
556 
557 #ifndef vtkm_cont_ArrayHandleSOA_cxx
558 
559 namespace vtkm
560 {
561 namespace cont
562 {
563 
564 #define VTKM_ARRAYHANDLE_SOA_EXPORT(Type) \
565  extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<vtkm::Vec<Type, 2>, StorageTagSOA>; \
566  extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<vtkm::Vec<Type, 3>, StorageTagSOA>; \
567  extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<vtkm::Vec<Type, 4>, StorageTagSOA>;
568 
576 VTKM_ARRAYHANDLE_SOA_EXPORT(vtkm::Int64)
577 VTKM_ARRAYHANDLE_SOA_EXPORT(vtkm::UInt64)
580 
581 #undef VTKM_ARRAYHANDLE_SOA_EXPORT
582 }
583 } // namespace vtkm::cont
584 
585 #endif // !vtkm_cont_ArrayHandleSOA_cxx
586 
587 #endif //vtk_m_cont_ArrayHandleSOA_h
vtkm::cont::ArrayHandle< T, vtkm::cont::StorageTagSOA >::GetBuffers
const VTKM_CONT std::vector< vtkm::cont::internal::Buffer > & GetBuffers() const
Returns the internal Buffer structures that hold the data.
Definition: ArrayHandle.h:696
vtkm::cont::make_ArrayHandle
VTKM_CONT 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:217
vtkm::cont::ArrayHandleSOA::ArrayHandleSOA
ArrayHandleSOA(vtkm::CopyFlag copy, const std::vector< ComponentType, Allocator > &vector0, RemainingVectors &&... componentVectors)
Definition: ArrayHandleSOA.h:307
vtkm::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:283
vtkm::cont::ArrayHandleSOA::VTKM_ARRAY_HANDLE_SUBCLASS
VTKM_ARRAY_HANDLE_SUBCLASS(ArrayHandleSOA,(ArrayHandleSOA< T >),(ArrayHandle< T, vtkm::cont::StorageTagSOA >))
ArrayHandle.h
ArrayExtractComponent.h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
ArrayPortalHelpers.h
VTKM_ASSERT
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
VTKM_EXEC_CONT
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
vtkm::cont::ArrayHandleSOA::ArrayHandleSOA
ArrayHandleSOA(vtkm::CopyFlag copy, std::vector< ComponentType > &&vector0, RemainingVectors &&... componentVectors)
Definition: ArrayHandleSOA.h:320
vtkm::Get
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC_CONT auto Get(const vtkm::Tuple< Ts... > &tuple) -> decltype(tuple.template Get< Index >())
Retrieve the object from a vtkm::Tuple at the given index.
Definition: Tuple.h:83
vtkm::IdComponent
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
vtkm::cont::StorageTagSOA
Definition: ArrayHandleSOA.h:124
vtkm::cont::ArrayHandleSOA::ArrayHandleSOA
ArrayHandleSOA(vtkm::Id length, vtkm::CopyFlag copy, const ComponentType *array0, const RemainingArrays &... componentArrays)
Definition: ArrayHandleSOA.h:347
vtkm::HasVecTraits
typename detail::HasVecTraitsImpl< T >::Type HasVecTraits
Determines whether the given type has VecTraits defined.
Definition: VecTraits.h:176
vtkm::Int16
int16_t Int16
Definition: Types.h:158
vtkm::BufferSizeType
vtkm::Int64 BufferSizeType
Definition: DeviceAdapterMemoryManager.h:27
vtkm::cont::ArrayHandleSOA::ArrayHandleSOA
ArrayHandleSOA(std::initializer_list< vtkm::cont::internal::Buffer > &&componentBuffers)
Definition: ArrayHandleSOA.h:259
mangled_diy_namespace
Definition: Particle.h:331
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::exec::arg::load
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC T load(const U &u, vtkm::Id v)
Definition: FetchTagArrayDirectIn.h:36
vtkm::cont::ArrayHandleSOA
An ArrayHandle that for Vecs stores each component in a separate physical array.
Definition: ArrayHandleSOA.h:245
vtkm::cont::ArrayHandleSOA::StorageType
vtkm::cont::internal::Storage< T, vtkm::cont::StorageTagSOA > StorageType
Definition: ArrayHandleSOA.h:250
vtkm::cont::ArrayHandleSOA::ComponentType
typename vtkm::VecTraits< T >::ComponentType ComponentType
Definition: ArrayHandleSOA.h:247
vtkm::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::cont::make_ArrayHandleMove
VTKM_CONT 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:241
ArrayPortalBasic.h
vtkm::VecTraits::GetComponent
static const VTKM_EXEC_CONT ComponentType & GetComponent(const typename std::remove_const< VecType >::type &vector, vtkm::IdComponent component)
Returns the value in a given component of the vector.
Math.h
VTKM_STATIC_ASSERT
#define VTKM_STATIC_ASSERT(condition)
Definition: StaticAssert.h:16
vtkm::cont::ArrayHandleSOA::ArrayHandleSOA
ArrayHandleSOA(std::initializer_list< ComponentArrayType > &&componentArrays)
Definition: ArrayHandleSOA.h:281
vtkm::Int8
int8_t Int8
Definition: Types.h:156
vtkm::cont::ArrayHandleSOA::ArrayHandleSOA
ArrayHandleSOA(const std::vector< ComponentArrayType > &componentArrays)
Definition: ArrayHandleSOA.h:272
vtkm::cont::ArrayHandle< T, vtkm::cont::StorageTagSOA >::SetBuffer
VTKM_CONT void SetBuffer(vtkm::IdComponent index, const vtkm::cont::internal::Buffer &buffer)
Definition: ArrayHandle.h:706
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
VTKM_ARRAYHANDLE_SOA_EXPORT
#define VTKM_ARRAYHANDLE_SOA_EXPORT(Type)
Definition: ArrayHandleSOA.h:564
vtkm::VecFlat
Treat a Vec or Vec-like object as a flat Vec.
Definition: VecFlat.h:224
vtkm::UInt8
uint8_t UInt8
Definition: Types.h:157
vtkm::CopyFlag::On
@ On
vtkm::cont::ArrayHandleSOA::ArrayHandleSOA
ArrayHandleSOA(std::initializer_list< std::vector< ComponentType >> &&componentVectors)
Definition: ArrayHandleSOA.h:292
vtkm::cont::make_ArrayHandleSOA
VTKM_CONT ArrayHandleSOA< ValueType > make_ArrayHandleSOA(std::initializer_list< vtkm::cont::ArrayHandle< typename vtkm::VecTraits< ValueType >::ComponentType, vtkm::cont::StorageTagBasic >> &&componentArrays)
Definition: ArrayHandleSOA.h:370
vtkm::cont::ArrayHandleSOA::GetArray
VTKM_CONT vtkm::cont::ArrayHandleBasic< ComponentType > GetArray(vtkm::IdComponent index) const
Definition: ArrayHandleSOA.h:358
vtkm::cont::DeviceAdapterId
Definition: DeviceAdapterTag.h:52
vtkm::Vec
A short fixed-length array.
Definition: Types.h:767
vtkm::cont::make_ArrayHandleSOAMove
VTKM_CONT ArrayHandleSOA< vtkm::Vec< ComponentType, vtkm::IdComponent(sizeof...(RemainingVectors)+1)> > make_ArrayHandleSOAMove(std::vector< ComponentType > &&vector0, RemainingVectors &&... componentVectors)
Definition: ArrayHandleSOA.h:428
vtkm::UInt32
uint32_t UInt32
Definition: Types.h:161
vtkm::Float32
float Float32
Definition: Types.h:154
vtkm::cont::ArrayHandleSOA::ComponentArrayType
vtkm::cont::ArrayHandle< ComponentType, vtkm::cont::StorageTagBasic > ComponentArrayType
Definition: ArrayHandleSOA.h:252
vtkm::VecTraits::ComponentType
typename VecType::ComponentType ComponentType
Type of the components in the vector.
Definition: VecTraits.h:73
vtkm::Int32
int32_t Int32
Definition: Types.h:160
vtkm::cont::StorageTagBasic
A tag for the basic implementation of a Storage object.
Definition: ArrayHandle.h:45
vtkm::Float64
double Float64
Definition: Types.h:155
vtkm::CopyFlag
CopyFlag
Definition: Flags.h:16
vtkm::cont::ArrayHandleSOA::SetArray
VTKM_CONT void SetArray(vtkm::IdComponent index, const ComponentArrayType &array)
Definition: ArrayHandleSOA.h:363
vtkm::cont::ArrayHandleSOA::ArrayHandleSOA
ArrayHandleSOA(std::initializer_list< const ComponentType * > componentArrays, vtkm::Id length, vtkm::CopyFlag copy)
Definition: ArrayHandleSOA.h:331
vtkm::cont::ArrayHandleBasic
Definition: ArrayHandleBasic.h:97
vtkm::VecTraits
The VecTraits class gives several static members that define how to use a given type as a vector.
Definition: VecTraits.h:66
VTKM_ALWAYS_EXPORT
#define VTKM_ALWAYS_EXPORT
Definition: ExportMacros.h:92
vtkm::UInt16
uint16_t UInt16
Definition: Types.h:159
vtkm::cont::ArrayHandleSOA::NUM_COMPONENTS
static constexpr vtkm::IdComponent NUM_COMPONENTS
Definition: ArrayHandleSOA.h:248
vtkm::cont::ArrayHandleSOA::ArrayHandleSOA
ArrayHandleSOA(const std::array< ComponentArrayType, NUM_COMPONENTS > &componentArrays)
Definition: ArrayHandleSOA.h:264
VTKM_SUPPRESS_EXEC_WARNINGS
#define VTKM_SUPPRESS_EXEC_WARNINGS
Definition: ExportMacros.h:53
VecTraits.h
vtkm::VecTraits::NUM_COMPONENTS
static constexpr vtkm::IdComponent NUM_COMPONENTS
Number of components in the vector.
Definition: VecTraits.h:86