VTK-m  2.1
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 
311  using ReadPortalType = typename StorageType::ReadPortalType;
312  using WritePortalType = typename StorageType::WritePortalType;
313 
317  : Buffers(StorageType::CreateBuffers())
318  {
319  }
320 
329  : Buffers(src.Buffers)
330  {
331  }
332 
341  : Buffers(std::move(src.Buffers))
342  {
343  }
344 
348  VTKM_CONT explicit ArrayHandle(const std::vector<vtkm::cont::internal::Buffer>& buffers)
349  : Buffers(buffers)
350  {
351  }
352 
356  VTKM_CONT explicit ArrayHandle(std::vector<vtkm::cont::internal::Buffer>&& buffers) noexcept
357  : Buffers(std::move(buffers))
358  {
359  }
360 
369 
372  VTKM_CONT
375  {
376  this->Buffers = src.Buffers;
377  return *this;
378  }
379 
382  VTKM_CONT
385  {
386  this->Buffers = std::move(src.Buffers);
387  return *this;
388  }
389 
393  VTKM_CONT
395  {
396  return this->Buffers == rhs.Buffers;
397  }
398 
399  VTKM_CONT
401  {
402  return this->Buffers != rhs.Buffers;
403  }
404 
405  template <typename VT, typename ST>
407  {
408  return false; // different valuetype and/or storage
409  }
410 
411  template <typename VT, typename ST>
413  {
414  return true; // different valuetype and/or storage
415  }
416 
420 
432  {
433  vtkm::cont::Token token;
434  return this->ReadPortal(token);
435  }
438  {
439  return StorageType::CreateReadPortal(
440  this->GetBuffers(), vtkm::cont::DeviceAdapterTagUndefined{}, token);
441  }
442 
453  {
454  vtkm::cont::Token token;
455  return this->WritePortal(token);
456  }
459  {
460  return StorageType::CreateWritePortal(
461  this->GetBuffers(), vtkm::cont::DeviceAdapterTagUndefined{}, token);
462  }
463 
467  {
468  return StorageType::GetNumberOfValues(this->GetBuffers());
469  }
470 
473  {
474  return StorageType::GetNumberOfComponentsFlat(this->GetBuffers());
475  }
476 
488  VTKM_CONT void Allocate(vtkm::Id numberOfValues,
489  vtkm::CopyFlag preserve,
490  vtkm::cont::Token& token) const
491  {
492  StorageType::ResizeBuffers(numberOfValues, this->GetBuffers(), preserve, token);
493  }
494 
496  VTKM_CONT void Allocate(vtkm::Id numberOfValues,
497  vtkm::CopyFlag preserve = vtkm::CopyFlag::Off) const
498  {
499  vtkm::cont::Token token;
500  this->Allocate(numberOfValues, preserve, token);
501  }
502 
517  VTKM_CONT void AllocateAndFill(vtkm::Id numberOfValues,
518  const ValueType& fillValue,
519  vtkm::CopyFlag preserve,
520  vtkm::cont::Token& token) const
521  {
522  // Note that there is a slight potential for a race condition here. It is possible for someone
523  // else to resize the array in between getting the startIndex and locking the array in the
524  // Allocate call. If there really are 2 threads trying to allocate this array at the same time,
525  // you probably have bigger problems than filling at the wrong index.
526  vtkm::Id startIndex = (preserve == vtkm::CopyFlag::On) ? this->GetNumberOfValues() : 0;
527 
528  this->Allocate(numberOfValues, preserve, token);
529 
530  if (startIndex < numberOfValues)
531  {
532  this->Fill(fillValue, startIndex, numberOfValues, token);
533  }
534  }
535 
537  VTKM_CONT void AllocateAndFill(vtkm::Id numberOfValues,
538  const ValueType& fillValue,
539  vtkm::CopyFlag preserve = vtkm::CopyFlag::Off) const
540  {
541  vtkm::cont::Token token;
542  this->AllocateAndFill(numberOfValues, fillValue, preserve, token);
543  }
544 
552  VTKM_CONT void Fill(const ValueType& fillValue,
553  vtkm::Id startIndex,
554  vtkm::Id endIndex,
555  vtkm::cont::Token& token) const
556  {
557  StorageType::Fill(this->GetBuffers(), fillValue, startIndex, endIndex, token);
558  }
560  VTKM_CONT void Fill(const ValueType& fillValue, vtkm::Id startIndex, vtkm::Id endIndex) const
561  {
562  vtkm::cont::Token token;
563  this->Fill(fillValue, startIndex, endIndex, token);
564  }
566  VTKM_CONT void Fill(const ValueType& fillValue, vtkm::Id startIndex = 0) const
567  {
568  vtkm::cont::Token token;
569  this->Fill(fillValue, startIndex, this->GetNumberOfValues(), token);
570  }
571 
576  {
577  detail::ArrayHandleReleaseResourcesExecution(this->Buffers);
578  }
579 
582  VTKM_CONT void ReleaseResources() const { this->Allocate(0); }
583 
598  vtkm::cont::Token& token) const
599  {
600  return StorageType::CreateReadPortal(this->GetBuffers(), device, token);
601  }
602 
617  vtkm::cont::Token& token) const
618  {
619  return StorageType::CreateWritePortal(this->GetBuffers(), device, token);
620  }
621 
638  vtkm::cont::Token& token) const
639  {
640  this->Allocate(numberOfValues, vtkm::CopyFlag::Off, token);
641  return StorageType::CreateWritePortal(this->GetBuffers(), device, token);
642  }
643 
648  {
649  return detail::ArrayHandleIsOnDevice(this->Buffers, device);
650  }
651 
655  VTKM_CONT bool IsOnHost() const
656  {
657  return this->IsOnDevice(vtkm::cont::DeviceAdapterTagUndefined{});
658  }
659 
667  {
668  // Creating a host read portal will force the data to be synced to the host.
669  this->ReadPortal();
670  }
671 
693  VTKM_CONT void Enqueue(const vtkm::cont::Token& token) const
694  {
695  for (auto&& buffer : this->Buffers)
696  {
697  buffer.Enqueue(token);
698  }
699  }
700 
706  {
707  VTKM_ASSERT(this->Buffers.size() == source.Buffers.size());
708 
709  for (std::size_t bufferIndex = 0; bufferIndex < this->Buffers.size(); ++bufferIndex)
710  {
711  this->Buffers[bufferIndex].DeepCopyFrom(source.Buffers[bufferIndex]);
712  }
713  }
714 
719  VTKM_CONT const std::vector<vtkm::cont::internal::Buffer>& GetBuffers() const
720  {
721  return this->Buffers;
722  }
723  VTKM_CONT std::vector<vtkm::cont::internal::Buffer>& GetBuffers() { return this->Buffers; }
724 
725 private:
726  mutable std::vector<vtkm::cont::internal::Buffer> Buffers;
727 
728 protected:
729  VTKM_CONT void SetBuffer(vtkm::IdComponent index, const vtkm::cont::internal::Buffer& buffer)
730  {
731  this->Buffers[static_cast<std::size_t>(index)] = buffer;
732  }
733 
734  VTKM_CONT void SetBuffers(const std::vector<vtkm::cont::internal::Buffer>& buffers)
735  {
736  this->Buffers = buffers;
737  }
738  VTKM_CONT void SetBuffers(std::vector<vtkm::cont::internal::Buffer>&& buffers)
739  {
740  this->Buffers = std::move(buffers);
741  }
742 };
743 
744 namespace detail
745 {
746 
747 template <typename T>
748 VTKM_NEVER_EXPORT VTKM_CONT inline void
749 printSummary_ArrayHandle_Value(const T& value, std::ostream& out, vtkm::VecTraitsTagSingleComponent)
750 {
751  out << value;
752 }
753 
755 VTKM_CONT
756 inline void printSummary_ArrayHandle_Value(vtkm::UInt8 value,
757  std::ostream& out,
759 {
760  out << static_cast<int>(value);
761 }
762 
764 VTKM_CONT
765 inline void printSummary_ArrayHandle_Value(vtkm::Int8 value,
766  std::ostream& out,
768 {
769  out << static_cast<int>(value);
770 }
771 
772 template <typename T>
773 VTKM_NEVER_EXPORT VTKM_CONT inline void printSummary_ArrayHandle_Value(
774  const T& value,
775  std::ostream& out,
777 {
778  using Traits = vtkm::VecTraits<T>;
779  using ComponentType = typename Traits::ComponentType;
780  using IsVecOfVec = typename vtkm::VecTraits<ComponentType>::HasMultipleComponents;
781  vtkm::IdComponent numComponents = Traits::GetNumberOfComponents(value);
782  out << "(";
783  printSummary_ArrayHandle_Value(Traits::GetComponent(value, 0), out, IsVecOfVec());
784  for (vtkm::IdComponent index = 1; index < numComponents; ++index)
785  {
786  out << ",";
787  printSummary_ArrayHandle_Value(Traits::GetComponent(value, index), out, IsVecOfVec());
788  }
789  out << ")";
790 }
791 
792 template <typename T1, typename T2>
793 VTKM_NEVER_EXPORT VTKM_CONT inline void printSummary_ArrayHandle_Value(
794  const vtkm::Pair<T1, T2>& value,
795  std::ostream& out,
797 {
798  out << "{";
799  printSummary_ArrayHandle_Value(
800  value.first, out, typename vtkm::VecTraits<T1>::HasMultipleComponents());
801  out << ",";
802  printSummary_ArrayHandle_Value(
803  value.second, out, typename vtkm::VecTraits<T2>::HasMultipleComponents());
804  out << "}";
805 }
806 
807 
808 
809 } // namespace detail
810 
811 template <typename T, typename StorageT>
814  std::ostream& out,
815  bool full = false)
816 {
817  using ArrayType = vtkm::cont::ArrayHandle<T, StorageT>;
818  using PortalType = typename ArrayType::ReadPortalType;
819  using IsVec = typename vtkm::VecTraits<T>::HasMultipleComponents;
820 
821  vtkm::Id sz = array.GetNumberOfValues();
822 
823  out << "valueType=" << vtkm::cont::TypeToString<T>()
824  << " storageType=" << vtkm::cont::TypeToString<StorageT>() << " " << sz
825  << " values occupying " << (static_cast<size_t>(sz) * sizeof(T)) << " bytes [";
826 
827  PortalType portal = array.ReadPortal();
828  if (full || sz <= 7)
829  {
830  for (vtkm::Id i = 0; i < sz; i++)
831  {
832  detail::printSummary_ArrayHandle_Value(portal.Get(i), out, IsVec());
833  if (i != (sz - 1))
834  {
835  out << " ";
836  }
837  }
838  }
839  else
840  {
841  detail::printSummary_ArrayHandle_Value(portal.Get(0), out, IsVec());
842  out << " ";
843  detail::printSummary_ArrayHandle_Value(portal.Get(1), out, IsVec());
844  out << " ";
845  detail::printSummary_ArrayHandle_Value(portal.Get(2), out, IsVec());
846  out << " ... ";
847  detail::printSummary_ArrayHandle_Value(portal.Get(sz - 3), out, IsVec());
848  out << " ";
849  detail::printSummary_ArrayHandle_Value(portal.Get(sz - 2), out, IsVec());
850  out << " ";
851  detail::printSummary_ArrayHandle_Value(portal.Get(sz - 1), out, IsVec());
852  }
853  out << "]\n";
854 }
855 
856 namespace internal
857 {
858 
859 namespace detail
860 {
861 
862 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>&);
863 template <typename T, typename S, typename... Args>
864 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
865  const vtkm::cont::ArrayHandle<T, S>& array,
866  const Args&... args);
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 template <typename... Args>
873 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
874  const std::vector<vtkm::cont::internal::Buffer>& addbuffs,
875  const Args&... args);
876 template <typename Arg0, typename... Args>
877 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
878  const Arg0& arg0,
879  const Args&... args);
880 
881 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>&)
882 {
883  // Nothing left to add.
884 }
885 
886 template <typename T, typename S, typename... Args>
887 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
888  const vtkm::cont::ArrayHandle<T, S>& array,
889  const Args&... args)
890 {
891  CreateBuffersImpl(buffers, array.GetBuffers(), args...);
892 }
893 
894 template <typename... Args>
895 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
896  const vtkm::cont::internal::Buffer& buffer,
897  const Args&... args)
898 {
899  buffers.push_back(buffer);
900  CreateBuffersImpl(buffers, args...);
901 }
902 
903 template <typename... Args>
904 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
905  const std::vector<vtkm::cont::internal::Buffer>& addbuffs,
906  const Args&... args)
907 {
908  buffers.insert(buffers.end(), addbuffs.begin(), addbuffs.end());
909  CreateBuffersImpl(buffers, args...);
910 }
911 
912 template <typename T, typename S, typename... Args>
913 VTKM_CONT inline void CreateBuffersResolveArrays(std::vector<vtkm::cont::internal::Buffer>& buffers,
914  std::true_type,
915  const vtkm::cont::ArrayHandle<T, S>& array,
916  const Args&... args)
917 {
918  CreateBuffersImpl(buffers, array, args...);
919 }
920 
921 template <typename MetaData, typename... Args>
922 VTKM_CONT inline void CreateBuffersResolveArrays(std::vector<vtkm::cont::internal::Buffer>& buffers,
923  std::false_type,
924  const MetaData& metadata,
925  const Args&... args)
926 {
927  vtkm::cont::internal::Buffer buffer;
928  buffer.SetMetaData(metadata);
929  buffers.push_back(std::move(buffer));
930  CreateBuffersImpl(buffers, args...);
931 }
932 
933 template <typename Arg0, typename... Args>
934 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
935  const Arg0& arg0,
936  const Args&... args)
937 {
938  // If the argument is a subclass of ArrayHandle, the template resolution will pick this
939  // overload instead of the correct ArrayHandle overload. To resolve that, check to see
940  // if the type is an `ArrayHandle` and use `CreateBuffersResolveArrays` to choose the
941  // right path.
942  using IsArray = typename vtkm::cont::internal::ArrayHandleCheck<Arg0>::type::type;
943  CreateBuffersResolveArrays(buffers, IsArray{}, arg0, args...);
944 }
945 
946 } // namespace detail
947 
962 template <typename... Args>
963 VTKM_CONT inline std::vector<vtkm::cont::internal::Buffer> CreateBuffers(const Args&... args)
964 {
965  std::vector<vtkm::cont::internal::Buffer> buffers;
966  buffers.reserve(sizeof...(args));
967  detail::CreateBuffersImpl(buffers, args...);
968  return buffers;
969 }
970 
971 } // namespace internal
972 
973 }
974 } //namespace vtkm::cont
975 
976 #ifndef vtk_m_cont_ArrayHandleBasic_h
978 #endif
979 
980 #endif //vtk_m_cont_ArrayHandle_h
vtkm::cont::ArrayHandle::SyncControlArray
void SyncControlArray() const
Synchronizes the control array with the execution array.
Definition: ArrayHandle.h:666
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:537
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:726
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:394
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:719
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:419
vtkm::cont::ArrayHandle::Enqueue
void Enqueue(const vtkm::cont::Token &token) const
Enqueue a token for access to this ArrayHandle.
Definition: ArrayHandle.h:693
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:812
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:552
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:575
vtkm::cont::ArrayHandle::operator!=
bool operator!=(const ArrayHandle< ValueType, StorageTag > &rhs) const
Definition: ArrayHandle.h:400
vtkm::cont::ArrayHandle::operator=
vtkm::cont::ArrayHandle< ValueType, StorageTag > & operator=(const vtkm::cont::ArrayHandle< ValueType, StorageTag > &src)
Shallow copies an ArrayHandle.
Definition: ArrayHandle.h:373
ArrayHandleBasic.h
DeviceAdapterList.h
vtkm::cont::ArrayHandle::SetBuffer
void SetBuffer(vtkm::IdComponent index, const vtkm::cont::internal::Buffer &buffer)
Definition: ArrayHandle.h:729
Storage.h
vtkm::cont::ArrayHandle::GetBuffers
std::vector< vtkm::cont::internal::Buffer > & GetBuffers()
Definition: ArrayHandle.h:723
vtkm::cont::ArrayHandle::GetNumberOfValues
vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:466
Assert.h
vtkm::cont::ArrayHandle::operator!=
bool operator!=(const ArrayHandle< VT, ST > &) const
Definition: ArrayHandle.h:412
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:340
vtkm::cont::ArrayHandle< vtkm::Id >::ReadPortalType
typename StorageType::ReadPortalType ReadPortalType
Definition: ArrayHandle.h:311
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:616
vtkm::cont::ArrayHandle::SetBuffers
void SetBuffers(const std::vector< vtkm::cont::internal::Buffer > &buffers)
Definition: ArrayHandle.h:734
vtkm::cont::ArrayHandle::~ArrayHandle
~ArrayHandle()
Destructs an empty ArrayHandle.
Definition: ArrayHandle.h:368
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:636
Buffer.h
vtkm::cont::ArrayHandle::ArrayHandle
ArrayHandle(const vtkm::cont::ArrayHandle< ValueType, StorageTag > &src)
Copy constructor.
Definition: ArrayHandle.h:328
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:582
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
Definition: ArrayHandle.h:312
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
Definition: ArrayHandle.h:437
vtkm::cont::ArrayHandle::DeepCopyFrom
void DeepCopyFrom(const vtkm::cont::ArrayHandle< ValueType, StorageTag > &source) const
Deep copies the data in the array.
Definition: ArrayHandle.h:705
vtkm::cont::ArrayHandle::ReadPortal
ReadPortalType ReadPortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:431
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:356
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:647
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:566
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:597
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:560
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:458
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:488
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:406
vtkm::cont::ArrayHandle::GetNumberOfComponentsFlat
vtkm::IdComponent GetNumberOfComponentsFlat() const
Returns the total number of components for each value in the array.
Definition: ArrayHandle.h:472
vtkm::cont::ArrayHandle::WritePortal
WritePortalType WritePortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:452
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:348
vtkm::cont::ArrayHandle::IsOnHost
bool IsOnHost() const
Returns true if the ArrayHandle's data is on the host.
Definition: ArrayHandle.h:655
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:738
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:517
StorageError.h
vtkm::cont::ArrayHandle::ArrayHandle
ArrayHandle()
Constructs an empty ArrayHandle.
Definition: ArrayHandle.h:316
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:496
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:383