VTK-m  2.0
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/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 
132 #define VTKM_IS_ARRAY_HANDLE(T) VTKM_STATIC_ASSERT(::vtkm::cont::internal::ArrayHandleCheck<T>{})
133 
134 } // namespace internal
135 
136 namespace detail
137 {
138 
139 template <typename T>
140 struct GetTypeInParentheses;
141 template <typename T>
142 struct GetTypeInParentheses<void(T)>
143 {
144  using type = T;
145 };
146 
147 } // namespace detail
148 
149 // Implementation for VTKM_ARRAY_HANDLE_SUBCLASS macros
150 #define VTK_M_ARRAY_HANDLE_SUBCLASS_IMPL(classname, fullclasstype, superclass, typename__) \
151  using Thisclass = typename__ vtkm::cont::detail::GetTypeInParentheses<void fullclasstype>::type; \
152  using Superclass = typename__ vtkm::cont::detail::GetTypeInParentheses<void superclass>::type; \
153  \
154  VTKM_IS_ARRAY_HANDLE(Superclass); \
155  \
156  VTKM_CONT \
157  classname() \
158  : Superclass() \
159  { \
160  } \
161  \
162  VTKM_CONT \
163  classname(const Thisclass& src) \
164  : Superclass(src) \
165  { \
166  } \
167  \
168  VTKM_CONT \
169  classname(Thisclass&& src) noexcept \
170  : Superclass(std::move(src)) \
171  { \
172  } \
173  \
174  VTKM_CONT \
175  classname(const vtkm::cont::ArrayHandle<typename__ Superclass::ValueType, \
176  typename__ Superclass::StorageTag>& src) \
177  : Superclass(src) \
178  { \
179  } \
180  \
181  VTKM_CONT \
182  classname(vtkm::cont::ArrayHandle<typename__ Superclass::ValueType, \
183  typename__ Superclass::StorageTag>&& src) noexcept \
184  : Superclass(std::move(src)) \
185  { \
186  } \
187  \
188  VTKM_CONT \
189  Thisclass& operator=(const Thisclass& src) \
190  { \
191  this->Superclass::operator=(src); \
192  return *this; \
193  } \
194  \
195  VTKM_CONT \
196  Thisclass& operator=(Thisclass&& src) noexcept \
197  { \
198  this->Superclass::operator=(std::move(src)); \
199  return *this; \
200  } \
201  \
202  using ValueType = typename__ Superclass::ValueType; \
203  using StorageTag = typename__ Superclass::StorageTag
204 
226 #define VTKM_ARRAY_HANDLE_SUBCLASS(classname, fullclasstype, superclass) \
227  VTK_M_ARRAY_HANDLE_SUBCLASS_IMPL(classname, fullclasstype, superclass, typename)
228 
249 #define VTKM_ARRAY_HANDLE_SUBCLASS_NT(classname, superclass) \
250  VTK_M_ARRAY_HANDLE_SUBCLASS_IMPL(classname, (classname), superclass, )
251 
252 namespace detail
253 {
254 
255 VTKM_CONT_EXPORT VTKM_CONT void ArrayHandleReleaseResourcesExecution(
256  const std::vector<vtkm::cont::internal::Buffer>& buffers);
257 
258 VTKM_CONT_EXPORT VTKM_CONT bool ArrayHandleIsOnDevice(
259  const std::vector<vtkm::cont::internal::Buffer>& buffers,
261 
262 } // namespace detail
263 
282 template <typename T, typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
283 class VTKM_ALWAYS_EXPORT ArrayHandle : public internal::ArrayHandleBase
284 {
286  (internal::IsValidArrayHandle<T, StorageTag_>::value),
287  "Attempted to create an ArrayHandle with an invalid type/storage combination.");
288 
289 public:
290  using ValueType = T;
291  using StorageTag = StorageTag_;
292  using StorageType = vtkm::cont::internal::Storage<ValueType, StorageTag>;
293 
294  using ReadPortalType = typename StorageType::ReadPortalType;
295  using WritePortalType = typename StorageType::WritePortalType;
296 
300  : Buffers(StorageType::CreateBuffers())
301  {
302  }
303 
312  : Buffers(src.Buffers)
313  {
314  }
315 
324  : Buffers(std::move(src.Buffers))
325  {
326  }
327 
332  VTKM_CONT ArrayHandle(const std::vector<vtkm::cont::internal::Buffer>& buffers)
333  : Buffers(buffers)
334  {
335  }
336 
337  VTKM_CONT ArrayHandle(std::vector<vtkm::cont::internal::Buffer>&& buffers) noexcept
338  : Buffers(std::move(buffers))
339  {
340  }
342 
351 
354  VTKM_CONT
357  {
358  this->Buffers = src.Buffers;
359  return *this;
360  }
361 
364  VTKM_CONT
367  {
368  this->Buffers = std::move(src.Buffers);
369  return *this;
370  }
371 
375  VTKM_CONT
377  {
378  return this->Buffers == rhs.Buffers;
379  }
380 
381  VTKM_CONT
383  {
384  return this->Buffers != rhs.Buffers;
385  }
386 
387  template <typename VT, typename ST>
389  {
390  return false; // different valuetype and/or storage
391  }
392 
393  template <typename VT, typename ST>
395  {
396  return true; // different valuetype and/or storage
397  }
398 
402 
415  {
416  vtkm::cont::Token token;
417  return this->ReadPortal(token);
418  }
420  {
421  return StorageType::CreateReadPortal(
422  this->GetBuffers(), vtkm::cont::DeviceAdapterTagUndefined{}, token);
423  }
425 
436  {
437  vtkm::cont::Token token;
438  return this->WritePortal(token);
439  }
441  {
442  return StorageType::CreateWritePortal(
443  this->GetBuffers(), vtkm::cont::DeviceAdapterTagUndefined{}, token);
444  }
445 
449  {
450  return StorageType::GetNumberOfValues(this->GetBuffers());
451  }
452 
465  VTKM_CONT void Allocate(vtkm::Id numberOfValues,
466  vtkm::CopyFlag preserve,
467  vtkm::cont::Token& token) const
468  {
469  StorageType::ResizeBuffers(numberOfValues, this->GetBuffers(), preserve, token);
470  }
471 
472  VTKM_CONT void Allocate(vtkm::Id numberOfValues,
473  vtkm::CopyFlag preserve = vtkm::CopyFlag::Off) const
474  {
475  vtkm::cont::Token token;
476  this->Allocate(numberOfValues, preserve, token);
477  }
479 
495  VTKM_CONT void AllocateAndFill(vtkm::Id numberOfValues,
496  const ValueType& fillValue,
497  vtkm::CopyFlag preserve,
498  vtkm::cont::Token& token) const
499  {
500  // Note that there is a slight potential for a race condition here. It is possible for someone
501  // else to resize the array in between getting the startIndex and locking the array in the
502  // Allocate call. If there really are 2 threads trying to allocate this array at the same time,
503  // you probably have bigger problems than filling at the wrong index.
504  vtkm::Id startIndex = (preserve == vtkm::CopyFlag::On) ? this->GetNumberOfValues() : 0;
505 
506  this->Allocate(numberOfValues, preserve, token);
507 
508  if (startIndex < numberOfValues)
509  {
510  this->Fill(fillValue, startIndex, numberOfValues, token);
511  }
512  }
513 
514  VTKM_CONT void AllocateAndFill(vtkm::Id numberOfValues,
515  const ValueType& fillValue,
516  vtkm::CopyFlag preserve = vtkm::CopyFlag::Off) const
517  {
518  vtkm::cont::Token token;
519  this->AllocateAndFill(numberOfValues, fillValue, preserve, token);
520  }
522 
530  VTKM_CONT void Fill(const ValueType& fillValue,
531  vtkm::Id startIndex,
532  vtkm::Id endIndex,
533  vtkm::cont::Token& token) const
534  {
535  StorageType::Fill(this->GetBuffers(), fillValue, startIndex, endIndex, token);
536  }
537  VTKM_CONT void Fill(const ValueType& fillValue, vtkm::Id startIndex, vtkm::Id endIndex) const
538  {
539  vtkm::cont::Token token;
540  this->Fill(fillValue, startIndex, endIndex, token);
541  }
542  VTKM_CONT void Fill(const ValueType& fillValue, vtkm::Id startIndex = 0) const
543  {
544  vtkm::cont::Token token;
545  this->Fill(fillValue, startIndex, this->GetNumberOfValues(), token);
546  }
548 
553  {
554  detail::ArrayHandleReleaseResourcesExecution(this->Buffers);
555  }
556 
559  VTKM_CONT void ReleaseResources() const { this->Allocate(0); }
560 
575  vtkm::cont::Token& token) const
576  {
577  return StorageType::CreateReadPortal(this->GetBuffers(), device, token);
578  }
579 
594  vtkm::cont::Token& token) const
595  {
596  return StorageType::CreateWritePortal(this->GetBuffers(), device, token);
597  }
598 
615  vtkm::cont::Token& token) const
616  {
617  this->Allocate(numberOfValues, vtkm::CopyFlag::Off, token);
618  return StorageType::CreateWritePortal(this->GetBuffers(), device, token);
619  }
620 
625  {
626  return detail::ArrayHandleIsOnDevice(this->Buffers, device);
627  }
628 
632  VTKM_CONT bool IsOnHost() const
633  {
634  return this->IsOnDevice(vtkm::cont::DeviceAdapterTagUndefined{});
635  }
636 
644  {
645  // Creating a host read portal will force the data to be synced to the host.
646  this->ReadPortal();
647  }
648 
670  VTKM_CONT void Enqueue(const vtkm::cont::Token& token) const
671  {
672  for (auto&& buffer : this->Buffers)
673  {
674  buffer.Enqueue(token);
675  }
676  }
677 
683  {
684  VTKM_ASSERT(this->Buffers.size() == source.Buffers.size());
685 
686  for (std::size_t bufferIndex = 0; bufferIndex < this->Buffers.size(); ++bufferIndex)
687  {
688  this->Buffers[bufferIndex].DeepCopyFrom(source.Buffers[bufferIndex]);
689  }
690  }
691 
696  VTKM_CONT const std::vector<vtkm::cont::internal::Buffer>& GetBuffers() const
697  {
698  return this->Buffers;
699  }
700  VTKM_CONT std::vector<vtkm::cont::internal::Buffer>& GetBuffers() { return this->Buffers; }
701 
702 private:
703  mutable std::vector<vtkm::cont::internal::Buffer> Buffers;
704 
705 protected:
706  VTKM_CONT void SetBuffer(vtkm::IdComponent index, const vtkm::cont::internal::Buffer& buffer)
707  {
708  this->Buffers[static_cast<std::size_t>(index)] = buffer;
709  }
710 
711  VTKM_CONT void SetBuffers(const std::vector<vtkm::cont::internal::Buffer>& buffers)
712  {
713  this->Buffers = buffers;
714  }
715  VTKM_CONT void SetBuffers(std::vector<vtkm::cont::internal::Buffer>&& buffers)
716  {
717  this->Buffers = std::move(buffers);
718  }
719 };
720 
721 namespace detail
722 {
723 
724 template <typename T>
725 VTKM_NEVER_EXPORT VTKM_CONT inline void
726 printSummary_ArrayHandle_Value(const T& value, std::ostream& out, vtkm::VecTraitsTagSingleComponent)
727 {
728  out << value;
729 }
730 
732 VTKM_CONT
733 inline void printSummary_ArrayHandle_Value(vtkm::UInt8 value,
734  std::ostream& out,
736 {
737  out << static_cast<int>(value);
738 }
739 
741 VTKM_CONT
742 inline void printSummary_ArrayHandle_Value(vtkm::Int8 value,
743  std::ostream& out,
745 {
746  out << static_cast<int>(value);
747 }
748 
749 template <typename T>
750 VTKM_NEVER_EXPORT VTKM_CONT inline void printSummary_ArrayHandle_Value(
751  const T& value,
752  std::ostream& out,
754 {
755  using Traits = vtkm::internal::SafeVecTraits<T>;
756  using ComponentType = typename Traits::ComponentType;
757  using IsVecOfVec = typename vtkm::internal::SafeVecTraits<ComponentType>::HasMultipleComponents;
758  vtkm::IdComponent numComponents = Traits::GetNumberOfComponents(value);
759  out << "(";
760  printSummary_ArrayHandle_Value(Traits::GetComponent(value, 0), out, IsVecOfVec());
761  for (vtkm::IdComponent index = 1; index < numComponents; ++index)
762  {
763  out << ",";
764  printSummary_ArrayHandle_Value(Traits::GetComponent(value, index), out, IsVecOfVec());
765  }
766  out << ")";
767 }
768 
769 template <typename T1, typename T2>
770 VTKM_NEVER_EXPORT VTKM_CONT inline void printSummary_ArrayHandle_Value(
771  const vtkm::Pair<T1, T2>& value,
772  std::ostream& out,
774 {
775  out << "{";
776  printSummary_ArrayHandle_Value(
777  value.first, out, typename vtkm::internal::SafeVecTraits<T1>::HasMultipleComponents());
778  out << ",";
779  printSummary_ArrayHandle_Value(
780  value.second, out, typename vtkm::internal::SafeVecTraits<T2>::HasMultipleComponents());
781  out << "}";
782 }
783 
784 
785 
786 } // namespace detail
787 
788 template <typename T, typename StorageT>
791  std::ostream& out,
792  bool full = false)
793 {
794  using ArrayType = vtkm::cont::ArrayHandle<T, StorageT>;
795  using PortalType = typename ArrayType::ReadPortalType;
796  using IsVec = typename vtkm::internal::SafeVecTraits<T>::HasMultipleComponents;
797 
798  vtkm::Id sz = array.GetNumberOfValues();
799 
800  out << "valueType=" << vtkm::cont::TypeToString<T>()
801  << " storageType=" << vtkm::cont::TypeToString<StorageT>() << " " << sz
802  << " values occupying " << (static_cast<size_t>(sz) * sizeof(T)) << " bytes [";
803 
804  PortalType portal = array.ReadPortal();
805  if (full || sz <= 7)
806  {
807  for (vtkm::Id i = 0; i < sz; i++)
808  {
809  detail::printSummary_ArrayHandle_Value(portal.Get(i), out, IsVec());
810  if (i != (sz - 1))
811  {
812  out << " ";
813  }
814  }
815  }
816  else
817  {
818  detail::printSummary_ArrayHandle_Value(portal.Get(0), out, IsVec());
819  out << " ";
820  detail::printSummary_ArrayHandle_Value(portal.Get(1), out, IsVec());
821  out << " ";
822  detail::printSummary_ArrayHandle_Value(portal.Get(2), out, IsVec());
823  out << " ... ";
824  detail::printSummary_ArrayHandle_Value(portal.Get(sz - 3), out, IsVec());
825  out << " ";
826  detail::printSummary_ArrayHandle_Value(portal.Get(sz - 2), out, IsVec());
827  out << " ";
828  detail::printSummary_ArrayHandle_Value(portal.Get(sz - 1), out, IsVec());
829  }
830  out << "]\n";
831 }
832 
833 namespace internal
834 {
835 
836 namespace detail
837 {
838 
839 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>&);
840 template <typename T, typename S, typename... Args>
841 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
842  const vtkm::cont::ArrayHandle<T, S>& array,
843  const Args&... args);
844 template <typename... Args>
845 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
846  const vtkm::cont::internal::Buffer& buffer,
847  const Args&... args);
848 
849 template <typename... Args>
850 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
851  const std::vector<vtkm::cont::internal::Buffer>& addbuffs,
852  const Args&... args);
853 template <typename Arg0, typename... Args>
854 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
855  const Arg0& arg0,
856  const Args&... args);
857 
858 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>&)
859 {
860  // Nothing left to add.
861 }
862 
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 {
868  CreateBuffersImpl(buffers, array.GetBuffers(), args...);
869 }
870 
871 template <typename... Args>
872 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
873  const vtkm::cont::internal::Buffer& buffer,
874  const Args&... args)
875 {
876  buffers.push_back(buffer);
877  CreateBuffersImpl(buffers, args...);
878 }
879 
880 template <typename... Args>
881 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
882  const std::vector<vtkm::cont::internal::Buffer>& addbuffs,
883  const Args&... args)
884 {
885  buffers.insert(buffers.end(), addbuffs.begin(), addbuffs.end());
886  CreateBuffersImpl(buffers, args...);
887 }
888 
889 template <typename T, typename S, typename... Args>
890 VTKM_CONT inline void CreateBuffersResolveArrays(std::vector<vtkm::cont::internal::Buffer>& buffers,
891  std::true_type,
892  const vtkm::cont::ArrayHandle<T, S>& array,
893  const Args&... args)
894 {
895  CreateBuffersImpl(buffers, array, args...);
896 }
897 
898 template <typename MetaData, typename... Args>
899 VTKM_CONT inline void CreateBuffersResolveArrays(std::vector<vtkm::cont::internal::Buffer>& buffers,
900  std::false_type,
901  const MetaData& metadata,
902  const Args&... args)
903 {
904  vtkm::cont::internal::Buffer buffer;
905  buffer.SetMetaData(metadata);
906  buffers.push_back(std::move(buffer));
907  CreateBuffersImpl(buffers, args...);
908 }
909 
910 template <typename Arg0, typename... Args>
911 VTKM_CONT inline void CreateBuffersImpl(std::vector<vtkm::cont::internal::Buffer>& buffers,
912  const Arg0& arg0,
913  const Args&... args)
914 {
915  // If the argument is a subclass of ArrayHandle, the template resolution will pick this
916  // overload instead of the correct ArrayHandle overload. To resolve that, check to see
917  // if the type is an `ArrayHandle` and use `CreateBuffersResolveArrays` to choose the
918  // right path.
919  using IsArray = typename vtkm::cont::internal::ArrayHandleCheck<Arg0>::type::type;
920  CreateBuffersResolveArrays(buffers, IsArray{}, arg0, args...);
921 }
922 
923 } // namespace detail
924 
939 template <typename... Args>
940 VTKM_CONT inline std::vector<vtkm::cont::internal::Buffer> CreateBuffers(const Args&... args)
941 {
942  std::vector<vtkm::cont::internal::Buffer> buffers;
943  buffers.reserve(sizeof...(args));
944  detail::CreateBuffersImpl(buffers, args...);
945  return buffers;
946 }
947 
948 } // namespace internal
949 
950 }
951 } //namespace vtkm::cont
952 
953 #ifndef vtk_m_cont_ArrayHandleBasic_h
955 #endif
956 
957 #endif //vtk_m_cont_ArrayHandle_h
vtkm::cont::ArrayHandle::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::GetNumberOfValues
VTKM_CONT vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:448
vtkm::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:283
vtkm::cont::ArrayHandle::Buffers
std::vector< vtkm::cont::internal::Buffer > Buffers
Definition: ArrayHandle.h:703
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:365
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
Types.h
vtkm::cont::ArrayHandle::ArrayHandle
VTKM_CONT ArrayHandle(const std::vector< vtkm::cont::internal::Buffer > &buffers)
Definition: ArrayHandle.h:332
ArrayPortalHelpers.h
VTKM_ASSERT
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
vtkm::cont::ArrayHandle::Enqueue
VTKM_CONT void Enqueue(const vtkm::cont::Token &token) const
Enqueue a token for access to this ArrayHandle.
Definition: ArrayHandle.h:670
vtkm::cont::ArrayHandle::Allocate
VTKM_CONT 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:465
vtkm::cont::ArrayHandle::AllocateAndFill
VTKM_CONT 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:495
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:574
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:789
vtkm::cont::ArrayHandle::SetBuffers
VTKM_CONT void SetBuffers(std::vector< vtkm::cont::internal::Buffer > &&buffers)
Definition: ArrayHandle.h:715
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:355
ArrayHandleBasic.h
vtkm::cont::ArrayHandle::operator!=
VTKM_CONT bool operator!=(const ArrayHandle< ValueType, StorageTag > &rhs) const
Definition: ArrayHandle.h:382
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:552
Assert.h
vtkm::cont::ArrayHandle::GetStorage
VTKM_CONT StorageType GetStorage() const
Get the storage.
Definition: ArrayHandle.h:401
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:593
vtkm::cont::ArrayHandle::~ArrayHandle
VTKM_CONT ~ArrayHandle()
Destructs an empty ArrayHandle.
Definition: ArrayHandle.h:350
vtkm::cont::ArrayHandle< vtkm::Id >::ValueType
vtkm::Id ValueType
Definition: ArrayHandle.h:290
vtkm::cont::ArrayHandle< vtkm::Id >::ReadPortalType
typename StorageType::ReadPortalType ReadPortalType
Definition: ArrayHandle.h:294
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:388
vtkm::cont::ArrayHandle::SetBuffers
VTKM_CONT void SetBuffers(const std::vector< vtkm::cont::internal::Buffer > &buffers)
Definition: ArrayHandle.h:711
vtkm::cont::ArrayHandle::WritePortal
VTKM_CONT WritePortalType WritePortal(vtkm::cont::Token &token) const
Definition: ArrayHandle.h:440
vtkm::cont::ArrayHandle::ReadPortal
VTKM_CONT ReadPortalType ReadPortal(vtkm::cont::Token &token) const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:419
vtkm::cont::ArrayHandle::Fill
VTKM_CONT 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:530
vtkm::cont::ArrayHandle::Fill
VTKM_CONT void Fill(const ValueType &fillValue, vtkm::Id startIndex=0) const
Fills the array with a given value.
Definition: ArrayHandle.h:542
vtkm::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::cont::ArrayHandle::Fill
VTKM_CONT void Fill(const ValueType &fillValue, vtkm::Id startIndex, vtkm::Id endIndex) const
Fills the array with a given value.
Definition: ArrayHandle.h:537
vtkm::cont::ArrayHandle::GetBuffers
VTKM_CONT std::vector< vtkm::cont::internal::Buffer > & GetBuffers()
Definition: ArrayHandle.h:700
vtkm::cont::ArrayHandle::ArrayHandle
VTKM_CONT ArrayHandle()
Constructs an empty ArrayHandle.
Definition: ArrayHandle.h:299
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:323
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::ArrayHandle::IsOnHost
VTKM_CONT bool IsOnHost() const
Returns true if the ArrayHandle's data is on the host.
Definition: ArrayHandle.h:632
Buffer.h
vtkm::cont::ArrayHandle::SetBuffer
VTKM_CONT void SetBuffer(vtkm::IdComponent index, const vtkm::cont::internal::Buffer &buffer)
Definition: ArrayHandle.h:706
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::cont::ArrayHandle::SyncControlArray
VTKM_CONT void SyncControlArray() const
Synchronizes the control array with the execution array.
Definition: ArrayHandle.h:643
vtkm::cont::ArrayHandle::WritePortal
VTKM_CONT WritePortalType WritePortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:435
vtkm::cont::ArrayHandle< vtkm::Id >::WritePortalType
typename StorageType::WritePortalType WritePortalType
Definition: ArrayHandle.h:295
vtkm::UInt8
uint8_t UInt8
Definition: Types.h:157
vtkm::cont::ArrayHandle::operator!=
VTKM_CONT bool operator!=(const ArrayHandle< VT, ST > &) const
Definition: ArrayHandle.h:394
vtkm::CopyFlag::On
@ On
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::cont::ArrayHandle::DeepCopyFrom
VTKM_CONT void DeepCopyFrom(const vtkm::cont::ArrayHandle< ValueType, StorageTag > &source) const
Deep copies the data in the array.
Definition: ArrayHandle.h:682
vtkm::CopyFlag::Off
@ Off
vtkm::cont::ArrayHandle::ArrayHandle
VTKM_CONT ArrayHandle(std::vector< vtkm::cont::internal::Buffer > &&buffers) noexcept
Definition: ArrayHandle.h:337
vtkm::cont::ArrayHandle::ReadPortal
VTKM_CONT ReadPortalType ReadPortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:414
vtkm::cont::ArrayHandle::PrepareForOutput
VTKM_CONT 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:613
ErrorBadValue.h
vtkm::cont::ArrayHandle< vtkm::Id >::StorageTag
VTKM_DEFAULT_STORAGE_TAG StorageTag
Definition: ArrayHandle.h:291
vtkm::cont::ArrayHandle< vtkm::Id >::StorageType
vtkm::cont::internal::Storage< ValueType, StorageTag > StorageType
Definition: ArrayHandle.h:292
vtkm::cont::StorageTagBasic
A tag for the basic implementation of a Storage object.
Definition: ArrayHandle.h:45
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:311
VTKM_NEVER_EXPORT
#define VTKM_NEVER_EXPORT
Definition: ExportMacros.h:93
vtkm::cont::ArrayHandle::IsOnDevice
VTKM_CONT bool IsOnDevice(vtkm::cont::DeviceAdapterId device) const
Returns true if the ArrayHandle's data is on the given device.
Definition: ArrayHandle.h:624
ErrorInternal.h
VTKM_ALWAYS_EXPORT
#define VTKM_ALWAYS_EXPORT
Definition: ExportMacros.h:92
Flags.h
vtkm::cont::ArrayHandle::AllocateAndFill
VTKM_CONT 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:514
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:376
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::cont::ArrayHandle::ReleaseResources
VTKM_CONT void ReleaseResources() const
Releases all resources in both the control and execution environments.
Definition: ArrayHandle.h:559
vtkm::Pair::second
SecondType second
The pair's second object.
Definition: Pair.h:55
StorageError.h
vtkm::cont::ArrayHandle::Allocate
VTKM_CONT 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:472