Viskores  1.0
ArrayHandle.h
Go to the documentation of this file.
1 //============================================================================
2 // The contents of this file are covered by the Viskores license. See
3 // LICENSE.txt for details.
4 //
5 // By contributing to this file, all contributors agree to the Developer
6 // Certificate of Origin Version 1.1 (DCO 1.1) as stated in DCO.txt.
7 //============================================================================
8 
9 //============================================================================
10 // Copyright (c) Kitware, Inc.
11 // All rights reserved.
12 // See LICENSE.txt for details.
13 //
14 // This software is distributed WITHOUT ANY WARRANTY; without even
15 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 // PURPOSE. See the above copyright notice for more information.
17 //============================================================================
18 #ifndef viskores_cont_ArrayHandle_h
19 #define viskores_cont_ArrayHandle_h
20 
22 
23 #include <viskores/Assert.h>
24 #include <viskores/Flags.h>
25 #include <viskores/Types.h>
26 
30 #include <viskores/cont/Storage.h>
31 #include <viskores/cont/Token.h>
32 
34 
35 #include <algorithm>
36 #include <deque>
37 #include <iterator>
38 #include <memory>
39 #include <mutex>
40 #include <vector>
41 
43 
44 namespace viskores
45 {
46 namespace cont
47 {
48 
49 // Normally this would be defined in ArrayHandleBasic.h, but we need this declared early for
50 // the default storage.
51 
53 struct VISKORES_ALWAYS_EXPORT StorageTagBasic
54 {
55 };
56 }
57 } // namespace viskores::cont
58 
59 #if VISKORES_STORAGE == VISKORES_STORAGE_BASIC
60 
61 #define VISKORES_DEFAULT_STORAGE_TAG ::viskores::cont::StorageTagBasic
62 
63 #elif VISKORES_STORAGE == VISKORES_STORAGE_ERROR
64 
66 #define VISKORES_DEFAULT_STORAGE_TAG ::viskores::cont::internal::StorageTagError
67 
68 #elif (VISKORES_STORAGE == VISKORES_STORAGE_UNDEFINED) || !defined(VISKORES_STORAGE)
69 
70 #ifndef VISKORES_DEFAULT_STORAGE_TAG
71 #warning If array storage is undefined, VISKORES_DEFAULT_STORAGE_TAG must be defined.
72 #endif
73 
74 #endif
75 
76 namespace viskores
77 {
78 namespace cont
79 {
80 
81 namespace internal
82 {
83 
90 class VISKORES_CONT_EXPORT ArrayHandleBase
91 {
92 };
93 
98 template <typename T, typename StorageTag>
99 using IsValidArrayHandle = std::integral_constant<
100  bool,
101  !(std::is_base_of<viskores::cont::internal::UndefinedStorage,
102  viskores::cont::internal::Storage<T, StorageTag>>::value)>;
103 
108 template <typename T, typename StorageTag>
109 using IsInvalidArrayHandle =
110  std::integral_constant<bool, !IsValidArrayHandle<T, StorageTag>::value>;
111 
118 template <typename ArrayHandle>
119 using IsWritableArrayHandle =
120  viskores::internal::PortalSupportsSets<typename std::decay<ArrayHandle>::type::WritePortalType>;
121 
134 template <typename T>
135 struct ArrayHandleCheck
136  : std::is_base_of<viskores::cont::internal::ArrayHandleBase, std::decay_t<T>>::type
137 {
138 };
139 
145 #define VISKORES_IS_ARRAY_HANDLE(T) \
146  VISKORES_STATIC_ASSERT(::viskores::cont::internal::ArrayHandleCheck<T>{})
147 
148 } // namespace internal
149 
150 namespace detail
151 {
152 
153 template <typename T>
154 struct GetTypeInParentheses;
155 template <typename T>
156 struct GetTypeInParentheses<void(T)>
157 {
158  using type = T;
159 };
160 
161 } // namespace detail
162 
163 // Implementation for VISKORES_ARRAY_HANDLE_SUBCLASS macros
164 #define VISKORES_ARRAY_HANDLE_SUBCLASS_IMPL(classname, fullclasstype, superclass, typename__) \
165  using Thisclass = \
166  typename__ viskores::cont::detail::GetTypeInParentheses<void fullclasstype>::type; \
167  using Superclass = \
168  typename__ viskores::cont::detail::GetTypeInParentheses<void superclass>::type; \
169  \
170  VISKORES_IS_ARRAY_HANDLE(Superclass); \
171  \
172  VISKORES_CONT \
173  classname() \
174  { \
175  } \
176  \
177  VISKORES_CONT \
178  classname(const Thisclass& src) \
179  : Superclass(src) \
180  { \
181  } \
182  \
183  VISKORES_CONT \
184  classname(Thisclass&& src) noexcept \
185  : Superclass(std::move(src)) \
186  { \
187  } \
188  \
189  VISKORES_CONT \
190  classname(const viskores::cont::ArrayHandle<typename__ Superclass::ValueType, \
191  typename__ Superclass::StorageTag>& src) \
192  : Superclass(src) \
193  { \
194  } \
195  \
196  VISKORES_CONT \
197  classname(viskores::cont::ArrayHandle<typename__ Superclass::ValueType, \
198  typename__ Superclass::StorageTag>&& src) noexcept \
199  : Superclass(std::move(src)) \
200  { \
201  } \
202  \
203  VISKORES_CONT \
204  explicit classname(const std::vector<viskores::cont::internal::Buffer>& buffers) \
205  : Superclass(buffers) \
206  { \
207  } \
208  \
209  VISKORES_CONT \
210  explicit classname(std::vector<viskores::cont::internal::Buffer>&& buffers) noexcept \
211  : Superclass(std::move(buffers)) \
212  { \
213  } \
214  \
215  VISKORES_CONT \
216  Thisclass& operator=(const Thisclass& src) \
217  { \
218  this->Superclass::operator=(src); \
219  return *this; \
220  } \
221  \
222  VISKORES_CONT \
223  Thisclass& operator=(Thisclass&& src) noexcept \
224  { \
225  this->Superclass::operator=(std::move(src)); \
226  return *this; \
227  } \
228  \
229  using ValueType = typename__ Superclass::ValueType; \
230  using StorageTag = typename__ Superclass::StorageTag; \
231  using StorageType = typename__ Superclass::StorageType; \
232  using ReadPortalType = typename__ Superclass::ReadPortalType; \
233  using WritePortalType = typename__ Superclass::WritePortalType
234 
256 #define VISKORES_ARRAY_HANDLE_SUBCLASS(classname, fullclasstype, superclass) \
257  VISKORES_ARRAY_HANDLE_SUBCLASS_IMPL(classname, fullclasstype, superclass, typename)
258 
279 #define VISKORES_ARRAY_HANDLE_SUBCLASS_NT(classname, superclass) \
280  VISKORES_ARRAY_HANDLE_SUBCLASS_IMPL(classname, (classname), superclass, )
281 
282 namespace detail
283 {
284 
285 VISKORES_CONT_EXPORT VISKORES_CONT void ArrayHandleReleaseResourcesExecution(
286  const std::vector<viskores::cont::internal::Buffer>& buffers);
287 
288 VISKORES_CONT_EXPORT VISKORES_CONT bool ArrayHandleIsOnDevice(
289  const std::vector<viskores::cont::internal::Buffer>& buffers,
291 
292 } // namespace detail
293 
312 template <typename T, typename StorageTag_ = VISKORES_DEFAULT_STORAGE_TAG>
313 class VISKORES_ALWAYS_EXPORT ArrayHandle : public internal::ArrayHandleBase
314 {
316  (internal::IsValidArrayHandle<T, StorageTag_>::value),
317  "Attempted to create an ArrayHandle with an invalid type/storage combination.");
318 
319 public:
320  using ValueType = T;
321  using StorageTag = StorageTag_;
322  using StorageType = viskores::cont::internal::Storage<ValueType, StorageTag>;
323 
325  using ReadPortalType = typename StorageType::ReadPortalType;
327  using WritePortalType = typename StorageType::WritePortalType;
328 
332  : Buffers(StorageType::CreateBuffers())
333  {
334  }
335 
344  : Buffers(src.Buffers)
345  {
346  }
347 
356  : Buffers(std::move(src.Buffers))
357  {
358  }
359 
363  VISKORES_CONT explicit ArrayHandle(const std::vector<viskores::cont::internal::Buffer>& buffers)
364  : Buffers(buffers)
365  {
366  }
367 
372  std::vector<viskores::cont::internal::Buffer>&& buffers) noexcept
373  : Buffers(std::move(buffers))
374  {
375  }
376 
385 
391  {
392  this->Buffers = src.Buffers;
393  return *this;
394  }
395 
401  {
402  this->Buffers = std::move(src.Buffers);
403  return *this;
404  }
405 
411  {
412  return this->Buffers == rhs.Buffers;
413  }
414 
417  {
418  return this->Buffers != rhs.Buffers;
419  }
420 
421  template <typename VT, typename ST>
423  {
424  return false; // different valuetype and/or storage
425  }
426 
427  template <typename VT, typename ST>
429  {
430  return true; // different valuetype and/or storage
431  }
432 
436 
448  {
449  viskores::cont::Token token;
450  return this->ReadPortal(token);
451  }
454  {
455  return StorageType::CreateReadPortal(
456  this->GetBuffers(), viskores::cont::DeviceAdapterTagUndefined{}, token);
457  }
458 
469  {
470  viskores::cont::Token token;
471  return this->WritePortal(token);
472  }
475  {
476  return StorageType::CreateWritePortal(
477  this->GetBuffers(), viskores::cont::DeviceAdapterTagUndefined{}, token);
478  }
479 
483  {
484  return StorageType::GetNumberOfValues(this->GetBuffers());
485  }
486 
489  {
490  return StorageType::GetNumberOfComponentsFlat(this->GetBuffers());
491  }
492 
504  VISKORES_CONT void Allocate(viskores::Id numberOfValues,
505  viskores::CopyFlag preserve,
506  viskores::cont::Token& token) const
507  {
508  StorageType::ResizeBuffers(numberOfValues, this->GetBuffers(), preserve, token);
509  }
510 
512  VISKORES_CONT void Allocate(viskores::Id numberOfValues,
514  {
515  viskores::cont::Token token;
516  this->Allocate(numberOfValues, preserve, token);
517  }
518 
534  const ValueType& fillValue,
535  viskores::CopyFlag preserve,
536  viskores::cont::Token& token) const
537  {
538  // Note that there is a slight potential for a race condition here. It is possible for someone
539  // else to resize the array in between getting the startIndex and locking the array in the
540  // Allocate call. If there really are 2 threads trying to allocate this array at the same time,
541  // you probably have bigger problems than filling at the wrong index.
542  viskores::Id startIndex = (preserve == viskores::CopyFlag::On) ? this->GetNumberOfValues() : 0;
543 
544  this->Allocate(numberOfValues, preserve, token);
545 
546  if (startIndex < numberOfValues)
547  {
548  this->Fill(fillValue, startIndex, numberOfValues, token);
549  }
550  }
551 
554  const ValueType& fillValue,
556  {
557  viskores::cont::Token token;
558  this->AllocateAndFill(numberOfValues, fillValue, preserve, token);
559  }
560 
568  VISKORES_CONT void Fill(const ValueType& fillValue,
569  viskores::Id startIndex,
570  viskores::Id endIndex,
571  viskores::cont::Token& token) const
572  {
573  StorageType::Fill(this->GetBuffers(), fillValue, startIndex, endIndex, token);
574  }
576  VISKORES_CONT void Fill(const ValueType& fillValue,
577  viskores::Id startIndex,
578  viskores::Id endIndex) const
579  {
580  viskores::cont::Token token;
581  this->Fill(fillValue, startIndex, endIndex, token);
582  }
584  VISKORES_CONT void Fill(const ValueType& fillValue, viskores::Id startIndex = 0) const
585  {
586  viskores::cont::Token token;
587  this->Fill(fillValue, startIndex, this->GetNumberOfValues(), token);
588  }
589 
594  {
595  detail::ArrayHandleReleaseResourcesExecution(this->Buffers);
596  }
597 
600  VISKORES_CONT void ReleaseResources() const { this->Allocate(0); }
601 
616  viskores::cont::Token& token) const
617  {
618  return StorageType::CreateReadPortal(this->GetBuffers(), device, token);
619  }
620 
635  viskores::cont::Token& token) const
636  {
637  return StorageType::CreateWritePortal(this->GetBuffers(), device, token);
638  }
639 
656  viskores::cont::Token& token) const
657  {
658  this->Allocate(numberOfValues, viskores::CopyFlag::Off, token);
659  return StorageType::CreateWritePortal(this->GetBuffers(), device, token);
660  }
661 
666  {
667  return detail::ArrayHandleIsOnDevice(this->Buffers, device);
668  }
669 
673  VISKORES_CONT bool IsOnHost() const
674  {
675  return this->IsOnDevice(viskores::cont::DeviceAdapterTagUndefined{});
676  }
677 
685  {
686  // Creating a host read portal will force the data to be synced to the host.
687  this->ReadPortal();
688  }
689 
711  VISKORES_CONT void Enqueue(const viskores::cont::Token& token) const
712  {
713  for (auto&& buffer : this->Buffers)
714  {
715  buffer.Enqueue(token);
716  }
717  }
718 
725  {
726  VISKORES_ASSERT(this->Buffers.size() == source.Buffers.size());
727 
728  for (std::size_t bufferIndex = 0; bufferIndex < this->Buffers.size(); ++bufferIndex)
729  {
730  this->Buffers[bufferIndex].DeepCopyFrom(source.Buffers[bufferIndex]);
731  }
732  }
733 
738  VISKORES_CONT const std::vector<viskores::cont::internal::Buffer>& GetBuffers() const
739  {
740  return this->Buffers;
741  }
742  VISKORES_CONT std::vector<viskores::cont::internal::Buffer>& GetBuffers()
743  {
744  return this->Buffers;
745  }
746 
747 private:
748  mutable std::vector<viskores::cont::internal::Buffer> Buffers;
749 
750 protected:
752  const viskores::cont::internal::Buffer& buffer)
753  {
754  this->Buffers[static_cast<std::size_t>(index)] = buffer;
755  }
756 
757  VISKORES_CONT void SetBuffers(const std::vector<viskores::cont::internal::Buffer>& buffers)
758  {
759  this->Buffers = buffers;
760  }
761  VISKORES_CONT void SetBuffers(std::vector<viskores::cont::internal::Buffer>&& buffers)
762  {
763  this->Buffers = std::move(buffers);
764  }
765 };
766 
767 namespace detail
768 {
769 
770 template <typename T>
771 VISKORES_NEVER_EXPORT VISKORES_CONT inline void printSummary_ArrayHandle_Value(
772  const T& value,
773  std::ostream& out,
775 {
776  out << value;
777 }
778 
779 VISKORES_NEVER_EXPORT
781 inline void printSummary_ArrayHandle_Value(viskores::UInt8 value,
782  std::ostream& out,
784 {
785  out << static_cast<int>(value);
786 }
787 
788 VISKORES_NEVER_EXPORT
790 inline void printSummary_ArrayHandle_Value(viskores::Int8 value,
791  std::ostream& out,
793 {
794  out << static_cast<int>(value);
795 }
796 
797 template <typename T>
798 VISKORES_NEVER_EXPORT VISKORES_CONT inline void printSummary_ArrayHandle_Value(
799  const T& value,
800  std::ostream& out,
802 {
803  using Traits = viskores::VecTraits<T>;
804  using ComponentType = typename Traits::ComponentType;
806  viskores::IdComponent numComponents = Traits::GetNumberOfComponents(value);
807  out << "(";
808  printSummary_ArrayHandle_Value(Traits::GetComponent(value, 0), out, IsVecOfVec());
809  for (viskores::IdComponent index = 1; index < numComponents; ++index)
810  {
811  out << ",";
812  printSummary_ArrayHandle_Value(Traits::GetComponent(value, index), out, IsVecOfVec());
813  }
814  out << ")";
815 }
816 
817 template <typename T1, typename T2>
818 VISKORES_NEVER_EXPORT VISKORES_CONT inline void printSummary_ArrayHandle_Value(
819  const viskores::Pair<T1, T2>& value,
820  std::ostream& out,
822 {
823  out << "{";
824  printSummary_ArrayHandle_Value(
826  out << ",";
827  printSummary_ArrayHandle_Value(
829  out << "}";
830 }
831 
832 
833 
834 } // namespace detail
835 
836 template <typename T, typename StorageT>
837 VISKORES_NEVER_EXPORT VISKORES_CONT inline void printSummary_ArrayHandle(
839  std::ostream& out,
840  bool full = false)
841 {
843  using PortalType = typename ArrayType::ReadPortalType;
844  using IsVec = typename viskores::VecTraits<T>::HasMultipleComponents;
845 
846  viskores::Id sz = array.GetNumberOfValues();
847 
848  out << "valueType=" << viskores::cont::TypeToString<T>()
849  << " storageType=" << viskores::cont::TypeToString<StorageT>() << " " << sz
850  << " values occupying " << (static_cast<size_t>(sz) * sizeof(T)) << " bytes [";
851 
852  PortalType portal = array.ReadPortal();
853  if (full || sz <= 7)
854  {
855  for (viskores::Id i = 0; i < sz; i++)
856  {
857  detail::printSummary_ArrayHandle_Value(portal.Get(i), out, IsVec());
858  if (i != (sz - 1))
859  {
860  out << " ";
861  }
862  }
863  }
864  else
865  {
866  detail::printSummary_ArrayHandle_Value(portal.Get(0), out, IsVec());
867  out << " ";
868  detail::printSummary_ArrayHandle_Value(portal.Get(1), out, IsVec());
869  out << " ";
870  detail::printSummary_ArrayHandle_Value(portal.Get(2), out, IsVec());
871  out << " ... ";
872  detail::printSummary_ArrayHandle_Value(portal.Get(sz - 3), out, IsVec());
873  out << " ";
874  detail::printSummary_ArrayHandle_Value(portal.Get(sz - 2), out, IsVec());
875  out << " ";
876  detail::printSummary_ArrayHandle_Value(portal.Get(sz - 1), out, IsVec());
877  }
878  out << "]\n";
879 }
880 
881 namespace internal
882 {
883 
884 namespace detail
885 {
886 
887 VISKORES_CONT inline void CreateBuffersImpl(std::vector<viskores::cont::internal::Buffer>&);
888 template <typename T, typename S, typename... Args>
889 VISKORES_CONT inline void CreateBuffersImpl(std::vector<viskores::cont::internal::Buffer>& buffers,
891  const Args&... args);
892 template <typename... Args>
893 VISKORES_CONT inline void CreateBuffersImpl(std::vector<viskores::cont::internal::Buffer>& buffers,
894  const viskores::cont::internal::Buffer& buffer,
895  const Args&... args);
896 
897 template <typename... Args>
898 VISKORES_CONT inline void CreateBuffersImpl(
899  std::vector<viskores::cont::internal::Buffer>& buffers,
900  const std::vector<viskores::cont::internal::Buffer>& addbuffs,
901  const Args&... args);
902 template <typename Arg0, typename... Args>
903 VISKORES_CONT inline void CreateBuffersImpl(std::vector<viskores::cont::internal::Buffer>& buffers,
904  const Arg0& arg0,
905  const Args&... args);
906 
907 VISKORES_CONT inline void CreateBuffersImpl(std::vector<viskores::cont::internal::Buffer>&)
908 {
909  // Nothing left to add.
910 }
911 
912 template <typename T, typename S, typename... Args>
913 VISKORES_CONT inline void CreateBuffersImpl(std::vector<viskores::cont::internal::Buffer>& buffers,
915  const Args&... args)
916 {
917  CreateBuffersImpl(buffers, array.GetBuffers(), args...);
918 }
919 
920 template <typename... Args>
921 VISKORES_CONT inline void CreateBuffersImpl(std::vector<viskores::cont::internal::Buffer>& buffers,
922  const viskores::cont::internal::Buffer& buffer,
923  const Args&... args)
924 {
925  buffers.push_back(buffer);
926  CreateBuffersImpl(buffers, args...);
927 }
928 
929 template <typename... Args>
930 VISKORES_CONT inline void CreateBuffersImpl(
931  std::vector<viskores::cont::internal::Buffer>& buffers,
932  const std::vector<viskores::cont::internal::Buffer>& addbuffs,
933  const Args&... args)
934 {
935  buffers.insert(buffers.end(), addbuffs.begin(), addbuffs.end());
936  CreateBuffersImpl(buffers, args...);
937 }
938 
939 template <typename T, typename S, typename... Args>
940 VISKORES_CONT inline void CreateBuffersResolveArrays(
941  std::vector<viskores::cont::internal::Buffer>& buffers,
942  std::true_type,
944  const Args&... args)
945 {
946  CreateBuffersImpl(buffers, array, args...);
947 }
948 
949 template <typename MetaData, typename... Args>
950 VISKORES_CONT inline void CreateBuffersResolveArrays(
951  std::vector<viskores::cont::internal::Buffer>& buffers,
952  std::false_type,
953  const MetaData& metadata,
954  const Args&... args)
955 {
956  viskores::cont::internal::Buffer buffer;
957  buffer.SetMetaData(metadata);
958  buffers.push_back(std::move(buffer));
959  CreateBuffersImpl(buffers, args...);
960 }
961 
962 template <typename Arg0, typename... Args>
963 VISKORES_CONT inline void CreateBuffersImpl(std::vector<viskores::cont::internal::Buffer>& buffers,
964  const Arg0& arg0,
965  const Args&... args)
966 {
967  // If the argument is a subclass of ArrayHandle, the template resolution will pick this
968  // overload instead of the correct ArrayHandle overload. To resolve that, check to see
969  // if the type is an `ArrayHandle` and use `CreateBuffersResolveArrays` to choose the
970  // right path.
971  using IsArray = typename viskores::cont::internal::ArrayHandleCheck<Arg0>::type::type;
972  CreateBuffersResolveArrays(buffers, IsArray{}, arg0, args...);
973 }
974 
975 } // namespace detail
976 
991 template <typename... Args>
992 VISKORES_CONT inline std::vector<viskores::cont::internal::Buffer> CreateBuffers(
993  const Args&... args)
994 {
995  std::vector<viskores::cont::internal::Buffer> buffers;
996  buffers.reserve(sizeof...(args));
997  detail::CreateBuffersImpl(buffers, args...);
998  return buffers;
999 }
1000 
1001 } // namespace internal
1002 
1003 }
1004 } //namespace viskores::cont
1005 
1006 #ifndef viskores_cont_ArrayHandleBasic_h
1008 #endif
1009 
1010 #endif //viskores_cont_ArrayHandle_h
viskores::cont::ArrayHandle< T, viskores::cont::StorageTagBasic >::StorageType
viskores::cont::internal::Storage< ValueType, StorageTag > StorageType
Definition: ArrayHandle.h:322
viskores::cont::ArrayHandle::GetStorage
StorageType GetStorage() const
Get the storage.
Definition: ArrayHandle.h:435
viskores::cont::ArrayHandle::ReadPortal
ReadPortalType ReadPortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:447
viskores::cont::ArrayHandle::GetNumberOfComponentsFlat
viskores::IdComponent GetNumberOfComponentsFlat() const
Returns the total number of components for each value in the array.
Definition: ArrayHandle.h:488
viskores::cont::ArrayHandle::Enqueue
void Enqueue(const viskores::cont::Token &token) const
Enqueue a token for access to this ArrayHandle.
Definition: ArrayHandle.h:711
viskores::cont::ArrayHandle::ReadPortal
ReadPortalType ReadPortal(viskores::cont::Token &token) const
The type of portal used when accessing data in a read-only mode.
Definition: ArrayHandle.h:453
viskores::CopyFlag::Off
@ Off
viskores::cont::ArrayHandle::ArrayHandle
ArrayHandle()
Constructs an empty ArrayHandle.
Definition: ArrayHandle.h:331
viskores::cont::ArrayHandle::SetBuffers
void SetBuffers(const std::vector< viskores::cont::internal::Buffer > &buffers)
Definition: ArrayHandle.h:757
Types.h
ArrayPortalHelpers.h
viskores::cont::ArrayHandle::~ArrayHandle
~ArrayHandle()
Destructs an empty ArrayHandle.
Definition: ArrayHandle.h:384
viskores::cont::ArrayHandle::PrepareForInput
ReadPortalType PrepareForInput(viskores::cont::DeviceAdapterId device, viskores::cont::Token &token) const
Prepares this array to be used as an input to an operation in the execution environment.
Definition: ArrayHandle.h:615
viskores::cont::ArrayHandle::operator!=
bool operator!=(const ArrayHandle< VT, ST > &) const
Definition: ArrayHandle.h:428
viskores::cont::ArrayHandle::operator=
viskores::cont::ArrayHandle< ValueType, StorageTag > & operator=(viskores::cont::ArrayHandle< ValueType, StorageTag > &&src) noexcept
Move and Assignment of an ArrayHandle.
Definition: ArrayHandle.h:399
viskores::Int8
int8_t Int8
Base type to use for 8-bit signed integer numbers.
Definition: Types.h:173
ArrayHandleBasic.h
DeviceAdapterList.h
Storage.h
viskores::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:313
viskores::VecTraitsTagMultipleComponents
A tag for vectors that are "true" vectors (i.e.
Definition: VecTraits.h:31
viskores::VecTraitsTagSingleComponent
A tag for vectors that are really just scalars (i.e.
Definition: VecTraits.h:38
viskores::cont::ArrayHandle::Fill
void Fill(const ValueType &fillValue, viskores::Id startIndex=0) const
Fills the array with a given value.
Definition: ArrayHandle.h:584
Assert.h
viskores::cont::ArrayHandle::operator==
bool operator==(const ArrayHandle< VT, ST > &) const
Definition: ArrayHandle.h:422
viskores::cont::ArrayHandle< T, viskores::cont::StorageTagBasic >::ReadPortalType
typename StorageType::ReadPortalType ReadPortalType
The type of portal used when accessing data in a read-only mode.
Definition: ArrayHandle.h:325
viskores::IdComponent
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
viskores::cont::ArrayHandle< T, viskores::cont::StorageTagBasic >::WritePortalType
typename StorageType::WritePortalType WritePortalType
The type of portal used when accessing data in a read-write mode.
Definition: ArrayHandle.h:327
viskores::cont::StorageTagBasic
A tag for the basic implementation of a Storage object.
Definition: ArrayHandle.h:53
viskores::cont::ArrayHandle::SetBuffer
void SetBuffer(viskores::IdComponent index, const viskores::cont::internal::Buffer &buffer)
Definition: ArrayHandle.h:751
viskores::cont::ArrayHandle::ArrayHandle
ArrayHandle(std::vector< viskores::cont::internal::Buffer > &&buffers) noexcept
Special constructor for subclass specializations that need to set the initial state array.
Definition: ArrayHandle.h:371
viskores::cont::ArrayHandle::SetBuffers
void SetBuffers(std::vector< viskores::cont::internal::Buffer > &&buffers)
Definition: ArrayHandle.h:761
viskores::cont::printSummary_ArrayHandle
void printSummary_ArrayHandle(const viskores::cont::ArrayHandle< T, StorageT > &array, std::ostream &out, bool full=false)
Definition: ArrayHandle.h:837
viskores::cont::ArrayHandle::Fill
void Fill(const ValueType &fillValue, viskores::Id startIndex, viskores::Id endIndex) const
Fills the array with a given value.
Definition: ArrayHandle.h:576
viskores::cont::ArrayHandle::GetBuffers
std::vector< viskores::cont::internal::Buffer > & GetBuffers()
Definition: ArrayHandle.h:742
viskores::Id
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
viskores::cont::ArrayHandle::ReleaseResources
void ReleaseResources() const
Releases all resources in both the control and execution environments.
Definition: ArrayHandle.h:600
VISKORES_CONT
#define VISKORES_CONT
Definition: ExportMacros.h:65
viskores
Groups connected points that have the same field value.
Definition: Atomic.h:27
viskores::cont::ArrayHandle::Buffers
std::vector< viskores::cont::internal::Buffer > Buffers
Definition: ArrayHandle.h:748
viskores::Pair::first
FirstType first
The pair's first object.
Definition: Pair.h:58
viskores::cont::ArrayHandle::PrepareForInPlace
WritePortalType PrepareForInPlace(viskores::cont::DeviceAdapterId device, viskores::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:634
viskores::CopyFlag::On
@ On
viskores::cont::ArrayHandle::AllocateAndFill
void AllocateAndFill(viskores::Id numberOfValues, const ValueType &fillValue, viskores::CopyFlag preserve, viskores::cont::Token &token) const
Allocates an array and fills it with an initial value.
Definition: ArrayHandle.h:533
viskores::VecTraits
Traits that can be queried to treat any type as a Vec.
Definition: VecTraits.h:69
viskores::cont::ArrayHandle::WritePortal
WritePortalType WritePortal(viskores::cont::Token &token) const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:474
viskores::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:410
viskores::cont::ArrayHandle::Allocate
void Allocate(viskores::Id numberOfValues, viskores::CopyFlag preserve, viskores::cont::Token &token) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:504
Buffer.h
viskores::cont::ArrayHandle::GetNumberOfValues
viskores::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:482
viskores::cont::DeviceAdapterTagUndefined
Tag for a device adapter used to avoid specifying a device.
Definition: DeviceAdapterTag.h:201
viskores::cont::ArrayHandle::PrepareForOutput
WritePortalType PrepareForOutput(viskores::Id numberOfValues, viskores::cont::DeviceAdapterId device, viskores::cont::Token &token) const
Prepares (allocates) this array to be used as an output from an operation in the execution environmen...
Definition: ArrayHandle.h:654
VISKORES_ASSERT
#define VISKORES_ASSERT(condition)
Definition: Assert.h:51
viskores::cont::ArrayHandle::operator!=
bool operator!=(const ArrayHandle< ValueType, StorageTag > &rhs) const
Definition: ArrayHandle.h:416
viskores::cont::ArrayHandle::WritePortal
WritePortalType WritePortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:468
viskores::cont::ArrayHandle::AllocateAndFill
void AllocateAndFill(viskores::Id numberOfValues, const ValueType &fillValue, viskores::CopyFlag preserve=viskores::CopyFlag::Off) const
Allocates an array and fills it with an initial value.
Definition: ArrayHandle.h:553
viskores::Pair
A viskores::Pair is essentially the same as an STL pair object except that the methods (constructors ...
Definition: Pair.h:37
VISKORES_STATIC_ASSERT_MSG
#define VISKORES_STATIC_ASSERT_MSG(condition, message)
Definition: StaticAssert.h:26
viskores::cont::ArrayHandle::IsOnDevice
bool IsOnDevice(viskores::cont::DeviceAdapterId device) const
Returns true if the ArrayHandle's data is on the given device.
Definition: ArrayHandle.h:665
viskores::UInt8
uint8_t UInt8
Base type to use for 8-bit unsigned integer numbers.
Definition: Types.h:177
viskores::cont::ArrayHandle::ArrayHandle
ArrayHandle(const std::vector< viskores::cont::internal::Buffer > &buffers)
Special constructor for subclass specializations that need to set the initial state array.
Definition: ArrayHandle.h:363
viskores::cont::DeviceAdapterId
An object used to specify a device.
Definition: DeviceAdapterTag.h:66
viskores::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:593
viskores::cont::ArrayHandle::DeepCopyFrom
void DeepCopyFrom(const viskores::cont::ArrayHandle< ValueType, StorageTag > &source) const
Deep copies the data in the array.
Definition: ArrayHandle.h:723
viskores::cont::ArrayHandle::operator=
viskores::cont::ArrayHandle< ValueType, StorageTag > & operator=(const viskores::cont::ArrayHandle< ValueType, StorageTag > &src)
Shallow copies an ArrayHandle.
Definition: ArrayHandle.h:389
viskores::cont::ArrayHandle< T, viskores::cont::StorageTagBasic >::ValueType
T ValueType
Definition: ArrayHandle.h:320
viskores::cont::ArrayHandle::Fill
void Fill(const ValueType &fillValue, viskores::Id startIndex, viskores::Id endIndex, viskores::cont::Token &token) const
Fills the array with a given value.
Definition: ArrayHandle.h:568
ErrorBadValue.h
viskores::Pair::second
SecondType second
The pair's second object.
Definition: Pair.h:63
viskores::cont::ArrayHandle::SyncControlArray
void SyncControlArray() const
Synchronizes the control array with the execution array.
Definition: ArrayHandle.h:684
ErrorInternal.h
Flags.h
viskores::cont::ArrayHandle::IsOnHost
bool IsOnHost() const
Returns true if the ArrayHandle's data is on the host.
Definition: ArrayHandle.h:673
viskores::CopyFlag
CopyFlag
Identifier used to specify whether a function should deep copy data.
Definition: Flags.h:25
Token.h
viskores::cont::ArrayHandle::ArrayHandle
ArrayHandle(viskores::cont::ArrayHandle< ValueType, StorageTag > &&src) noexcept
Move constructor.
Definition: ArrayHandle.h:355
viskores::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:43
viskores::cont::ArrayHandle::GetBuffers
const std::vector< viskores::cont::internal::Buffer > & GetBuffers() const
Returns the internal Buffer structures that hold the data.
Definition: ArrayHandle.h:738
viskores::cont::ArrayHandle::ArrayHandle
ArrayHandle(const viskores::cont::ArrayHandle< ValueType, StorageTag > &src)
Copy constructor.
Definition: ArrayHandle.h:343
StorageError.h
viskores::cont::ArrayHandle::Allocate
void Allocate(viskores::Id numberOfValues, viskores::CopyFlag preserve=viskores::CopyFlag::Off) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:512
viskores_cont_export.h