VTK-m  2.2
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 
14 
15 #include <vtkm/Assert.h>
16 #include <vtkm/Flags.h>
17 #include <vtkm/Types.h>
18 
22 #include <vtkm/cont/Storage.h>
23 #include <vtkm/cont/Token.h>
24 
26 
27 #include <algorithm>
28 #include <deque>
29 #include <iterator>
30 #include <memory>
31 #include <mutex>
32 #include <vector>
33 
35 
36 namespace vtkm
37 {
38 namespace cont
39 {
40 
41 // Normally this would be defined in ArrayHandleBasic.h, but we need this declared early for
42 // the default storage.
43 
46 {
47 };
48 }
49 } // namespace vtkm::cont
50 
51 #if VTKM_STORAGE == VTKM_STORAGE_BASIC
52 
53 #define VTKM_DEFAULT_STORAGE_TAG ::vtkm::cont::StorageTagBasic
54 
55 #elif VTKM_STORAGE == VTKM_STORAGE_ERROR
56 
58 #define VTKM_DEFAULT_STORAGE_TAG ::vtkm::cont::internal::StorageTagError
59 
60 #elif (VTKM_STORAGE == VTKM_STORAGE_UNDEFINED) || !defined(VTKM_STORAGE)
61 
62 #ifndef VTKM_DEFAULT_STORAGE_TAG
63 #warning If array storage is undefined, VTKM_DEFAULT_STORAGE_TAG must be defined.
64 #endif
65 
66 #endif
67 
68 namespace vtkm
69 {
70 namespace cont
71 {
72 
73 namespace internal
74 {
75 
82 class VTKM_CONT_EXPORT ArrayHandleBase
83 {
84 };
85 
90 template <typename T, typename StorageTag>
91 using IsValidArrayHandle =
92  std::integral_constant<bool,
93  !(std::is_base_of<vtkm::cont::internal::UndefinedStorage,
94  vtkm::cont::internal::Storage<T, StorageTag>>::value)>;
95 
100 template <typename T, typename StorageTag>
101 using IsInvalidArrayHandle =
102  std::integral_constant<bool, !IsValidArrayHandle<T, StorageTag>::value>;
103 
110 template <typename ArrayHandle>
111 using IsWritableArrayHandle =
112  vtkm::internal::PortalSupportsSets<typename std::decay<ArrayHandle>::type::WritePortalType>;
113 
126 template <typename T>
127 struct ArrayHandleCheck
128  : std::is_base_of<vtkm::cont::internal::ArrayHandleBase, std::decay_t<T>>::type
129 {
130 };
131 
137 #define VTKM_IS_ARRAY_HANDLE(T) VTKM_STATIC_ASSERT(::vtkm::cont::internal::ArrayHandleCheck<T>{})
138 
139 } // namespace internal
140 
141 namespace detail
142 {
143 
144 template <typename T>
145 struct GetTypeInParentheses;
146 template <typename T>
147 struct GetTypeInParentheses<void(T)>
148 {
149  using type = T;
150 };
151 
152 } // namespace detail
153 
154 // Implementation for VTKM_ARRAY_HANDLE_SUBCLASS macros
155 #define VTK_M_ARRAY_HANDLE_SUBCLASS_IMPL(classname, fullclasstype, superclass, typename__) \
156  using Thisclass = typename__ vtkm::cont::detail::GetTypeInParentheses<void fullclasstype>::type; \
157  using Superclass = typename__ vtkm::cont::detail::GetTypeInParentheses<void superclass>::type; \
158  \
159  VTKM_IS_ARRAY_HANDLE(Superclass); \
160  \
161  VTKM_CONT \
162  classname() {} \
163  \
164  VTKM_CONT \
165  classname(const Thisclass& src) \
166  : Superclass(src) \
167  { \
168  } \
169  \
170  VTKM_CONT \
171  classname(Thisclass&& src) noexcept \
172  : Superclass(std::move(src)) \
173  { \
174  } \
175  \
176  VTKM_CONT \
177  classname(const vtkm::cont::ArrayHandle<typename__ Superclass::ValueType, \
178  typename__ Superclass::StorageTag>& src) \
179  : Superclass(src) \
180  { \
181  } \
182  \
183  VTKM_CONT \
184  classname(vtkm::cont::ArrayHandle<typename__ Superclass::ValueType, \
185  typename__ Superclass::StorageTag>&& src) noexcept \
186  : Superclass(std::move(src)) \
187  { \
188  } \
189  \
190  VTKM_CONT \
191  explicit classname(const std::vector<vtkm::cont::internal::Buffer>& buffers) \
192  : Superclass(buffers) \
193  { \
194  } \
195  \
196  VTKM_CONT \
197  explicit classname(std::vector<vtkm::cont::internal::Buffer>&& buffers) noexcept \
198  : Superclass(std::move(buffers)) \
199  { \
200  } \
201  \
202  VTKM_CONT \
203  Thisclass& operator=(const Thisclass& src) \
204  { \
205  this->Superclass::operator=(src); \
206  return *this; \
207  } \
208  \
209  VTKM_CONT \
210  Thisclass& operator=(Thisclass&& src) noexcept \
211  { \
212  this->Superclass::operator=(std::move(src)); \
213  return *this; \
214  } \
215  \
216  using ValueType = typename__ Superclass::ValueType; \
217  using StorageTag = typename__ Superclass::StorageTag; \
218  using StorageType = typename__ Superclass::StorageType; \
219  using ReadPortalType = typename__ Superclass::ReadPortalType; \
220  using WritePortalType = typename__ Superclass::WritePortalType
221 
243 #define VTKM_ARRAY_HANDLE_SUBCLASS(classname, fullclasstype, superclass) \
244  VTK_M_ARRAY_HANDLE_SUBCLASS_IMPL(classname, fullclasstype, superclass, typename)
245 
266 #define VTKM_ARRAY_HANDLE_SUBCLASS_NT(classname, superclass) \
267  VTK_M_ARRAY_HANDLE_SUBCLASS_IMPL(classname, (classname), superclass, )
268 
269 namespace detail
270 {
271 
272 VTKM_CONT_EXPORT VTKM_CONT void ArrayHandleReleaseResourcesExecution(
273  const std::vector<vtkm::cont::internal::Buffer>& buffers);
274 
275 VTKM_CONT_EXPORT VTKM_CONT bool ArrayHandleIsOnDevice(
276  const std::vector<vtkm::cont::internal::Buffer>& buffers,
278 
279 } // namespace detail
280 
299 template <typename T, typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
300 class VTKM_ALWAYS_EXPORT ArrayHandle : public internal::ArrayHandleBase
301 {
303  (internal::IsValidArrayHandle<T, StorageTag_>::value),
304  "Attempted to create an ArrayHandle with an invalid type/storage combination.");
305 
306 public:
307  using ValueType = T;
308  using StorageTag = StorageTag_;
309  using StorageType = vtkm::cont::internal::Storage<ValueType, StorageTag>;
310 
312  using ReadPortalType = typename StorageType::ReadPortalType;
314  using WritePortalType = typename StorageType::WritePortalType;
315 
319  : Buffers(StorageType::CreateBuffers())
320  {
321  }
322 
331  : Buffers(src.Buffers)
332  {
333  }
334 
343  : Buffers(std::move(src.Buffers))
344  {
345  }
346 
350  VTKM_CONT explicit ArrayHandle(const std::vector<vtkm::cont::internal::Buffer>& buffers)
351  : Buffers(buffers)
352  {
353  }
354 
358  VTKM_CONT explicit ArrayHandle(std::vector<vtkm::cont::internal::Buffer>&& buffers) noexcept
359  : Buffers(std::move(buffers))
360  {
361  }
362 
371 
374  VTKM_CONT
377  {
378  this->Buffers = src.Buffers;
379  return *this;
380  }
381 
384  VTKM_CONT
387  {
388  this->Buffers = std::move(src.Buffers);
389  return *this;
390  }
391 
395  VTKM_CONT
397  {
398  return this->Buffers == rhs.Buffers;
399  }
400 
401  VTKM_CONT
403  {
404  return this->Buffers != rhs.Buffers;
405  }
406 
407  template <typename VT, typename ST>
409  {
410  return false; // different valuetype and/or storage
411  }
412 
413  template <typename VT, typename ST>
415  {
416  return true; // different valuetype and/or storage
417  }
418 
422 
434  {
435  vtkm::cont::Token token;
436  return this->ReadPortal(token);
437  }
440  {
441  return StorageType::CreateReadPortal(
442  this->GetBuffers(), vtkm::cont::DeviceAdapterTagUndefined{}, token);
443  }
444 
455  {
456  vtkm::cont::Token token;
457  return this->WritePortal(token);
458  }
461  {
462  return StorageType::CreateWritePortal(
463  this->GetBuffers(), vtkm::cont::DeviceAdapterTagUndefined{}, token);
464  }
465 
469  {
470  return StorageType::GetNumberOfValues(this->GetBuffers());
471  }
472 
475  {
476  return StorageType::GetNumberOfComponentsFlat(this->GetBuffers());
477  }
478 
490  VTKM_CONT void Allocate(vtkm::Id numberOfValues,
491  vtkm::CopyFlag preserve,
492  vtkm::cont::Token& token) const
493  {
494  StorageType::ResizeBuffers(numberOfValues, this->GetBuffers(), preserve, token);
495  }
496 
498  VTKM_CONT void Allocate(vtkm::Id numberOfValues,
499  vtkm::CopyFlag preserve = vtkm::CopyFlag::Off) const
500  {
501  vtkm::cont::Token token;
502  this->Allocate(numberOfValues, preserve, token);
503  }
504 
519  VTKM_CONT void AllocateAndFill(vtkm::Id numberOfValues,
520  const ValueType& fillValue,
521  vtkm::CopyFlag preserve,
522  vtkm::cont::Token& token) const
523  {
524  // Note that there is a slight potential for a race condition here. It is possible for someone
525  // else to resize the array in between getting the startIndex and locking the array in the
526  // Allocate call. If there really are 2 threads trying to allocate this array at the same time,
527  // you probably have bigger problems than filling at the wrong index.
528  vtkm::Id startIndex = (preserve == vtkm::CopyFlag::On) ? this->GetNumberOfValues() : 0;
529 
530  this->Allocate(numberOfValues, preserve, token);
531 
532  if (startIndex < numberOfValues)
533  {
534  this->Fill(fillValue, startIndex, numberOfValues, token);
535  }
536  }
537 
539  VTKM_CONT void AllocateAndFill(vtkm::Id numberOfValues,
540  const ValueType& fillValue,
541  vtkm::CopyFlag preserve = vtkm::CopyFlag::Off) const
542  {
543  vtkm::cont::Token token;
544  this->AllocateAndFill(numberOfValues, fillValue, preserve, token);
545  }
546 
554  VTKM_CONT void Fill(const ValueType& fillValue,
555  vtkm::Id startIndex,
556  vtkm::Id endIndex,
557  vtkm::cont::Token& token) const
558  {
559  StorageType::Fill(this->GetBuffers(), fillValue, startIndex, endIndex, token);
560  }
562  VTKM_CONT void Fill(const ValueType& fillValue, vtkm::Id startIndex, vtkm::Id endIndex) const
563  {
564  vtkm::cont::Token token;
565  this->Fill(fillValue, startIndex, endIndex, token);
566  }
568  VTKM_CONT void Fill(const ValueType& fillValue, vtkm::Id startIndex = 0) const
569  {
570  vtkm::cont::Token token;
571  this->Fill(fillValue, startIndex, this->GetNumberOfValues(), token);
572  }
573 
578  {
579  detail::ArrayHandleReleaseResourcesExecution(this->Buffers);
580  }
581 
584  VTKM_CONT void ReleaseResources() const { this->Allocate(0); }
585 
600  vtkm::cont::Token& token) const
601  {
602  return StorageType::CreateReadPortal(this->GetBuffers(), device, token);
603  }
604 
619  vtkm::cont::Token& token) const
620  {
621  return StorageType::CreateWritePortal(this->GetBuffers(), device, token);
622  }
623 
640  vtkm::cont::Token& token) const
641  {
642  this->Allocate(numberOfValues, vtkm::CopyFlag::Off, token);
643  return StorageType::CreateWritePortal(this->GetBuffers(), device, token);
644  }
645 
650  {
651  return detail::ArrayHandleIsOnDevice(this->Buffers, device);
652  }
653 
657  VTKM_CONT bool IsOnHost() const
658  {
659  return this->IsOnDevice(vtkm::cont::DeviceAdapterTagUndefined{});
660  }
661 
669  {
670  // Creating a host read portal will force the data to be synced to the host.
671  this->ReadPortal();
672  }
673 
695  VTKM_CONT void Enqueue(const vtkm::cont::Token& token) const
696  {
697  for (auto&& buffer : this->Buffers)
698  {
699  buffer.Enqueue(token);
700  }
701  }
702 
708  {
709  VTKM_ASSERT(this->Buffers.size() == source.Buffers.size());
710 
711  for (std::size_t bufferIndex = 0; bufferIndex < this->Buffers.size(); ++bufferIndex)
712  {
713  this->Buffers[bufferIndex].DeepCopyFrom(source.Buffers[bufferIndex]);
714  }
715  }
716 
721  VTKM_CONT const std::vector<vtkm::cont::internal::Buffer>& GetBuffers() const
722  {
723  return this->Buffers;
724  }
725  VTKM_CONT std::vector<vtkm::cont::internal::Buffer>& GetBuffers() { return this->Buffers; }
726 
727 private:
728  mutable std::vector<vtkm::cont::internal::Buffer> Buffers;
729 
730 protected:
731  VTKM_CONT void SetBuffer(vtkm::IdComponent index, const vtkm::cont::internal::Buffer& buffer)
732  {
733  this->Buffers[static_cast<std::size_t>(index)] = buffer;
734  }
735 
736  VTKM_CONT void SetBuffers(const std::vector<vtkm::cont::internal::Buffer>& buffers)
737  {
738  this->Buffers = buffers;
739  }
740  VTKM_CONT void SetBuffers(std::vector<vtkm::cont::internal::Buffer>&& buffers)
741  {
742  this->Buffers = std::move(buffers);
743  }
744 };
745 
746 namespace detail
747 {
748 
749 template <typename T>
750 VTKM_NEVER_EXPORT VTKM_CONT inline void
751 printSummary_ArrayHandle_Value(const T& value, std::ostream& out, vtkm::VecTraitsTagSingleComponent)
752 {
753  out << value;
754 }
755 
757 VTKM_CONT
758 inline void printSummary_ArrayHandle_Value(vtkm::UInt8 value,
759  std::ostream& out,
761 {
762  out << static_cast<int>(value);
763 }
764 
766 VTKM_CONT
767 inline void printSummary_ArrayHandle_Value(vtkm::Int8 value,
768  std::ostream& out,
770 {
771  out << static_cast<int>(value);
772 }
773 
774 template <typename T>
775 VTKM_NEVER_EXPORT VTKM_CONT inline void printSummary_ArrayHandle_Value(
776  const T& value,
777  std::ostream& out,
779 {
780  using Traits = vtkm::VecTraits<T>;
781  using ComponentType = typename Traits::ComponentType;
782  using IsVecOfVec = typename vtkm::VecTraits<ComponentType>::HasMultipleComponents;
783  vtkm::IdComponent numComponents = Traits::GetNumberOfComponents(value);
784  out << "(";
785  printSummary_ArrayHandle_Value(Traits::GetComponent(value, 0), out, IsVecOfVec());
786  for (vtkm::IdComponent index = 1; index < numComponents; ++index)
787  {
788  out << ",";
789  printSummary_ArrayHandle_Value(Traits::GetComponent(value, index), out, IsVecOfVec());
790  }
791  out << ")";
792 }
793 
794 template <typename T1, typename T2>
795 VTKM_NEVER_EXPORT VTKM_CONT inline void printSummary_ArrayHandle_Value(
796  const vtkm::Pair<T1, T2>& value,
797  std::ostream& out,
799 {
800  out << "{";
801  printSummary_ArrayHandle_Value(
802  value.first, out, typename vtkm::VecTraits<T1>::HasMultipleComponents());
803  out << ",";
804  printSummary_ArrayHandle_Value(
805  value.second, out, typename vtkm::VecTraits<T2>::HasMultipleComponents());
806  out << "}";
807 }
808 
809 
810 
811 } // namespace detail
812 
813 template <typename T, typename StorageT>
816  std::ostream& out,
817  bool full = false)
818 {
819  using ArrayType = vtkm::cont::ArrayHandle<T, StorageT>;
820  using PortalType = typename ArrayType::ReadPortalType;
821  using IsVec = typename vtkm::VecTraits<T>::HasMultipleComponents;
822 
823  vtkm::Id sz = array.GetNumberOfValues();
824 
825  out << "valueType=" << vtkm::cont::TypeToString<T>()
826  << " storageType=" << vtkm::cont::TypeToString<StorageT>() << " " << sz
827  << " values occupying " << (static_cast<size_t>(sz) * sizeof(T)) << " bytes [";
828 
829  PortalType portal = array.ReadPortal();
830  if (full || sz <= 7)
831  {
832  for (vtkm::Id i = 0; i < sz; i++)
833  {
834  detail::printSummary_ArrayHandle_Value(portal.Get(i), out, IsVec());
835  if (i != (sz - 1))
836  {
837  out << " ";
838  }
839  }
840  }
841  else
842  {
843  detail::printSummary_ArrayHandle_Value(portal.Get(0), out, IsVec());
844  out << " ";
845  detail::printSummary_ArrayHandle_Value(portal.Get(1), out, IsVec());
846  out << " ";
847  detail::printSummary_ArrayHandle_Value(portal.Get(2), out, IsVec());
848  out << " ... ";
849  detail::printSummary_ArrayHandle_Value(portal.Get(sz - 3), out, IsVec());
850  out << " ";
851  detail::printSummary_ArrayHandle_Value(portal.Get(sz - 2), out, IsVec());
852  out << " ";
853  detail::printSummary_ArrayHandle_Value(portal.Get(sz - 1), out, IsVec());
854  }
855  out << "]\n";
856 }
857 
858 namespace internal
859 {
860 
861 namespace detail
862 {
863 
864 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>&);
865 template <typename T, typename S, typename... Args>
866 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
867  const vtkm::cont::ArrayHandle<T, S>& array,
868  const Args&... args);
869 template <typename... Args>
870 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
871  const vtkm::cont::internal::Buffer& buffer,
872  const Args&... args);
873 
874 template <typename... Args>
875 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
876  const std::vector<vtkm::cont::internal::Buffer>& addbuffs,
877  const Args&... args);
878 template <typename Arg0, typename... Args>
879 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
880  const Arg0& arg0,
881  const Args&... args);
882 
883 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>&)
884 {
885  // Nothing left to add.
886 }
887 
888 template <typename T, typename S, typename... Args>
889 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
890  const vtkm::cont::ArrayHandle<T, S>& array,
891  const Args&... args)
892 {
893  CreateBuffersImpl(buffers, array.GetBuffers(), args...);
894 }
895 
896 template <typename... Args>
897 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
898  const vtkm::cont::internal::Buffer& buffer,
899  const Args&... args)
900 {
901  buffers.push_back(buffer);
902  CreateBuffersImpl(buffers, args...);
903 }
904 
905 template <typename... Args>
906 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
907  const std::vector<vtkm::cont::internal::Buffer>& addbuffs,
908  const Args&... args)
909 {
910  buffers.insert(buffers.end(), addbuffs.begin(), addbuffs.end());
911  CreateBuffersImpl(buffers, args...);
912 }
913 
914 template <typename T, typename S, typename... Args>
915 VTKM_CONT inline void CreateBuffersResolveArrays(std::vector<vtkm::cont::internal::Buffer>& buffers,
916  std::true_type,
917  const vtkm::cont::ArrayHandle<T, S>& array,
918  const Args&... args)
919 {
920  CreateBuffersImpl(buffers, array, args...);
921 }
922 
923 template <typename MetaData, typename... Args>
924 VTKM_CONT inline void CreateBuffersResolveArrays(std::vector<vtkm::cont::internal::Buffer>& buffers,
925  std::false_type,
926  const MetaData& metadata,
927  const Args&... args)
928 {
929  vtkm::cont::internal::Buffer buffer;
930  buffer.SetMetaData(metadata);
931  buffers.push_back(std::move(buffer));
932  CreateBuffersImpl(buffers, args...);
933 }
934 
935 template <typename Arg0, typename... Args>
936 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
937  const Arg0& arg0,
938  const Args&... args)
939 {
940  // If the argument is a subclass of ArrayHandle, the template resolution will pick this
941  // overload instead of the correct ArrayHandle overload. To resolve that, check to see
942  // if the type is an `ArrayHandle` and use `CreateBuffersResolveArrays` to choose the
943  // right path.
944  using IsArray = typename vtkm::cont::internal::ArrayHandleCheck<Arg0>::type::type;
945  CreateBuffersResolveArrays(buffers, IsArray{}, arg0, args...);
946 }
947 
948 } // namespace detail
949 
964 template <typename... Args>
965 VTKM_CONT inline std::vector<vtkm::cont::internal::Buffer> CreateBuffers(const Args&... args)
966 {
967  std::vector<vtkm::cont::internal::Buffer> buffers;
968  buffers.reserve(sizeof...(args));
969  detail::CreateBuffersImpl(buffers, args...);
970  return buffers;
971 }
972 
973 } // namespace internal
974 
975 }
976 } //namespace vtkm::cont
977 
978 #ifndef vtk_m_cont_ArrayHandleBasic_h
980 #endif
981 
982 #endif //vtk_m_cont_ArrayHandle_h
vtkm::cont::ArrayHandle::SyncControlArray
void SyncControlArray() const
Synchronizes the control array with the execution array.
Definition: ArrayHandle.h:668
vtkm::cont::ArrayHandle::AllocateAndFill
void AllocateAndFill(vtkm::Id numberOfValues, const ValueType &fillValue, vtkm::CopyFlag preserve=vtkm::CopyFlag::Off) const
Allocates an array and fills it with an initial value.
Definition: ArrayHandle.h:539
vtkm::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:300
vtkm::cont::ArrayHandle::Buffers
std::vector< vtkm::cont::internal::Buffer > Buffers
Definition: ArrayHandle.h:728
vtkm::cont::ArrayHandle::operator==
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:396
vtkm::cont::ArrayHandle::GetBuffers
const std::vector< vtkm::cont::internal::Buffer > & GetBuffers() const
Returns the internal Buffer structures that hold the data.
Definition: ArrayHandle.h:721
vtkm::VecTraitsTagMultipleComponents
A tag for vectors that are "true" vectors (i.e.
Definition: VecTraits.h:23
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::cont::ArrayHandle::GetStorage
StorageType GetStorage() const
Get the storage.
Definition: ArrayHandle.h:421
vtkm::cont::ArrayHandle::Enqueue
void Enqueue(const vtkm::cont::Token &token) const
Enqueue a token for access to this ArrayHandle.
Definition: ArrayHandle.h:695
Types.h
ArrayPortalHelpers.h
VTKM_ASSERT
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
vtkm::IdComponent
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
vtkm::cont::printSummary_ArrayHandle
void printSummary_ArrayHandle(const vtkm::cont::ArrayHandle< T, StorageT > &array, std::ostream &out, bool full=false)
Definition: ArrayHandle.h:814
vtkm::cont::ArrayHandle::Fill
void Fill(const ValueType &fillValue, vtkm::Id startIndex, vtkm::Id endIndex, vtkm::cont::Token &token) const
Fills the array with a given value.
Definition: ArrayHandle.h:554
vtkm::cont::ArrayHandle::ReleaseResourcesExecution
void ReleaseResourcesExecution() const
Releases any resources being used in the execution environment (that are not being shared by the cont...
Definition: ArrayHandle.h:577
vtkm::cont::ArrayHandle::operator!=
bool operator!=(const ArrayHandle< ValueType, StorageTag > &rhs) const
Definition: ArrayHandle.h:402
vtkm::cont::ArrayHandle::operator=
vtkm::cont::ArrayHandle< ValueType, StorageTag > & operator=(const vtkm::cont::ArrayHandle< ValueType, StorageTag > &src)
Shallow copies an ArrayHandle.
Definition: ArrayHandle.h:375
ArrayHandleBasic.h
DeviceAdapterList.h
vtkm::cont::ArrayHandle::SetBuffer
void SetBuffer(vtkm::IdComponent index, const vtkm::cont::internal::Buffer &buffer)
Definition: ArrayHandle.h:731
Storage.h
vtkm::cont::ArrayHandle::GetBuffers
std::vector< vtkm::cont::internal::Buffer > & GetBuffers()
Definition: ArrayHandle.h:725
vtkm::cont::ArrayHandle::GetNumberOfValues
vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:468
Assert.h
vtkm::cont::ArrayHandle::operator!=
bool operator!=(const ArrayHandle< VT, ST > &) const
Definition: ArrayHandle.h:414
vtkm::cont::ArrayHandle< vtkm::Id >::ValueType
vtkm::Id ValueType
Definition: ArrayHandle.h:307
vtkm::cont::ArrayHandle::ArrayHandle
ArrayHandle(vtkm::cont::ArrayHandle< ValueType, StorageTag > &&src) noexcept
Move constructor.
Definition: ArrayHandle.h:342
vtkm::cont::ArrayHandle< vtkm::Id >::ReadPortalType
typename StorageType::ReadPortalType ReadPortalType
The type of portal used when accessing data in a read-only mode.
Definition: ArrayHandle.h:312
vtkm::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::cont::ArrayHandle::PrepareForInPlace
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:618
vtkm::cont::ArrayHandle::SetBuffers
void SetBuffers(const std::vector< vtkm::cont::internal::Buffer > &buffers)
Definition: ArrayHandle.h:736
vtkm::cont::ArrayHandle::~ArrayHandle
~ArrayHandle()
Destructs an empty ArrayHandle.
Definition: ArrayHandle.h:370
vtkm::Int8
int8_t Int8
Base type to use for 8-bit signed integer numbers.
Definition: Types.h:165
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
VTKM_CONT_EXPORT
#define VTKM_CONT_EXPORT
Definition: vtkm_cont_export.h:44
vtkm::cont::ArrayHandle::PrepareForOutput
WritePortalType PrepareForOutput(vtkm::Id numberOfValues, vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Prepares (allocates) this array to be used as an output from an operation in the execution environmen...
Definition: ArrayHandle.h:638
Buffer.h
vtkm::cont::ArrayHandle::ArrayHandle
ArrayHandle(const vtkm::cont::ArrayHandle< ValueType, StorageTag > &src)
Copy constructor.
Definition: ArrayHandle.h:330
vtkm_cont_export.h
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::cont::ArrayHandle::ReleaseResources
void ReleaseResources() const
Releases all resources in both the control and execution environments.
Definition: ArrayHandle.h:584
vtkm::Id
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
vtkm::cont::ArrayHandle< vtkm::Id >::WritePortalType
typename StorageType::WritePortalType WritePortalType
The type of portal used when accessing data in a read-write mode.
Definition: ArrayHandle.h:314
vtkm::UInt8
uint8_t UInt8
Base type to use for 8-bit unsigned integer numbers.
Definition: Types.h:169
vtkm::CopyFlag::On
@ On
vtkm::cont::ArrayHandle::ReadPortal
ReadPortalType ReadPortal(vtkm::cont::Token &token) const
The type of portal used when accessing data in a read-only mode.
Definition: ArrayHandle.h:439
vtkm::cont::ArrayHandle::DeepCopyFrom
void DeepCopyFrom(const vtkm::cont::ArrayHandle< ValueType, StorageTag > &source) const
Deep copies the data in the array.
Definition: ArrayHandle.h:707
vtkm::cont::ArrayHandle::ReadPortal
ReadPortalType ReadPortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:433
vtkm::cont::ArrayHandle::ArrayHandle
ArrayHandle(std::vector< vtkm::cont::internal::Buffer > &&buffers) noexcept
Special constructor for subclass specializations that need to set the initial state array.
Definition: ArrayHandle.h:358
vtkm::cont::ArrayHandle::IsOnDevice
bool IsOnDevice(vtkm::cont::DeviceAdapterId device) const
Returns true if the ArrayHandle's data is on the given device.
Definition: ArrayHandle.h:649
vtkm::cont::DeviceAdapterId
An object used to specify a device.
Definition: DeviceAdapterTag.h:58
vtkm::VecTraitsTagSingleComponent
A tag for vectors that are really just scalars (i.e.
Definition: VecTraits.h:30
vtkm::CopyFlag::Off
@ Off
vtkm::cont::ArrayHandle::Fill
void Fill(const ValueType &fillValue, vtkm::Id startIndex=0) const
Fills the array with a given value.
Definition: ArrayHandle.h:568
vtkm::cont::DeviceAdapterTagUndefined
Tag for a device adapter used to avoid specifying a device.
Definition: DeviceAdapterTag.h:187
ErrorBadValue.h
vtkm::cont::ArrayHandle< vtkm::Id >::StorageTag
VTKM_DEFAULT_STORAGE_TAG StorageTag
Definition: ArrayHandle.h:308
vtkm::cont::ArrayHandle< vtkm::Id >::StorageType
vtkm::cont::internal::Storage< ValueType, StorageTag > StorageType
Definition: ArrayHandle.h:309
vtkm::cont::StorageTagBasic
A tag for the basic implementation of a Storage object.
Definition: ArrayHandle.h:45
vtkm::cont::ArrayHandle::PrepareForInput
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:599
vtkm::CopyFlag
CopyFlag
Identifier used to specify whether a function should deep copy data.
Definition: Flags.h:17
vtkm::cont::ArrayHandle::Fill
void Fill(const ValueType &fillValue, vtkm::Id startIndex, vtkm::Id endIndex) const
Fills the array with a given value.
Definition: ArrayHandle.h:562
VTKM_NEVER_EXPORT
#define VTKM_NEVER_EXPORT
Definition: ExportMacros.h:90
vtkm::cont::ArrayHandle::WritePortal
WritePortalType WritePortal(vtkm::cont::Token &token) const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:460
vtkm::cont::ArrayHandle::Allocate
void Allocate(vtkm::Id numberOfValues, vtkm::CopyFlag preserve, vtkm::cont::Token &token) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:490
vtkm::VecTraits
Traits that can be queried to treat any type as a Vec.
Definition: VecTraits.h:61
ErrorInternal.h
VTKM_ALWAYS_EXPORT
#define VTKM_ALWAYS_EXPORT
Definition: ExportMacros.h:89
Flags.h
vtkm::cont::ArrayHandle::operator==
bool operator==(const ArrayHandle< VT, ST > &) const
Definition: ArrayHandle.h:408
vtkm::cont::ArrayHandle::GetNumberOfComponentsFlat
vtkm::IdComponent GetNumberOfComponentsFlat() const
Returns the total number of components for each value in the array.
Definition: ArrayHandle.h:474
vtkm::cont::ArrayHandle::WritePortal
WritePortalType WritePortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:454
vtkm::cont::ArrayHandle::ArrayHandle
ArrayHandle(const std::vector< vtkm::cont::internal::Buffer > &buffers)
Special constructor for subclass specializations that need to set the initial state array.
Definition: ArrayHandle.h:350
vtkm::cont::ArrayHandle::IsOnHost
bool IsOnHost() const
Returns true if the ArrayHandle's data is on the host.
Definition: ArrayHandle.h:657
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
vtkm::cont::ArrayHandle::SetBuffers
void SetBuffers(std::vector< vtkm::cont::internal::Buffer > &&buffers)
Definition: ArrayHandle.h:740
vtkm::cont::ArrayHandle::AllocateAndFill
void AllocateAndFill(vtkm::Id numberOfValues, const ValueType &fillValue, vtkm::CopyFlag preserve, vtkm::cont::Token &token) const
Allocates an array and fills it with an initial value.
Definition: ArrayHandle.h:519
StorageError.h
vtkm::cont::ArrayHandle::ArrayHandle
ArrayHandle()
Constructs an empty ArrayHandle.
Definition: ArrayHandle.h:318
vtkm::cont::ArrayHandle::Allocate
void Allocate(vtkm::Id numberOfValues, vtkm::CopyFlag preserve=vtkm::CopyFlag::Off) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:498
vtkm::cont::ArrayHandle::operator=
vtkm::cont::ArrayHandle< ValueType, StorageTag > & operator=(vtkm::cont::ArrayHandle< ValueType, StorageTag > &&src) noexcept
Move and Assignment of an ArrayHandle.
Definition: ArrayHandle.h:385