VTK-m  2.0
ArrayHandleRecombineVec.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_ArrayHandleRecombineVec_h
11 #define vtk_m_cont_ArrayHandleRecombineVec_h
12 
17 
18 #include <vtkm/VecVariable.h>
19 
21 
22 namespace vtkm
23 {
24 namespace internal
25 {
26 
27 template <typename PortalType>
28 class RecombineVec
29 {
32 
33 public:
34  using ComponentType = typename std::remove_const<typename PortalType::ValueType>::type;
35 
36  RecombineVec(const RecombineVec&) = default;
37 
38  VTKM_EXEC_CONT RecombineVec(const vtkm::VecCConst<PortalType>& portals, vtkm::Id index)
39  : Portals(portals)
40  , Index(index)
41  {
42  }
43 
44  VTKM_EXEC_CONT vtkm::IdComponent GetNumberOfComponents() const
45  {
46  return this->Portals.GetNumberOfComponents();
47  }
48 
50  vtkm::internal::ArrayPortalValueReference<PortalType> operator[](vtkm::IdComponent cIndex) const
51  {
52  return vtkm::internal::ArrayPortalValueReference<PortalType>(this->Portals[cIndex],
53  this->Index);
54  }
55 
56  template <typename T, vtkm::IdComponent DestSize>
57  VTKM_EXEC_CONT void CopyInto(vtkm::Vec<T, DestSize>& dest) const
58  {
59  vtkm::IdComponent numComponents = vtkm::Min(DestSize, this->GetNumberOfComponents());
60  for (vtkm::IdComponent cIndex = 0; cIndex < numComponents; ++cIndex)
61  {
62  dest[cIndex] = this->Portals[cIndex].Get(this->Index);
63  }
64  // Clear out any components not held by this dynamic Vec-like
65  for (vtkm::IdComponent cIndex = numComponents; cIndex < DestSize; ++cIndex)
66  {
68  }
69  }
70 
71  VTKM_EXEC_CONT vtkm::Id GetIndex() const { return this->Index; }
72 
73  VTKM_EXEC_CONT RecombineVec& operator=(const RecombineVec& src)
74  {
75  this->DoCopy(src);
76  return *this;
77  }
78 
79  template <typename T, typename = typename std::enable_if<vtkm::HasVecTraits<T>::value>::type>
80  VTKM_EXEC_CONT RecombineVec& operator=(const T& src)
81  {
82  this->DoCopy(src);
83  return *this;
84  }
85 
86  VTKM_EXEC_CONT operator ComponentType() const { return this->Portals[0].Get(this->Index); }
87 
88  template <vtkm::IdComponent N>
90  {
92  this->CopyInto(result);
93  return result;
94  }
95 
96  template <typename T, typename = typename std::enable_if<vtkm::HasVecTraits<T>::value>::type>
97  VTKM_EXEC_CONT RecombineVec& operator+=(const T& src)
98  {
99  using VTraits = vtkm::VecTraits<T>;
100  VTKM_ASSERT(this->GetNumberOfComponents() == VTraits::GetNumberOfComponents(src));
101  for (vtkm::IdComponent cIndex = 0; cIndex < this->GetNumberOfComponents(); ++cIndex)
102  {
103  (*this)[cIndex] += VTraits::GetComponent(src, cIndex);
104  }
105  return *this;
106  }
107  template <typename T, typename = typename std::enable_if<vtkm::HasVecTraits<T>::value>::type>
108  VTKM_EXEC_CONT RecombineVec& operator-=(const T& src)
109  {
110  using VTraits = vtkm::VecTraits<T>;
111  VTKM_ASSERT(this->GetNumberOfComponents() == VTraits::GetNumberOfComponents(src));
112  for (vtkm::IdComponent cIndex = 0; cIndex < this->GetNumberOfComponents(); ++cIndex)
113  {
114  (*this)[cIndex] -= VTraits::GetComponent(src, cIndex);
115  }
116  return *this;
117  }
118  template <typename T, typename = typename std::enable_if<vtkm::HasVecTraits<T>::value>::type>
119  VTKM_EXEC_CONT RecombineVec& operator*=(const T& src)
120  {
121  using VTraits = vtkm::VecTraits<T>;
122  VTKM_ASSERT(this->GetNumberOfComponents() == VTraits::GetNumberOfComponents(src));
123  for (vtkm::IdComponent cIndex = 0; cIndex < this->GetNumberOfComponents(); ++cIndex)
124  {
125  (*this)[cIndex] *= VTraits::GetComponent(src, cIndex);
126  }
127  return *this;
128  }
129  template <typename T, typename = typename std::enable_if<vtkm::HasVecTraits<T>::value>::type>
130  VTKM_EXEC_CONT RecombineVec& operator/=(const T& src)
131  {
132  using VTraits = vtkm::VecTraits<T>;
133  VTKM_ASSERT(this->GetNumberOfComponents() == VTraits::GetNumberOfComponents(src));
134  for (vtkm::IdComponent cIndex = 0; cIndex < this->GetNumberOfComponents(); ++cIndex)
135  {
136  (*this)[cIndex] /= VTraits::GetComponent(src, cIndex);
137  }
138  return *this;
139  }
140  template <typename T, typename = typename std::enable_if<vtkm::HasVecTraits<T>::value>::type>
141  VTKM_EXEC_CONT RecombineVec& operator%=(const T& src)
142  {
143  using VTraits = vtkm::VecTraits<T>;
144  VTKM_ASSERT(this->GetNumberOfComponents() == VTraits::GetNumberOfComponents(src));
145  for (vtkm::IdComponent cIndex = 0; cIndex < this->GetNumberOfComponents(); ++cIndex)
146  {
147  (*this)[cIndex] %= VTraits::GetComponent(src, cIndex);
148  }
149  return *this;
150  }
151  template <typename T, typename = typename std::enable_if<vtkm::HasVecTraits<T>::value>::type>
152  VTKM_EXEC_CONT RecombineVec& operator&=(const T& src)
153  {
154  using VTraits = vtkm::VecTraits<T>;
155  VTKM_ASSERT(this->GetNumberOfComponents() == VTraits::GetNumberOfComponents(src));
156  for (vtkm::IdComponent cIndex = 0; cIndex < this->GetNumberOfComponents(); ++cIndex)
157  {
158  (*this)[cIndex] &= VTraits::GetComponent(src, cIndex);
159  }
160  return *this;
161  }
162  template <typename T, typename = typename std::enable_if<vtkm::HasVecTraits<T>::value>::type>
163  VTKM_EXEC_CONT RecombineVec& operator|=(const T& src)
164  {
165  using VTraits = vtkm::VecTraits<T>;
166  VTKM_ASSERT(this->GetNumberOfComponents() == VTraits::GetNumberOfComponents(src));
167  for (vtkm::IdComponent cIndex = 0; cIndex < this->GetNumberOfComponents(); ++cIndex)
168  {
169  (*this)[cIndex] |= VTraits::GetComponent(src, cIndex);
170  }
171  return *this;
172  }
173  template <typename T, typename = typename std::enable_if<vtkm::HasVecTraits<T>::value>::type>
174  VTKM_EXEC_CONT RecombineVec& operator^=(const T& src)
175  {
176  using VTraits = vtkm::VecTraits<T>;
177  VTKM_ASSERT(this->GetNumberOfComponents() == VTraits::GetNumberOfComponents(src));
178  for (vtkm::IdComponent cIndex = 0; cIndex < this->GetNumberOfComponents(); ++cIndex)
179  {
180  (*this)[cIndex] ^= VTraits::GetComponent(src, cIndex);
181  }
182  return *this;
183  }
184  template <typename T, typename = typename std::enable_if<vtkm::HasVecTraits<T>::value>::type>
185  VTKM_EXEC_CONT RecombineVec& operator>>=(const T& src)
186  {
187  using VTraits = vtkm::VecTraits<T>;
188  VTKM_ASSERT(this->GetNumberOfComponents() == VTraits::GetNumberOfComponents(src));
189  for (vtkm::IdComponent cIndex = 0; cIndex < this->GetNumberOfComponents(); ++cIndex)
190  {
191  (*this)[cIndex] >>= VTraits::GetComponent(src, cIndex);
192  }
193  return *this;
194  }
195  template <typename T, typename = typename std::enable_if<vtkm::HasVecTraits<T>::value>::type>
196  VTKM_EXEC_CONT RecombineVec& operator<<=(const T& src)
197  {
198  using VTraits = vtkm::VecTraits<T>;
199  VTKM_ASSERT(this->GetNumberOfComponents() == VTraits::GetNumberOfComponents(src));
200  for (vtkm::IdComponent cIndex = 0; cIndex < this->GetNumberOfComponents(); ++cIndex)
201  {
202  (*this)[cIndex] <<= VTraits::GetComponent(src, cIndex);
203  }
204  return *this;
205  }
206 
207 private:
208  template <typename T>
209  VTKM_EXEC_CONT void DoCopy(const T& src)
210  {
211  using VTraits = vtkm::VecTraits<T>;
212  vtkm::IdComponent numComponents = VTraits::GetNumberOfComponents(src);
213  if (numComponents > 1)
214  {
215  if (numComponents > this->GetNumberOfComponents())
216  {
217  numComponents = this->GetNumberOfComponents();
218  }
219  for (vtkm::IdComponent cIndex = 0; cIndex < numComponents; ++cIndex)
220  {
221  this->Portals[cIndex].Set(this->Index,
222  static_cast<ComponentType>(VTraits::GetComponent(src, cIndex)));
223  }
224  }
225  else
226  {
227  // Special case when copying from a scalar
228  for (vtkm::IdComponent cIndex = 0; cIndex < this->GetNumberOfComponents(); ++cIndex)
229  {
230  this->Portals[cIndex].Set(this->Index,
231  static_cast<ComponentType>(VTraits::GetComponent(src, 0)));
232  }
233  }
234  }
235 };
236 
237 } // namespace internal
238 
239 template <typename PortalType>
240 struct TypeTraits<vtkm::internal::RecombineVec<PortalType>>
241 {
242 private:
243  using VecType = vtkm::internal::RecombineVec<PortalType>;
244  using ComponentType = typename VecType::ComponentType;
245 
246 public:
249 
250  VTKM_EXEC_CONT static vtkm::internal::RecombineVec<PortalType> ZeroInitialization()
251  {
252  // Return a vec-like of size 0.
253  return vtkm::internal::RecombineVec<PortalType>{};
254  }
255 };
256 
257 template <typename PortalType>
258 struct VecTraits<vtkm::internal::RecombineVec<PortalType>>
259 {
260  using VecType = vtkm::internal::RecombineVec<PortalType>;
261  using ComponentType = typename VecType::ComponentType;
265 
266  VTKM_EXEC_CONT static vtkm::IdComponent GetNumberOfComponents(const VecType& vector)
267  {
268  return vector.GetNumberOfComponents();
269  }
270 
272  static ComponentType GetComponent(const VecType& vector, vtkm::IdComponent componentIndex)
273  {
274  return vector[componentIndex];
275  }
276 
277  VTKM_EXEC_CONT static void SetComponent(const VecType& vector,
278  vtkm::IdComponent componentIndex,
279  const ComponentType& component)
280  {
281  vector[componentIndex] = component;
282  }
283 
284  template <vtkm::IdComponent destSize>
285  VTKM_EXEC_CONT static void CopyInto(const VecType& src, vtkm::Vec<ComponentType, destSize>& dest)
286  {
287  src.CopyInto(dest);
288  }
289 };
290 
291 namespace internal
292 {
293 
294 template <typename SourcePortalType>
295 class ArrayPortalRecombineVec
296 {
297  // Note that this ArrayPortal has a pointer to a C array of other portals. We need to
298  // make sure that the pointer is valid on the device we are using it on. See the
299  // CreateReadPortal and CreateWritePortal in the Storage below to see how that is
300  // managed.
301  const SourcePortalType* Portals;
302  vtkm::IdComponent NumberOfComponents;
303 
304 public:
305  using ValueType = vtkm::internal::RecombineVec<SourcePortalType>;
306 
307  ArrayPortalRecombineVec() = default;
308  ArrayPortalRecombineVec(const SourcePortalType* portals, vtkm::IdComponent numComponents)
309  : Portals(portals)
310  , NumberOfComponents(numComponents)
311  {
312  }
313 
314  VTKM_EXEC_CONT vtkm::Id GetNumberOfValues() const { return this->Portals[0].GetNumberOfValues(); }
315 
316  VTKM_EXEC_CONT ValueType Get(vtkm::Id index) const
317  {
318  return ValueType({ this->Portals, this->NumberOfComponents }, index);
319  }
320 
321  VTKM_EXEC_CONT void Set(vtkm::Id index, const ValueType& value) const
322  {
323  // The ValueType is actually a reference back to the portals, and sets to it should
324  // already be set in the portal. Thus, we don't really need to do anything.
325  VTKM_ASSERT(value.GetIndex() == index);
326  }
327 
328  template <typename T>
329  VTKM_EXEC_CONT void Set(vtkm::Id index, const T& value) const
330  {
331  using Traits = vtkm::VecTraits<T>;
332  VTKM_ASSERT(Traits::GetNumberOfComponents(value) == this->NumberOfComponents);
333  for (vtkm::IdComponent cIndex = 0; cIndex < this->NumberOfComponents; ++cIndex)
334  {
335  this->Portals[cIndex].Set(index, Traits::GetComponent(value, cIndex));
336  }
337  }
338 };
339 
340 }
341 } // namespace vtkm::internal
342 
343 namespace vtkm
344 {
345 namespace cont
346 {
347 
348 namespace internal
349 {
350 
351 struct StorageTagRecombineVec
352 {
353 };
354 
355 namespace detail
356 {
357 
358 struct RecombineVecMetaData
359 {
360  mutable std::vector<vtkm::cont::internal::Buffer> PortalBuffers;
361  std::vector<std::size_t> ArrayBufferOffsets;
362 
363  RecombineVecMetaData() = default;
364 
365  RecombineVecMetaData(const RecombineVecMetaData& src) { *this = src; }
366 
367  RecombineVecMetaData& operator=(const RecombineVecMetaData& src)
368  {
369  this->ArrayBufferOffsets = src.ArrayBufferOffsets;
370 
371  this->PortalBuffers.clear();
372  // Intentionally not copying portals. Portals will be recreated from proper array when requsted.
373 
374  return *this;
375  }
376 };
377 
378 template <typename T>
379 using RecombinedPortalType = vtkm::internal::ArrayPortalMultiplexer<
380  typename vtkm::cont::internal::Storage<T, vtkm::cont::StorageTagStride>::ReadPortalType,
381  typename vtkm::cont::internal::Storage<T, vtkm::cont::StorageTagStride>::WritePortalType>;
382 
383 template <typename T>
384 using RecombinedValueType = vtkm::internal::RecombineVec<RecombinedPortalType<T>>;
385 
386 } // namespace detail
387 
388 template <typename ReadWritePortal>
389 class Storage<vtkm::internal::RecombineVec<ReadWritePortal>,
390  vtkm::cont::internal::StorageTagRecombineVec>
391 {
392  using ComponentType = typename ReadWritePortal::ValueType;
393  using SourceStorage = vtkm::cont::internal::Storage<ComponentType, vtkm::cont::StorageTagStride>;
395 
397  (std::is_same<ReadWritePortal, detail::RecombinedPortalType<ComponentType>>::value));
398 
399  VTKM_CONT static std::vector<vtkm::cont::internal::Buffer> BuffersForComponent(
400  const std::vector<vtkm::cont::internal::Buffer>& buffers,
401  vtkm::IdComponent componentIndex)
402  {
403  auto& metaData = buffers[0].GetMetaData<detail::RecombineVecMetaData>();
404  std::size_t index = static_cast<std::size_t>(componentIndex);
405  return std::vector<vtkm::cont::internal::Buffer>(
406  buffers.begin() + metaData.ArrayBufferOffsets[index],
407  buffers.begin() + metaData.ArrayBufferOffsets[index + 1]);
408  }
409 
410 public:
412 
413  using ReadPortalType = vtkm::internal::ArrayPortalRecombineVec<ReadWritePortal>;
414  using WritePortalType = vtkm::internal::ArrayPortalRecombineVec<ReadWritePortal>;
415 
416  VTKM_CONT static vtkm::IdComponent NumberOfComponents(
417  const std::vector<vtkm::cont::internal::Buffer>& buffers)
418  {
419  return static_cast<vtkm::IdComponent>(
420  buffers[0].GetMetaData<detail::RecombineVecMetaData>().ArrayBufferOffsets.size() - 1);
421  }
422 
423  VTKM_CONT static vtkm::Id GetNumberOfValues(
424  const std::vector<vtkm::cont::internal::Buffer>& buffers)
425  {
426  return SourceStorage::GetNumberOfValues(BuffersForComponent(buffers, 0));
427  }
428 
429  VTKM_CONT static void Fill(const std::vector<vtkm::cont::internal::Buffer>&,
430  const vtkm::internal::RecombineVec<ReadWritePortal>&,
431  vtkm::Id,
432  vtkm::Id,
434  {
435  throw vtkm::cont::ErrorBadType("Fill not supported for ArrayHandleRecombineVec.");
436  }
437 
438  VTKM_CONT static ReadPortalType CreateReadPortal(
439  const std::vector<vtkm::cont::internal::Buffer>& buffers,
441  vtkm::cont::Token& token)
442  {
443  vtkm::IdComponent numComponents = NumberOfComponents(buffers);
444 
445  // The array portal needs a runtime-allocated array of portals for each component.
446  // We use the vtkm::cont::internal::Buffer object to allow us to allocate memory on the
447  // device and copy data there.
448  vtkm::cont::internal::Buffer portalBuffer;
449  portalBuffer.SetNumberOfBytes(static_cast<vtkm::BufferSizeType>(sizeof(ReadWritePortal)) *
450  numComponents,
452  token);
453 
454  // Save a reference of the portal in our metadata.
455  // Note that the buffer we create is going to hang around until the ArrayHandle gets
456  // destroyed. The buffers are small and should not be a problem unless you create a
457  // lot of portals.
458  buffers[0].GetMetaData<detail::RecombineVecMetaData>().PortalBuffers.push_back(portalBuffer);
459 
460  // Get the control-side memory and fill it with the execution-side portals
461  ReadWritePortal* portals =
462  reinterpret_cast<ReadWritePortal*>(portalBuffer.WritePointerHost(token));
463  for (vtkm::IdComponent cIndex = 0; cIndex < numComponents; ++cIndex)
464  {
465  portals[cIndex] = ReadWritePortal(
466  SourceStorage::CreateReadPortal(BuffersForComponent(buffers, cIndex), device, token));
467  }
468 
469  // Now get the execution-side memory (portals will be copied as necessary) and create
470  // the portal for the appropriate device
471  return ReadPortalType(
472  reinterpret_cast<const ReadWritePortal*>(portalBuffer.ReadPointerDevice(device, token)),
473  numComponents);
474  }
475 
476  VTKM_CONT static WritePortalType CreateWritePortal(
477  const std::vector<vtkm::cont::internal::Buffer>& buffers,
479  vtkm::cont::Token& token)
480  {
481  vtkm::IdComponent numComponents = NumberOfComponents(buffers);
482 
483  // The array portal needs a runtime-allocated array of portals for each component.
484  // We use the vtkm::cont::internal::Buffer object to allow us to allocate memory on the
485  // device and copy data there.
486  vtkm::cont::internal::Buffer portalBuffer;
487  portalBuffer.SetNumberOfBytes(static_cast<vtkm::BufferSizeType>(sizeof(ReadWritePortal)) *
488  numComponents,
490  token);
491 
492  // Save a reference of the portal in our metadata.
493  // Note that the buffer we create is going to hang around until the ArrayHandle gets
494  // destroyed. The buffers are small and should not be a problem unless you create a
495  // lot of portals.
496  buffers[0].GetMetaData<detail::RecombineVecMetaData>().PortalBuffers.push_back(portalBuffer);
497 
498  // Get the control-side memory and fill it with the execution-side portals
499  ReadWritePortal* portals =
500  reinterpret_cast<ReadWritePortal*>(portalBuffer.WritePointerHost(token));
501  for (vtkm::IdComponent cIndex = 0; cIndex < numComponents; ++cIndex)
502  {
503  portals[cIndex] = ReadWritePortal(
504  SourceStorage::CreateWritePortal(BuffersForComponent(buffers, cIndex), device, token));
505  }
506 
507  // Now get the execution-side memory (portals will be copied as necessary) and create
508  // the portal for the appropriate device
509  return WritePortalType(
510  reinterpret_cast<const ReadWritePortal*>(portalBuffer.ReadPointerDevice(device, token)),
511  numComponents);
512  }
513 
514  VTKM_CONT static ArrayType ArrayForComponent(
515  const std::vector<vtkm::cont::internal::Buffer>& buffers,
516  vtkm::IdComponent componentIndex)
517  {
518  return ArrayType(BuffersForComponent(buffers, componentIndex));
519  }
520 
521  VTKM_CONT static std::vector<vtkm::cont::internal::Buffer> CreateBuffers()
522  {
523  detail::RecombineVecMetaData metaData;
524  metaData.ArrayBufferOffsets.push_back(1);
525  return vtkm::cont::internal::CreateBuffers(metaData);
526  }
527 
528  VTKM_CONT static void AppendComponent(std::vector<vtkm::cont::internal::Buffer>& buffers,
529  const ArrayType& array)
530  {
531  // Add buffers of new array to our list of buffers.
532  buffers.insert(buffers.end(), array.GetBuffers().begin(), array.GetBuffers().end());
533  // Update metadata for new offset to end.
534  buffers[0].GetMetaData<detail::RecombineVecMetaData>().ArrayBufferOffsets.push_back(
535  buffers.size());
536  }
537 };
538 
539 } // namespace internal
540 
556 template <typename ComponentType>
558  : public vtkm::cont::ArrayHandle<internal::detail::RecombinedValueType<ComponentType>,
559  vtkm::cont::internal::StorageTagRecombineVec>
560 {
561 public:
565  (vtkm::cont::ArrayHandle<internal::detail::RecombinedValueType<ComponentType>,
566  vtkm::cont::internal::StorageTagRecombineVec>));
567 
568 private:
569  using StorageType = vtkm::cont::internal::Storage<ValueType, StorageTag>;
570 
571 public:
573  {
574  return StorageType::NumberOfComponents(this->GetBuffers());
575  }
576 
578  vtkm::IdComponent componentIndex) const
579  {
580  return StorageType::ArrayForComponent(this->GetBuffers(), componentIndex);
581  }
582 
585  {
586  std::vector<vtkm::cont::internal::Buffer> buffers = this->GetBuffers();
587  StorageType::AppendComponent(buffers, array);
588  this->SetBuffers(std::move(buffers));
589  }
590 };
591 
592 namespace internal
593 {
594 
595 template <>
596 struct ArrayExtractComponentImpl<vtkm::cont::internal::StorageTagRecombineVec>
597 {
598  template <typename RecombineVec>
601  operator()(
603  vtkm::IdComponent componentIndex,
604  vtkm::CopyFlag allowCopy) const
605  {
606  using ComponentType = typename RecombineVec::ComponentType;
610  array.GetComponentArray(componentIndex / subComponents),
611  componentIndex % subComponents,
612  allowCopy);
613  }
614 };
615 
616 } // namespace internal
617 
618 }
619 } // namespace vtkm::cont
620 
621 //=============================================================================
622 // Specializations of worklet arguments using ArrayHandleGropuVecVariable
624 
625 #endif //vtk_m_cont_ArrayHandleRecombineVec_h
vtkm::cont::ArrayHandle< internal::detail::RecombinedValueType< ComponentType >, vtkm::cont::internal::StorageTagRecombineVec >::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::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:283
ArrayExtractComponent.h
vtkm::cont::ArrayHandleRecombineVec
A grouping of ArrayHandleStrides into an ArrayHandle of Vecs.
Definition: ArrayHandleRecombineVec.h:557
ArrayHandleStride.h
vtkm::VecTraitsTagMultipleComponents
A tag for vectors that are "true" vectors (i.e.
Definition: VecTraits.h:21
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
VTKM_ASSERT
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
VTKM_EXEC_CONT
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
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::VecTraits::SetComponent
static VTKM_EXEC_CONT void SetComponent(VecType &vector, vtkm::IdComponent component, ComponentType value)
Changes the value in a given component of the vector.
DeviceAdapterTag.h
vtkm::VecTraits::CopyInto
static VTKM_EXEC_CONT void CopyInto(const VecType &src, vtkm::Vec< ComponentType, destSize > &dest)
Copies the components in the given vector into a given Vec object.
vtkm::cont::ArrayHandleRecombineVec::AppendComponentArray
void AppendComponentArray(const vtkm::cont::ArrayHandle< ComponentType, vtkm::cont::StorageTagStride > &array)
Definition: ArrayHandleRecombineVec.h:583
vtkm::cont::ErrorBadType
This class is thrown when VTK-m encounters data of a type that is incompatible with the current opera...
Definition: ErrorBadType.h:25
vtkm::BufferSizeType
vtkm::Int64 BufferSizeType
Definition: DeviceAdapterMemoryManager.h:27
VTKM_STORAGE_NO_RESIZE
#define VTKM_STORAGE_NO_RESIZE
Definition: Storage.h:185
vtkm::VecTraits::BaseComponentType
typename vtkm::VecTraits< ComponentType >::BaseComponentType BaseComponentType
Base component type in the vector.
Definition: VecTraits.h:80
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::cont::ArrayHandle< internal::detail::RecombinedValueType< ComponentType >, vtkm::cont::internal::StorageTagRecombineVec >::SetBuffers
VTKM_CONT void SetBuffers(const std::vector< vtkm::cont::internal::Buffer > &buffers)
Definition: ArrayHandle.h:711
vtkm::TypeTraits::NumericTag
vtkm::TypeTraitsUnknownTag NumericTag
A tag to determine whether the type is integer or real.
Definition: TypeTraits.h:67
vtkm::cont::ArrayHandleStride
An ArrayHandle that accesses a basic array with strides and offsets.
Definition: ArrayHandleStride.h:251
vtkm::TypeTraits::DimensionalityTag
vtkm::TypeTraitsUnknownTag DimensionalityTag
A tag to determine whether the type has multiple components.
Definition: TypeTraits.h:73
vtkm::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::VecTraitsTagSizeVariable
A tag for vectors where the number of components are not determined until run time.
Definition: VecTraits.h:41
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.
vtkm::VecTraits::HasMultipleComponents
typename internal::VecTraitsMultipleComponentChooser< NUM_COMPONENTS >::Type HasMultipleComponents
A tag specifying whether this vector has multiple components (i.e.
Definition: VecTraits.h:98
VTKM_STATIC_ASSERT
#define VTKM_STATIC_ASSERT(condition)
Definition: StaticAssert.h:16
ArrayPortalValueReference.h
vtkm::VecCConst
A const version of VecC.
Definition: Types.h:1331
Index
int Index
Definition: ChooseCudaDevice.h:87
vtkm::VecTraits::IsSizeStatic
vtkm::VecTraitsTagSizeStatic IsSizeStatic
A tag specifying whether the size of this vector is known at compile time.
Definition: VecTraits.h:106
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::VecCConst::GetNumberOfComponents
VTKM_EXEC_CONT vtkm::IdComponent GetNumberOfComponents() const
Definition: Types.h:1393
vtkm::VecFlat
Treat a Vec or Vec-like object as a flat Vec.
Definition: VecFlat.h:224
vtkm::cont::ArrayHandleRecombineVec::StorageType
vtkm::cont::internal::Storage< ValueType, StorageTag > StorageType
Definition: ArrayHandleRecombineVec.h:569
vtkm::TypeTraitsUnknownTag
Tag used to identify types that aren't Real, Integer, Scalar or Vector.
Definition: TypeTraits.h:20
vtkm::cont::DeviceAdapterId
Definition: DeviceAdapterTag.h:52
vtkm::TypeTraitsVectorTag
Tag used to identify 1 dimensional types (vectors).
Definition: TypeTraits.h:51
vtkm::Vec
A short fixed-length array.
Definition: Types.h:767
vtkm::CopyFlag::Off
@ Off
VecVariable.h
ArrayHandleMultiplexer.h
FetchTagArrayDirectOutArrayHandleRecombineVec.h
vtkm::cont::ArrayExtractComponent
vtkm::cont::ArrayHandleStride< typename vtkm::internal::SafeVecTraits< T >::BaseComponentType > ArrayExtractComponent(const vtkm::cont::ArrayHandle< T, S > &src, vtkm::IdComponent componentIndex, vtkm::CopyFlag allowCopy=vtkm::CopyFlag::On)
Pulls a component out of an ArrayHandle.
Definition: ArrayExtractComponent.h:258
vtkm::VecTraits::ComponentType
typename VecType::ComponentType ComponentType
Type of the components in the vector.
Definition: VecTraits.h:73
vtkm::CopyFlag
CopyFlag
Definition: Flags.h:16
vtkm::cont::ArrayHandleRecombineVec::GetComponentArray
vtkm::cont::ArrayHandleStride< ComponentType > GetComponentArray(vtkm::IdComponent componentIndex) const
Definition: ArrayHandleRecombineVec.h:577
vtkm::VecTraits< T >
vtkm::cont::ArrayHandleRecombineVec::VTKM_ARRAY_HANDLE_SUBCLASS
VTKM_ARRAY_HANDLE_SUBCLASS(ArrayHandleRecombineVec,(ArrayHandleRecombineVec< ComponentType >),(vtkm::cont::ArrayHandle< internal::detail::RecombinedValueType< ComponentType >, vtkm::cont::internal::StorageTagRecombineVec >))
vtkm::TypeTraits::ZeroInitialization
static VTKM_EXEC_CONT T ZeroInitialization()
Definition: TypeTraits.h:75
vtkm::VecTraits::GetNumberOfComponents
static vtkm::IdComponent GetNumberOfComponents(const VecType &vec)
Number of components in the given vector.
vtkm::cont::ArrayHandleRecombineVec::GetNumberOfComponents
vtkm::IdComponent GetNumberOfComponents() const
Definition: ArrayHandleRecombineVec.h:572