VTK-m  1.6
ArrayHandle.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_ArrayHandle_h
11 #define vtk_m_cont_ArrayHandle_h
12 
13 #include <vtkm/cont/vtkm_cont_export.h>
14 
15 #include <vtkm/Assert.h>
16 #include <vtkm/Deprecated.h>
17 #include <vtkm/Flags.h>
18 #include <vtkm/Types.h>
19 
23 #include <vtkm/cont/Storage.h>
24 #include <vtkm/cont/Token.h>
25 
27 
28 #include <algorithm>
29 #include <deque>
30 #include <iterator>
31 #include <memory>
32 #include <mutex>
33 #include <vector>
34 
36 
37 namespace vtkm
38 {
39 namespace cont
40 {
41 
42 // Normally this would be defined in ArrayHandleBasic.h, but we need this declared early for
43 // the default storage.
44 
47 {
48 };
49 }
50 } // namespace vtkm::cont
51 
52 #if VTKM_STORAGE == VTKM_STORAGE_BASIC
53 
54 #define VTKM_DEFAULT_STORAGE_TAG ::vtkm::cont::StorageTagBasic
55 
56 #elif VTKM_STORAGE == VTKM_STORAGE_ERROR
57 
59 #define VTKM_DEFAULT_STORAGE_TAG ::vtkm::cont::internal::StorageTagError
60 
61 #elif (VTKM_STORAGE == VTKM_STORAGE_UNDEFINED) || !defined(VTKM_STORAGE)
62 
63 #ifndef VTKM_DEFAULT_STORAGE_TAG
64 #warning If array storage is undefined, VTKM_DEFAULT_STORAGE_TAG must be defined.
65 #endif
66 
67 #endif
68 
69 namespace vtkm
70 {
71 namespace cont
72 {
73 
74 namespace internal
75 {
76 
83 class VTKM_CONT_EXPORT ArrayHandleBase
84 {
85 };
86 
91 template <typename T, typename StorageTag>
92 using IsValidArrayHandle =
93  std::integral_constant<bool,
94  !(std::is_base_of<vtkm::cont::internal::UndefinedStorage,
95  vtkm::cont::internal::Storage<T, StorageTag>>::value)>;
96 
101 template <typename T, typename StorageTag>
102 using IsInvalidArrayHandle =
103  std::integral_constant<bool, !IsValidArrayHandle<T, StorageTag>::value>;
104 
111 template <typename ArrayHandle>
112 using IsWritableArrayHandle =
113  vtkm::internal::PortalSupportsSets<typename std::decay<ArrayHandle>::type::WritePortalType>;
114 
127 template <typename T>
128 struct ArrayHandleCheck
129 {
130  using U = typename std::remove_pointer<T>::type;
131  using type = typename std::is_base_of<::vtkm::cont::internal::ArrayHandleBase, U>::type;
132 };
133 
134 #define VTKM_IS_ARRAY_HANDLE(T) \
135  VTKM_STATIC_ASSERT(::vtkm::cont::internal::ArrayHandleCheck<T>::type::value)
136 
137 } // namespace internal
138 
139 namespace detail
140 {
141 
142 template <typename T>
143 struct GetTypeInParentheses;
144 template <typename T>
145 struct GetTypeInParentheses<void(T)>
146 {
147  using type = T;
148 };
149 
150 } // namespace detail
151 
152 // Implementation for VTKM_ARRAY_HANDLE_SUBCLASS macros
153 #define VTK_M_ARRAY_HANDLE_SUBCLASS_IMPL(classname, fullclasstype, superclass, typename__) \
154  using Thisclass = typename__ vtkm::cont::detail::GetTypeInParentheses<void fullclasstype>::type; \
155  using Superclass = typename__ vtkm::cont::detail::GetTypeInParentheses<void superclass>::type; \
156  \
157  VTKM_IS_ARRAY_HANDLE(Superclass); \
158  \
159  VTKM_CONT \
160  classname() \
161  : Superclass() \
162  { \
163  } \
164  \
165  VTKM_CONT \
166  classname(const Thisclass& src) \
167  : Superclass(src) \
168  { \
169  } \
170  \
171  VTKM_CONT \
172  classname(Thisclass&& src) noexcept \
173  : Superclass(std::move(src)) \
174  { \
175  } \
176  \
177  VTKM_CONT \
178  classname(const vtkm::cont::ArrayHandle<typename__ Superclass::ValueType, \
179  typename__ Superclass::StorageTag>& src) \
180  : Superclass(src) \
181  { \
182  } \
183  \
184  VTKM_CONT \
185  classname(vtkm::cont::ArrayHandle<typename__ Superclass::ValueType, \
186  typename__ Superclass::StorageTag>&& src) noexcept \
187  : Superclass(std::move(src)) \
188  { \
189  } \
190  \
191  VTKM_CONT \
192  Thisclass& operator=(const Thisclass& src) \
193  { \
194  this->Superclass::operator=(src); \
195  return *this; \
196  } \
197  \
198  VTKM_CONT \
199  Thisclass& operator=(Thisclass&& src) noexcept \
200  { \
201  this->Superclass::operator=(std::move(src)); \
202  return *this; \
203  } \
204  \
205  using ValueType = typename__ Superclass::ValueType; \
206  using StorageTag = typename__ Superclass::StorageTag
207 
229 #define VTKM_ARRAY_HANDLE_SUBCLASS(classname, fullclasstype, superclass) \
230  VTK_M_ARRAY_HANDLE_SUBCLASS_IMPL(classname, fullclasstype, superclass, typename)
231 
252 #define VTKM_ARRAY_HANDLE_SUBCLASS_NT(classname, superclass) \
253  VTK_M_ARRAY_HANDLE_SUBCLASS_IMPL(classname, (classname), superclass, )
254 
255 namespace detail
256 {
257 
258 VTKM_CONT_EXPORT VTKM_CONT void ArrayHandleReleaseResourcesExecution(
259  const std::vector<vtkm::cont::internal::Buffer>& buffers);
260 
261 VTKM_CONT_EXPORT VTKM_CONT bool ArrayHandleIsOnDevice(
262  const std::vector<vtkm::cont::internal::Buffer>& buffers,
264 
265 VTKM_CONT_EXPORT VTKM_CONT vtkm::cont::DeviceAdapterId ArrayHandleGetDeviceAdapterId(
266  const std::vector<vtkm::cont::internal::Buffer>& buffers);
267 
268 } // namespace detail
269 
288 template <typename T, typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
289 class VTKM_ALWAYS_EXPORT ArrayHandle : public internal::ArrayHandleBase
290 {
292  (internal::IsValidArrayHandle<T, StorageTag_>::value),
293  "Attempted to create an ArrayHandle with an invalid type/storage combination.");
294 
295 public:
296  using ValueType = T;
297  using StorageTag = StorageTag_;
298  using StorageType = vtkm::cont::internal::Storage<ValueType, StorageTag>;
299 
300  using ReadPortalType = typename StorageType::ReadPortalType;
301  using WritePortalType = typename StorageType::WritePortalType;
302 
303  // TODO: Deprecate this
304  template <typename Device>
305  struct VTKM_DEPRECATED(1.6, "Use ReadPortalType and WritePortalType.") ExecutionTypes
306  {
307  using Portal = WritePortalType;
308  using PortalConst = ReadPortalType;
309  };
310 
311  using PortalControl VTKM_DEPRECATED(1.6, "Use ArrayHandle::WritePortalType instead.") =
313  using PortalConstControl VTKM_DEPRECATED(1.6, "Use ArrayHandle::ReadPortalType instead.") =
315 
319  : Buffers(static_cast<std::size_t>(StorageType::GetNumberOfBuffers()))
320  {
321  }
322 
331  : Buffers(src.Buffers)
332  {
333  }
334 
343  : Buffers(std::move(src.Buffers))
344  {
345  }
346 
351  VTKM_CONT ArrayHandle(const std::vector<vtkm::cont::internal::Buffer>& buffers)
352  : Buffers(buffers)
353  {
354  VTKM_ASSERT(static_cast<vtkm::IdComponent>(this->Buffers.size()) == this->GetNumberOfBuffers());
355  }
356 
357  VTKM_CONT ArrayHandle(std::vector<vtkm::cont::internal::Buffer>&& buffers) noexcept
358  : Buffers(std::move(buffers))
359  {
360  VTKM_ASSERT(static_cast<vtkm::IdComponent>(this->Buffers.size()) == this->GetNumberOfBuffers());
361  }
362 
363  VTKM_CONT ArrayHandle(const vtkm::cont::internal::Buffer* buffers)
364  : Buffers(buffers, buffers + StorageType::GetNumberOfBuffers())
365  {
366  }
368 
377 
380  VTKM_CONT
383  {
384  this->Buffers = src.Buffers;
385  return *this;
386  }
387 
390  VTKM_CONT
393  {
394  this->Buffers = std::move(src.Buffers);
395  return *this;
396  }
397 
401  VTKM_CONT
403  {
404  return this->Buffers == rhs.Buffers;
405  }
406 
407  VTKM_CONT
409  {
410  return this->Buffers != rhs.Buffers;
411  }
412 
413  template <typename VT, typename ST>
415  {
416  return false; // different valuetype and/or storage
417  }
418 
419  template <typename VT, typename ST>
421  {
422  return true; // different valuetype and/or storage
423  }
424 
426  {
427  return StorageType::GetNumberOfBuffers();
428  }
429 
433 
440  VTKM_CONT
441  VTKM_DEPRECATED(1.6,
442  "Use ArrayHandle::WritePortal() instead. "
443  "Note that the returned portal will lock the array while it is in scope.")
444 
445 
446  WritePortalType GetPortalControl() const { return this->WritePortal(); }
448 
455  VTKM_CONT
456  VTKM_DEPRECATED(1.6,
457  "Use ArrayHandle::ReadPortal() instead. "
458  "Note that the returned portal will lock the array while it is in scope.")
460  ReadPortalType GetPortalConstControl() const { return this->ReadPortal(); }
462 
473  VTKM_CONT ReadPortalType ReadPortal() const
474  {
475  vtkm::cont::Token token;
476  return StorageType::CreateReadPortal(
477  this->GetBuffers(), vtkm::cont::DeviceAdapterTagUndefined{}, token);
478  }
479 
490  {
491  vtkm::cont::Token token;
492 
493  return StorageType::CreateWritePortal(
494  this->GetBuffers(), vtkm::cont::DeviceAdapterTagUndefined{}, token);
495  }
496 
500  {
501  return StorageType::GetNumberOfValues(this->GetBuffers());
502  }
503 
516  VTKM_CONT void Allocate(vtkm::Id numberOfValues,
517  vtkm::CopyFlag preserve,
518  vtkm::cont::Token& token)
519  {
520  StorageType::ResizeBuffers(numberOfValues, this->GetBuffers(), preserve, token);
521  }
522 
524  {
525  vtkm::cont::Token token;
526  this->Allocate(numberOfValues, preserve, token);
527  }
529 
530  VTKM_DEPRECATED(1.6, "Use Allocate(n, vtkm::CopyFlag::On) instead of Shrink(n).")
531  VTKM_CONT void Shrink(vtkm::Id numberOfValues)
532  {
533  this->Allocate(numberOfValues, vtkm::CopyFlag::On);
534  }
535 
540  {
541  detail::ArrayHandleReleaseResourcesExecution(this->Buffers);
542  }
543 
546  VTKM_CONT void ReleaseResources() { this->Allocate(0); }
547 
562  vtkm::cont::Token& token) const
563  {
564  return StorageType::CreateReadPortal(this->GetBuffers(), device, token);
565  }
566 
581  vtkm::cont::Token& token) const
582  {
583  return StorageType::CreateWritePortal(this->GetBuffers(), device, token);
584  }
585 
602  vtkm::cont::Token& token)
603  {
604  this->Allocate(numberOfValues, vtkm::CopyFlag::Off, token);
605  return StorageType::CreateWritePortal(this->GetBuffers(), device, token);
606  }
607 
608  VTKM_CONT VTKM_DEPRECATED(1.6, "PrepareForInput now requires a vtkm::cont::Token object.")
609  ReadPortalType PrepareForInput(vtkm::cont::DeviceAdapterId device) const
610  {
611  vtkm::cont::Token token;
612  return this->PrepareForInput(device, token);
613  }
614  VTKM_CONT VTKM_DEPRECATED(1.6, "PrepareForOutput now requires a vtkm::cont::Token object.")
615  WritePortalType PrepareForOutput(vtkm::Id numberOfValues, vtkm::cont::DeviceAdapterId device)
616  {
617  vtkm::cont::Token token;
618  return this->PrepareForOutput(numberOfValues, device, token);
619  }
620  VTKM_CONT VTKM_DEPRECATED(1.6, "PrepareForInPlace now requires a vtkm::cont::Token object.")
621  WritePortalType PrepareForInPlace(vtkm::cont::DeviceAdapterId device) const
622  {
623  vtkm::cont::Token token;
624  return this->PrepareForInPlace(device, token);
625  }
626 
630  VTKM_CONT bool IsOnDevice(vtkm::cont::DeviceAdapterId device) const
631  {
632  return detail::ArrayHandleIsOnDevice(this->Buffers, device);
633  }
634 
638  VTKM_CONT bool IsOnHost() const
639  {
640  return this->IsOnDevice(vtkm::cont::DeviceAdapterTagUndefined{});
641  }
642 
652  VTKM_CONT
653  DeviceAdapterId GetDeviceAdapterId() const
654  {
655  return detail::ArrayHandleGetDeviceAdapterId(this->Buffers);
656  }
657 
664  VTKM_CONT void SyncControlArray() const
665  {
666  // Creating a host read portal will force the data to be synced to the host.
667  this->ReadPortal();
668  }
669 
691  VTKM_CONT void Enqueue(const vtkm::cont::Token& token) const
692  {
693  for (auto&& buffer : this->Buffers)
694  {
695  buffer.Enqueue(token);
696  }
697  }
698 
703  VTKM_CONT void DeepCopyFrom(const vtkm::cont::ArrayHandle<ValueType, StorageTag>& source) const
704  {
705  VTKM_ASSERT(this->Buffers.size() == source.Buffers.size());
706 
707  for (std::size_t bufferIndex = 0; bufferIndex < this->Buffers.size(); ++bufferIndex)
708  {
709  this->Buffers[bufferIndex].DeepCopyFrom(source.Buffers[bufferIndex]);
710  }
711  }
712 
715  VTKM_CONT vtkm::cont::internal::Buffer* GetBuffers() const { return this->Buffers.data(); }
716 
717 private:
718  mutable std::vector<vtkm::cont::internal::Buffer> Buffers;
719 
720 protected:
721  VTKM_CONT void SetBuffer(vtkm::IdComponent index, const vtkm::cont::internal::Buffer& buffer)
722  {
723  this->Buffers[static_cast<std::size_t>(index)] = buffer;
724  }
725 
726  // BufferContainer must be an iteratable container of Buffer objects.
727  template <typename BufferContainer>
728  VTKM_CONT void SetBuffers(const BufferContainer& buffers)
729  {
730  std::copy(buffers.begin(), buffers.end(), this->Iterators->Buffers.begin());
731  }
732 };
733 
734 namespace detail
735 {
736 
737 template <typename T>
738 VTKM_NEVER_EXPORT VTKM_CONT inline void
739 printSummary_ArrayHandle_Value(const T& value, std::ostream& out, vtkm::VecTraitsTagSingleComponent)
740 {
741  out << value;
742 }
743 
745 VTKM_CONT
746 inline void printSummary_ArrayHandle_Value(vtkm::UInt8 value,
747  std::ostream& out,
749 {
750  out << static_cast<int>(value);
751 }
752 
754 VTKM_CONT
755 inline void printSummary_ArrayHandle_Value(vtkm::Int8 value,
756  std::ostream& out,
758 {
759  out << static_cast<int>(value);
760 }
761 
762 template <typename T>
763 VTKM_NEVER_EXPORT VTKM_CONT inline void printSummary_ArrayHandle_Value(
764  const T& value,
765  std::ostream& out,
767 {
768  using Traits = vtkm::VecTraits<T>;
769  using ComponentType = typename Traits::ComponentType;
770  using IsVecOfVec = typename vtkm::VecTraits<ComponentType>::HasMultipleComponents;
771  vtkm::IdComponent numComponents = Traits::GetNumberOfComponents(value);
772  out << "(";
773  printSummary_ArrayHandle_Value(Traits::GetComponent(value, 0), out, IsVecOfVec());
774  for (vtkm::IdComponent index = 1; index < numComponents; ++index)
775  {
776  out << ",";
777  printSummary_ArrayHandle_Value(Traits::GetComponent(value, index), out, IsVecOfVec());
778  }
779  out << ")";
780 }
781 
782 template <typename T1, typename T2>
783 VTKM_NEVER_EXPORT VTKM_CONT inline void printSummary_ArrayHandle_Value(
784  const vtkm::Pair<T1, T2>& value,
785  std::ostream& out,
787 {
788  out << "{";
789  printSummary_ArrayHandle_Value(
790  value.first, out, typename vtkm::VecTraits<T1>::HasMultipleComponents());
791  out << ",";
792  printSummary_ArrayHandle_Value(
793  value.second, out, typename vtkm::VecTraits<T2>::HasMultipleComponents());
794  out << "}";
795 }
796 
797 
798 
799 } // namespace detail
800 
801 template <typename T, typename StorageT>
804  std::ostream& out,
805  bool full = false)
806 {
807  using ArrayType = vtkm::cont::ArrayHandle<T, StorageT>;
808  using PortalType = typename ArrayType::ReadPortalType;
809  using IsVec = typename vtkm::VecTraits<T>::HasMultipleComponents;
810 
811  vtkm::Id sz = array.GetNumberOfValues();
812 
813  out << "valueType=" << vtkm::cont::TypeToString<T>()
814  << " storageType=" << vtkm::cont::TypeToString<StorageT>() << " " << sz
815  << " values occupying " << (static_cast<size_t>(sz) * sizeof(T)) << " bytes [";
816 
817  PortalType portal = array.ReadPortal();
818  if (full || sz <= 7)
819  {
820  for (vtkm::Id i = 0; i < sz; i++)
821  {
822  detail::printSummary_ArrayHandle_Value(portal.Get(i), out, IsVec());
823  if (i != (sz - 1))
824  {
825  out << " ";
826  }
827  }
828  }
829  else
830  {
831  detail::printSummary_ArrayHandle_Value(portal.Get(0), out, IsVec());
832  out << " ";
833  detail::printSummary_ArrayHandle_Value(portal.Get(1), out, IsVec());
834  out << " ";
835  detail::printSummary_ArrayHandle_Value(portal.Get(2), out, IsVec());
836  out << " ... ";
837  detail::printSummary_ArrayHandle_Value(portal.Get(sz - 3), out, IsVec());
838  out << " ";
839  detail::printSummary_ArrayHandle_Value(portal.Get(sz - 2), out, IsVec());
840  out << " ";
841  detail::printSummary_ArrayHandle_Value(portal.Get(sz - 1), out, IsVec());
842  }
843  out << "]\n";
844 }
845 
846 namespace internal
847 {
848 
849 namespace detail
850 {
851 
852 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>&)
853 {
854  // Nothing left to add.
855 }
856 
857 template <typename T, typename S, typename... Args>
858 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
859  const vtkm::cont::ArrayHandle<T, S>& array,
860  const Args&... args)
861 {
862  vtkm::cont::internal::Buffer* arrayBuffers = array.GetBuffers();
863  buffers.insert(buffers.end(), arrayBuffers, arrayBuffers + array.GetNumberOfBuffers());
864  CreateBuffersImpl(buffers, args...);
865 }
866 
867 template <typename... Args>
868 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
869  const vtkm::cont::internal::Buffer& buffer,
870  const Args&... args)
871 {
872  buffers.push_back(buffer);
873  CreateBuffersImpl(buffers, args...);
874 }
875 
876 template <typename... Args>
877 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
878  const std::vector<vtkm::cont::internal::Buffer>& addbuffs,
879  const Args&... args)
880 {
881  buffers.insert(buffers.end(), addbuffs.begin(), addbuffs.end());
882  CreateBuffersImpl(buffers, args...);
883 }
884 
885 template <typename Arg0, typename... Args>
886 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
887  const Arg0& arg0,
888  const Args&... args);
889 
890 template <typename T, typename S, typename... Args>
891 VTKM_CONT inline void CreateBuffersResolveArrays(std::vector<vtkm::cont::internal::Buffer>& buffers,
892  std::true_type,
893  const vtkm::cont::ArrayHandle<T, S>& array,
894  const Args&... args)
895 {
896  CreateBuffersImpl(buffers, array, args...);
897 }
898 
899 template <typename MetaData, typename... Args>
900 VTKM_CONT inline void CreateBuffersResolveArrays(std::vector<vtkm::cont::internal::Buffer>& buffers,
901  std::false_type,
902  const MetaData& metadata,
903  const Args&... args)
904 {
905  vtkm::cont::internal::Buffer buffer;
906  buffer.SetMetaData(metadata);
907  buffers.push_back(std::move(buffer));
908  CreateBuffersImpl(buffers, args...);
909 }
910 
911 template <typename Arg0, typename... Args>
912 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
913  const Arg0& arg0,
914  const Args&... args)
915 {
916  // If the argument is a subclass of ArrayHandle, the template resolution will pick this
917  // overload instead of the correct ArrayHandle overload. To resolve that, check to see
918  // if the type is an `ArrayHandle` and use `CreateBuffersResolveArrays` to choose the
919  // right path.
920  using IsArray = typename vtkm::cont::internal::ArrayHandleCheck<Arg0>::type::type;
921  CreateBuffersResolveArrays(buffers, IsArray{}, arg0, args...);
922 }
923 
924 } // namespace detail
925 
940 template <typename... Args>
941 VTKM_CONT inline std::vector<vtkm::cont::internal::Buffer> CreateBuffers(const Args&... args)
942 {
943  std::vector<vtkm::cont::internal::Buffer> buffers;
944  buffers.reserve(sizeof...(args));
945  detail::CreateBuffersImpl(buffers, args...);
946  return buffers;
947 }
948 
949 } // namespace internal
950 
951 }
952 } //namespace vtkm::cont
953 
954 #ifndef vtk_m_cont_ArrayHandleBasic_h
956 #endif
957 
958 #endif //vtk_m_cont_ArrayHandle_h
vtkm::cont::ArrayHandle::GetNumberOfValues
VTKM_CONT vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:499
vtkm::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:289
vtkm::cont::VTKM_DEPRECATED
struct VTKM_DEPRECATED(1.6, "Use vtkm::ColorSpace.") ColorSpace
Definition: cont/ColorTable.h:36
vtkm::cont::ArrayHandle::operator=
VTKM_CONT vtkm::cont::ArrayHandle< ValueType, StorageTag > & operator=(vtkm::cont::ArrayHandle< ValueType, StorageTag > &&src) noexcept
Move and Assignment of an ArrayHandle.
Definition: ArrayHandle.h:391
vtkm::VecTraitsTagMultipleComponents
A tag for vectors that are "true" vectors (i.e.
Definition: VecTraits.h:21
vtkm
VTKM_NO_DEPRECATED_VIRTUAL.
Definition: Algorithms.h:23
Types.h
vtkm::cont::ArrayHandle::ArrayHandle
VTKM_CONT ArrayHandle(const std::vector< vtkm::cont::internal::Buffer > &buffers)
Definition: ArrayHandle.h:351
ArrayPortalHelpers.h
VTKM_ASSERT
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
vtkm::cont::ArrayHandle::PrepareForInput
VTKM_CONT ReadPortalType PrepareForInput(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Prepares this array to be used as an input to an operation in the execution environment.
Definition: ArrayHandle.h:561
vtkm::IdComponent
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
vtkm::cont::printSummary_ArrayHandle
VTKM_NEVER_EXPORT VTKM_CONT void printSummary_ArrayHandle(const vtkm::cont::ArrayHandle< T, StorageT > &array, std::ostream &out, bool full=false)
Definition: ArrayHandle.h:802
vtkm::cont::ArrayHandle::operator=
VTKM_CONT vtkm::cont::ArrayHandle< ValueType, StorageTag > & operator=(const vtkm::cont::ArrayHandle< ValueType, StorageTag > &src)
Copies an ArrayHandle.
Definition: ArrayHandle.h:381
vtkm::cont::ArrayHandle::ReleaseResources
VTKM_CONT void ReleaseResources()
Releases all resources in both the control and execution environments.
Definition: ArrayHandle.h:546
ArrayHandleBasic.h
vtkm::cont::ArrayHandle::operator!=
VTKM_CONT bool operator!=(const ArrayHandle< ValueType, StorageTag > &rhs) const
Definition: ArrayHandle.h:408
DeviceAdapterList.h
Storage.h
vtkm::cont::ArrayHandle::ReleaseResourcesExecution
VTKM_CONT void ReleaseResourcesExecution() const
Releases any resources being used in the execution environment (that are not being shared by the cont...
Definition: ArrayHandle.h:539
vtkm::cont::ArrayHandle::ArrayHandle
VTKM_CONT ArrayHandle(const vtkm::cont::internal::Buffer *buffers)
Definition: ArrayHandle.h:363
Assert.h
vtkm::cont::ArrayHandle::VTKM_DEPRECATED
VTKM_DEPRECATED(1.6, "Use Allocate(n, vtkm::CopyFlag::On) instead of Shrink(n).") VTKM_CONT void Shrink(vtkm
Definition: ArrayHandle.h:530
vtkm::cont::ArrayHandle::GetStorage
VTKM_CONT StorageType GetStorage() const
Get the storage.
Definition: ArrayHandle.h:432
vtkm::cont::ArrayHandle::PrepareForInPlace
VTKM_CONT WritePortalType PrepareForInPlace(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Prepares this array to be used in an in-place operation (both as input and output) in the execution e...
Definition: ArrayHandle.h:580
vtkm::cont::ArrayHandle::~ArrayHandle
VTKM_CONT ~ArrayHandle()
Destructs an empty ArrayHandle.
Definition: ArrayHandle.h:376
vtkm::cont::ArrayHandle< vtkm::Id >::ValueType
vtkm::Id ValueType
Definition: ArrayHandle.h:296
vtkm::cont::ArrayHandle< vtkm::Id >::ReadPortalType
typename StorageType::ReadPortalType ReadPortalType
Definition: ArrayHandle.h:300
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::cont::ArrayHandle::operator==
VTKM_CONT bool operator==(const ArrayHandle< VT, ST > &) const
Definition: ArrayHandle.h:414
vtkm::cont::ArrayHandle::VTKM_DEPRECATED
VTKM_CONT VTKM_DEPRECATED(1.6, "PrepareForInput now requires a vtkm::cont::Token object.") ReadPortalType PrepareForInput(vtkm
Definition: ArrayHandle.h:608
vtkm::cont::ArrayHandle::GetNumberOfBuffers
static constexpr VTKM_CONT vtkm::IdComponent GetNumberOfBuffers()
Definition: ArrayHandle.h:425
vtkm::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
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::cont::ArrayHandle::ArrayHandle
VTKM_CONT ArrayHandle()
Constructs an empty ArrayHandle.
Definition: ArrayHandle.h:318
vtkm::Int8
int8_t Int8
Definition: Types.h:156
vtkm::cont::ArrayHandle::ArrayHandle
VTKM_CONT ArrayHandle(vtkm::cont::ArrayHandle< ValueType, StorageTag > &&src) noexcept
Move constructor.
Definition: ArrayHandle.h:342
vtkm::Pair::first
FirstType first
The pair's first object.
Definition: Pair.h:50
VTKM_STATIC_ASSERT_MSG
#define VTKM_STATIC_ASSERT_MSG(condition, message)
Definition: StaticAssert.h:18
Buffer.h
vtkm::cont::ArrayHandle::SetBuffer
VTKM_CONT void SetBuffer(vtkm::IdComponent index, const vtkm::cont::internal::Buffer &buffer)
Returns true if the ArrayHandle's data is on the given device.
Definition: ArrayHandle.h:721
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::cont::ArrayHandle::PrepareForOutput
VTKM_CONT WritePortalType PrepareForOutput(vtkm::Id numberOfValues, vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token)
Prepares (allocates) this array to be used as an output from an operation in the execution environmen...
Definition: ArrayHandle.h:600
vtkm::cont::ArrayHandle::WritePortal
VTKM_CONT WritePortalType WritePortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:489
vtkm::cont::ArrayHandle< vtkm::Id >::WritePortalType
typename StorageType::WritePortalType WritePortalType
Definition: ArrayHandle.h:301
vtkm::UInt8
uint8_t UInt8
Definition: Types.h:157
vtkm::cont::ArrayHandle::Allocate
VTKM_CONT void Allocate(vtkm::Id numberOfValues, vtkm::CopyFlag preserve=vtkm::CopyFlag::Off)
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:523
vtkm::cont::ArrayHandle::operator!=
VTKM_CONT bool operator!=(const ArrayHandle< VT, ST > &) const
Definition: ArrayHandle.h:420
vtkm::CopyFlag::On
@ On
vtkm::cont::ArrayHandle::SetBuffers
VTKM_CONT void SetBuffers(const BufferContainer &buffers)
Definition: ArrayHandle.h:728
vtkm::cont::DeviceAdapterId
Definition: DeviceAdapterTag.h:52
vtkm::VecTraitsTagSingleComponent
A tag for vectors that are really just scalars (i.e.
Definition: VecTraits.h:28
vtkm::CopyFlag::Off
@ Off
vtkm::cont::ArrayHandle::ArrayHandle
VTKM_CONT ArrayHandle(std::vector< vtkm::cont::internal::Buffer > &&buffers) noexcept
Definition: ArrayHandle.h:357
Deprecated.h
ErrorBadValue.h
vtkm::cont::ArrayHandle< vtkm::Id >::StorageTag
VTKM_DEFAULT_STORAGE_TAG StorageTag
Definition: ArrayHandle.h:297
vtkm::cont::ArrayHandle< vtkm::Id >::StorageType
vtkm::cont::internal::Storage< ValueType, StorageTag > StorageType
Definition: ArrayHandle.h:298
vtkm::cont::StorageTagBasic
A tag for the basic implementation of a Storage object.
Definition: ArrayHandle.h:46
vtkm::CopyFlag
CopyFlag
Definition: Flags.h:16
vtkm::cont::ArrayHandle::ArrayHandle
VTKM_CONT ArrayHandle(const vtkm::cont::ArrayHandle< ValueType, StorageTag > &src)
Copy constructor.
Definition: ArrayHandle.h:330
VTKM_NEVER_EXPORT
#define VTKM_NEVER_EXPORT
Definition: ExportMacros.h:93
vtkm::VecTraits< T >
ErrorInternal.h
VTKM_ALWAYS_EXPORT
#define VTKM_ALWAYS_EXPORT
Definition: ExportMacros.h:92
Flags.h
vtkm::cont::ArrayHandle::Allocate
VTKM_CONT void Allocate(vtkm::Id numberOfValues, vtkm::CopyFlag preserve, vtkm::cont::Token &token)
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:516
vtkm::cont::ArrayHandle::operator==
VTKM_CONT bool operator==(const ArrayHandle< ValueType, StorageTag > &rhs) const
Like a pointer, two ArrayHandles are considered equal if they point to the same location in memory.
Definition: ArrayHandle.h:402
vtkm::Pair
A vtkm::Pair is essentially the same as an STL pair object except that the methods (constructors and ...
Definition: Pair.h:29
Token.h
vtkm::Pair::second
SecondType second
The pair's second object.
Definition: Pair.h:55
StorageError.h