VTK-m  2.2
BitField.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 
11 #ifndef vtk_m_cont_BitField_h
12 #define vtk_m_cont_BitField_h
13 
14 #include <vtkm/cont/ArrayHandle.h>
16 
17 #include <vtkm/Atomic.h>
18 #include <vtkm/List.h>
19 #include <vtkm/Types.h>
20 
21 #include <cassert>
22 #include <climits>
23 #include <memory>
24 #include <type_traits>
25 
26 namespace vtkm
27 {
28 namespace cont
29 {
30 
31 class BitField;
32 
33 namespace internal
34 {
35 
36 struct StorageTagBitField;
37 
38 struct VTKM_ALWAYS_EXPORT BitFieldMetaData
39 {
40  vtkm::Id NumberOfBits = 0;
41 };
42 
43 }
44 
45 namespace detail
46 {
47 
48 struct BitFieldTraits
49 {
50  // Allocations will occur in blocks of BlockSize bytes. This ensures that
51  // power-of-two word sizes up to BlockSize will not access invalid data
52  // during word-based access, and that atomic values will be properly aligned.
53  // We use the default StorageBasic alignment for this.
54  constexpr static vtkm::Id BlockSize = VTKM_ALLOCATION_ALIGNMENT;
55 
56  // Make sure the blocksize is at least 64. Eventually we may implement SIMD
57  // bit operations, and the current largest vector width is 512 bits.
58  VTKM_STATIC_ASSERT(BlockSize >= 64);
59 
61  template <typename WordType>
62  using IsValidWordType =
63  std::integral_constant<bool,
64  /* is unsigned */
65  std::is_unsigned<WordType>::value &&
66  /* doesn't exceed blocksize */
67  sizeof(WordType) <= static_cast<size_t>(BlockSize) &&
68  /* BlockSize is a multiple of WordType */
69  static_cast<size_t>(BlockSize) % sizeof(WordType) == 0>;
70 
73  template <typename WordType>
74  using IsValidWordTypeAtomic =
75  std::integral_constant<bool,
76  /* is unsigned */
77  std::is_unsigned<WordType>::value &&
78  /* doesn't exceed blocksize */
79  sizeof(WordType) <= static_cast<size_t>(BlockSize) &&
80  /* BlockSize is a multiple of WordType */
81  static_cast<size_t>(BlockSize) % sizeof(WordType) == 0 &&
82  /* Supported by atomic interface */
84 };
85 
88 struct BitCoordinate
89 {
91  vtkm::Id WordIndex;
92 
94  vtkm::Int32 BitOffset; // [0, bitsInWord)
95 };
96 
100 template <bool IsConst>
101 class BitPortalBase
102 {
103  // Checks if PortalType has a GetIteratorBegin() method that returns a
104  // pointer.
105  template <typename PortalType,
106  typename PointerType = decltype(std::declval<PortalType>().GetIteratorBegin())>
107  struct HasPointerAccess : public std::is_pointer<PointerType>
108  {
109  };
110 
111  // Determine whether we should store a const vs. mutable pointer:
112  template <typename T>
113  using MaybeConstPointer = typename std::conditional<IsConst, T const*, T*>::type;
114  using BufferType = MaybeConstPointer<void>; // void* or void const*, as appropriate
115 
116 public:
118  using WordTypePreferred = vtkm::AtomicTypePreferred;
119 
121  template <typename WordType>
122  using IsValidWordType = BitFieldTraits::IsValidWordType<WordType>;
123 
125  template <typename WordType>
126  using IsValidWordTypeAtomic = BitFieldTraits::IsValidWordTypeAtomic<WordType>;
127 
128  VTKM_STATIC_ASSERT_MSG(IsValidWordType<WordTypeDefault>::value,
129  "Internal error: Default word type is invalid.");
130  VTKM_STATIC_ASSERT_MSG(IsValidWordType<WordTypePreferred>::value,
131  "Device-specific fast word type is invalid.");
132 
133  VTKM_STATIC_ASSERT_MSG(IsValidWordTypeAtomic<WordTypeDefault>::value,
134  "Internal error: Default word type is invalid.");
135  VTKM_STATIC_ASSERT_MSG(IsValidWordTypeAtomic<WordTypePreferred>::value,
136  "Device-specific fast word type is invalid for atomic operations.");
137 
138 protected:
139  friend class vtkm::cont::BitField;
140  friend class vtkm::cont::internal::Storage<bool, vtkm::cont::internal::StorageTagBitField>;
141 
143  VTKM_CONT BitPortalBase(BufferType rawArray, vtkm::Id numberOfBits)
144  : Data{ rawArray }
145  , NumberOfBits{ numberOfBits }
146  {
147  }
148 
149 public:
150  BitPortalBase() noexcept = default;
151  BitPortalBase(const BitPortalBase&) noexcept = default;
152  BitPortalBase(BitPortalBase&&) noexcept = default;
153  BitPortalBase& operator=(const BitPortalBase&) noexcept = default;
154  BitPortalBase& operator=(BitPortalBase&&) noexcept = default;
155 
158  vtkm::Id GetNumberOfBits() const noexcept { return this->NumberOfBits; }
159 
163  template <typename WordType = WordTypePreferred>
164  VTKM_EXEC_CONT vtkm::Id GetNumberOfWords() const noexcept
165  {
166  VTKM_STATIC_ASSERT(IsValidWordType<WordType>::value);
167  static constexpr vtkm::Id WordSize = static_cast<vtkm::Id>(sizeof(WordType));
168  static constexpr vtkm::Id WordBits = WordSize * CHAR_BIT;
169  return (this->NumberOfBits + WordBits - 1) / WordBits;
170  }
171 
174  template <typename WordType = WordTypePreferred>
175  VTKM_EXEC_CONT WordType GetFinalWordMask() const noexcept
176  {
177  if (this->NumberOfBits == 0)
178  {
179  return WordType{ 0 };
180  }
181 
182  static constexpr vtkm::Int32 BitsPerWord =
183  static_cast<vtkm::Int32>(sizeof(WordType) * CHAR_BIT);
184 
185  const auto maxBit = this->NumberOfBits - 1;
186  const auto coord = this->GetBitCoordinateFromIndex<WordType>(maxBit);
187  const vtkm::Int32 shift = BitsPerWord - coord.BitOffset - 1;
188  return (~WordType{ 0 }) >> shift;
189  }
190 
193  template <typename WordType = WordTypePreferred>
194  VTKM_EXEC_CONT static BitCoordinate GetBitCoordinateFromIndex(vtkm::Id bitIdx) noexcept
195  {
196  VTKM_STATIC_ASSERT(IsValidWordType<WordType>::value);
197  static constexpr vtkm::Id BitsPerWord = static_cast<vtkm::Id>(sizeof(WordType) * CHAR_BIT);
198  return { static_cast<vtkm::Id>(bitIdx / BitsPerWord),
199  static_cast<vtkm::Int32>(bitIdx % BitsPerWord) };
200  }
201 
207  void SetBit(vtkm::Id bitIdx, bool val) const noexcept
208  {
209  VTKM_STATIC_ASSERT_MSG(!IsConst, "'Set' method called on const BitField portal.");
210  using WordType = WordTypePreferred;
211  const auto coord = this->GetBitCoordinateFromIndex<WordType>(bitIdx);
212  const auto mask = WordType(1) << coord.BitOffset;
213  WordType* wordAddr = this->GetWordAddress<WordType>(coord.WordIndex);
214  if (val)
215  {
216  *wordAddr |= mask;
217  }
218  else
219  {
220  *wordAddr &= ~mask;
221  }
222  }
223 
227  void SetBitAtomic(vtkm::Id bitIdx, bool val) const
228  {
229  VTKM_STATIC_ASSERT_MSG(!IsConst, "'Set' method called on const BitField portal.");
230  using WordType = WordTypePreferred;
231  const auto coord = this->GetBitCoordinateFromIndex<WordType>(bitIdx);
232  const auto mask = WordType(1) << coord.BitOffset;
233  if (val)
234  {
235  this->OrWordAtomic(coord.WordIndex, mask);
236  }
237  else
238  {
239  this->AndWordAtomic(coord.WordIndex, ~mask);
240  }
241  }
242 
246  bool GetBit(vtkm::Id bitIdx) const noexcept
247  {
248  using WordType = WordTypePreferred;
249  const auto coord = this->GetBitCoordinateFromIndex<WordType>(bitIdx);
250  const auto word = this->GetWord<WordType>(coord.WordIndex);
251  const auto mask = WordType(1) << coord.BitOffset;
252  return (word & mask) != WordType(0);
253  }
254 
259  bool GetBitAtomic(vtkm::Id bitIdx) const
260  {
261  using WordType = WordTypePreferred;
262  const auto coord = this->GetBitCoordinateFromIndex<WordType>(bitIdx);
263  const auto word = this->GetWordAtomic<WordType>(coord.WordIndex);
264  const auto mask = WordType(1) << coord.BitOffset;
265  return (word & mask) != WordType(0);
266  }
267 
270  template <typename WordType = WordTypePreferred>
271  VTKM_EXEC_CONT void SetWord(vtkm::Id wordIdx, WordType word) const noexcept
272  {
273  VTKM_STATIC_ASSERT_MSG(!IsConst, "'Set' method called on const BitField portal.");
274  *this->GetWordAddress<WordType>(wordIdx) = word;
275  }
276 
279  template <typename WordType = WordTypePreferred>
280  VTKM_EXEC_CONT void SetWordAtomic(vtkm::Id wordIdx, WordType word) const
281  {
282  VTKM_STATIC_ASSERT_MSG(!IsConst, "'Set' method called on const BitField portal.");
283  VTKM_STATIC_ASSERT_MSG(IsValidWordTypeAtomic<WordType>::value,
284  "Requested WordType does not support atomic"
285  " operations on target execution platform.");
286  vtkm::AtomicStore(this->GetWordAddress<WordType>(wordIdx), word);
287  }
288 
291  template <typename WordType = WordTypePreferred>
292  VTKM_EXEC_CONT WordType GetWord(vtkm::Id wordIdx) const noexcept
293  {
294  return *this->GetWordAddress<WordType>(wordIdx);
295  }
296 
299  template <typename WordType = WordTypePreferred>
300  VTKM_EXEC_CONT WordType GetWordAtomic(vtkm::Id wordIdx) const
301  {
302  VTKM_STATIC_ASSERT_MSG(IsValidWordTypeAtomic<WordType>::value,
303  "Requested WordType does not support atomic"
304  " operations on target execution platform.");
305  return vtkm::AtomicLoad(this->GetWordAddress<WordType>(wordIdx));
306  }
307 
311  bool NotBitAtomic(vtkm::Id bitIdx) const
312  {
313  VTKM_STATIC_ASSERT_MSG(!IsConst, "Attempt to modify const BitField portal.");
314  using WordType = WordTypePreferred;
315  const auto coord = this->GetBitCoordinateFromIndex<WordType>(bitIdx);
316  const auto mask = WordType(1) << coord.BitOffset;
317  const auto oldWord = this->XorWordAtomic(coord.WordIndex, mask);
318  return (oldWord & mask) != WordType(0);
319  }
320 
323  template <typename WordType = WordTypePreferred>
324  VTKM_EXEC_CONT WordType NotWordAtomic(vtkm::Id wordIdx) const
325  {
326  VTKM_STATIC_ASSERT_MSG(!IsConst, "Attempt to modify const BitField portal.");
327  VTKM_STATIC_ASSERT_MSG(IsValidWordTypeAtomic<WordType>::value,
328  "Requested WordType does not support atomic"
329  " operations on target execution platform.");
330  WordType* addr = this->GetWordAddress<WordType>(wordIdx);
331  return vtkm::AtomicNot(addr);
332  }
333 
338  bool AndBitAtomic(vtkm::Id bitIdx, bool val) const
339  {
340  VTKM_STATIC_ASSERT_MSG(!IsConst, "Attempt to modify const BitField portal.");
341  using WordType = WordTypePreferred;
342  const auto coord = this->GetBitCoordinateFromIndex<WordType>(bitIdx);
343  const auto bitmask = WordType(1) << coord.BitOffset;
344  // wordmask is all 1's, except for BitOffset which is (val ? 1 : 0)
345  const auto wordmask = val ? ~WordType(0) : ~bitmask;
346  const auto oldWord = this->AndWordAtomic(coord.WordIndex, wordmask);
347  return (oldWord & bitmask) != WordType(0);
348  }
349 
353  template <typename WordType = WordTypePreferred>
354  VTKM_EXEC_CONT WordType AndWordAtomic(vtkm::Id wordIdx, WordType wordmask) const
355  {
356  VTKM_STATIC_ASSERT_MSG(!IsConst, "Attempt to modify const BitField portal.");
357  VTKM_STATIC_ASSERT_MSG(IsValidWordTypeAtomic<WordType>::value,
358  "Requested WordType does not support atomic"
359  " operations on target execution platform.");
360  WordType* addr = this->GetWordAddress<WordType>(wordIdx);
361  return vtkm::AtomicAnd(addr, wordmask);
362  }
363 
368  bool OrBitAtomic(vtkm::Id bitIdx, bool val) const
369  {
370  VTKM_STATIC_ASSERT_MSG(!IsConst, "Attempt to modify const BitField portal.");
371  using WordType = WordTypePreferred;
372  const auto coord = this->GetBitCoordinateFromIndex<WordType>(bitIdx);
373  const auto bitmask = WordType(1) << coord.BitOffset;
374  // wordmask is all 0's, except for BitOffset which is (val ? 1 : 0)
375  const auto wordmask = val ? bitmask : WordType(0);
376  const auto oldWord = this->OrWordAtomic(coord.WordIndex, wordmask);
377  return (oldWord & bitmask) != WordType(0);
378  }
379 
383  template <typename WordType = WordTypePreferred>
384  VTKM_EXEC_CONT WordType OrWordAtomic(vtkm::Id wordIdx, WordType wordmask) const
385  {
386  VTKM_STATIC_ASSERT_MSG(!IsConst, "Attempt to modify const BitField portal.");
387  VTKM_STATIC_ASSERT_MSG(IsValidWordTypeAtomic<WordType>::value,
388  "Requested WordType does not support atomic"
389  " operations on target execution platform.");
390  WordType* addr = this->GetWordAddress<WordType>(wordIdx);
391  return vtkm::AtomicOr(addr, wordmask);
392  }
393 
398  bool XorBitAtomic(vtkm::Id bitIdx, bool val) const
399  {
400  VTKM_STATIC_ASSERT_MSG(!IsConst, "Attempt to modify const BitField portal.");
401  using WordType = WordTypePreferred;
402  const auto coord = this->GetBitCoordinateFromIndex<WordType>(bitIdx);
403  const auto bitmask = WordType(1) << coord.BitOffset;
404  // wordmask is all 0's, except for BitOffset which is (val ? 1 : 0)
405  const auto wordmask = val ? bitmask : WordType(0);
406  const auto oldWord = this->XorWordAtomic(coord.WordIndex, wordmask);
407  return (oldWord & bitmask) != WordType(0);
408  }
409 
413  template <typename WordType = WordTypePreferred>
414  VTKM_EXEC_CONT WordType XorWordAtomic(vtkm::Id wordIdx, WordType wordmask) const
415  {
416  VTKM_STATIC_ASSERT_MSG(!IsConst, "Attempt to modify const BitField portal.");
417  VTKM_STATIC_ASSERT_MSG(IsValidWordTypeAtomic<WordType>::value,
418  "Requested WordType does not support atomic"
419  " operations on target execution platform.");
420  WordType* addr = this->GetWordAddress<WordType>(wordIdx);
421  return vtkm::AtomicXor(addr, wordmask);
422  }
423 
431  bool CompareExchangeBitAtomic(vtkm::Id bitIdx, bool* oldBit, bool newBit) const
432  {
433  VTKM_STATIC_ASSERT_MSG(!IsConst, "Attempt to modify const BitField portal.");
434  using WordType = WordTypePreferred;
435  const auto coord = this->GetBitCoordinateFromIndex<WordType>(bitIdx);
436  const auto bitmask = WordType(1) << coord.BitOffset;
437 
438  WordType oldWord = this->GetWord<WordType>(coord.WordIndex);
439  do
440  {
441  bool actualBit = (oldWord & bitmask) != WordType(0);
442  if (actualBit != *oldBit)
443  { // The bit-of-interest does not match what we expected.
444  *oldBit = actualBit;
445  return false;
446  }
447  else if (actualBit == newBit)
448  { // The bit hasn't changed, but also already matches newVal. We're done.
449  return true;
450  }
451 
452  // Attempt to update the word with a compare-exchange in the loop condition.
453  // If the old word changed since last queried, oldWord will get updated and
454  // the loop will continue until it succeeds.
455  } while (!this->CompareExchangeWordAtomic(coord.WordIndex, &oldWord, oldWord ^ bitmask));
456 
457  return true;
458  }
459 
466  template <typename WordType = WordTypePreferred>
467  VTKM_EXEC_CONT bool CompareExchangeWordAtomic(vtkm::Id wordIdx,
468  WordType* oldWord,
469  WordType newWord) const
470  {
471  VTKM_STATIC_ASSERT_MSG(!IsConst, "Attempt to modify const BitField portal.");
472  VTKM_STATIC_ASSERT_MSG(IsValidWordTypeAtomic<WordType>::value,
473  "Requested WordType does not support atomic"
474  " operations on target execution platform.");
475  WordType* addr = this->GetWordAddress<WordType>(wordIdx);
476  return vtkm::AtomicCompareExchange(addr, oldWord, newWord);
477  }
478 
479 private:
480  template <typename WordType>
481  VTKM_EXEC_CONT MaybeConstPointer<WordType> GetWordAddress(vtkm::Id wordId) const noexcept
482  {
483  VTKM_STATIC_ASSERT(IsValidWordType<WordType>::value);
484  return reinterpret_cast<MaybeConstPointer<WordType>>(this->Data) + wordId;
485  }
486 
487  BufferType Data{ nullptr };
488  vtkm::Id NumberOfBits{ 0 };
489 };
490 
491 using BitPortal = BitPortalBase<false>;
492 
493 using BitPortalConst = BitPortalBase<true>;
494 
495 } // end namespace detail
496 
498 {
499  static constexpr vtkm::Id BlockSize = detail::BitFieldTraits::BlockSize;
500 
501 public:
503  using WritePortalType = detail::BitPortal;
504 
506  using ReadPortalType = detail::BitPortalConst;
507 
509 
510  template <typename Device>
512  {
515 
517  using Portal = detail::BitPortal;
518 
520  using PortalConst = detail::BitPortalConst;
521  };
522 
524  template <typename WordType>
525  using IsValidWordType = detail::BitFieldTraits::IsValidWordType<WordType>;
526 
528  template <typename WordType, typename Device = void>
529  using IsValidWordTypeAtomic = detail::BitFieldTraits::IsValidWordTypeAtomic<WordType>;
530 
532  VTKM_CONT BitField(const BitField&) = default;
533  VTKM_CONT BitField(BitField&&) noexcept = default;
534  VTKM_CONT ~BitField() = default;
535  VTKM_CONT BitField& operator=(const BitField&) = default;
536  VTKM_CONT BitField& operator=(BitField&&) noexcept = default;
537 
538  VTKM_CONT
539  bool operator==(const BitField& rhs) const { return this->Buffer == rhs.Buffer; }
540 
541  VTKM_CONT
542  bool operator!=(const BitField& rhs) const { return this->Buffer != rhs.Buffer; }
543 
545  VTKM_CONT vtkm::cont::internal::Buffer GetBuffer() const { return this->Buffer; }
546 
548  VTKM_CONT vtkm::Id GetNumberOfBits() const;
549 
552  template <typename WordType>
554  {
556  static constexpr vtkm::Id WordBits = static_cast<vtkm::Id>(sizeof(WordType) * CHAR_BIT);
557  return (this->GetNumberOfBits() + WordBits - 1) / WordBits;
558  }
559 
561  VTKM_CONT void Allocate(vtkm::Id numberOfBits,
562  vtkm::CopyFlag preserve,
563  vtkm::cont::Token& token) const;
564 
566  VTKM_CONT void Allocate(vtkm::Id numberOfBits,
567  vtkm::CopyFlag preserve = vtkm::CopyFlag::Off) const
568  {
569  vtkm::cont::Token token;
570  this->Allocate(numberOfBits, preserve, token);
571  }
572 
574  template <typename ValueType>
575  VTKM_CONT void AllocateAndFill(vtkm::Id numberOfBits,
576  ValueType value,
577  vtkm::cont::Token& token) const
578  {
579  this->Allocate(numberOfBits, vtkm::CopyFlag::Off, token);
580  this->Fill(value, token);
581  }
582  template <typename ValueType>
583  VTKM_CONT void AllocateAndFill(vtkm::Id numberOfBits, ValueType value) const
584  {
585  vtkm::cont::Token token;
586  this->AllocateAndFill(numberOfBits, value, token);
587  }
588 
589 private:
590  VTKM_CONT void FillImpl(const void* word,
591  vtkm::BufferSizeType wordSize,
592  vtkm::cont::Token& token) const;
593 
594 public:
596  template <typename WordType>
597  VTKM_CONT void Fill(WordType word, vtkm::cont::Token& token) const
598  {
599  this->FillImpl(&word, static_cast<vtkm::BufferSizeType>(sizeof(WordType)), token);
600  }
601  template <typename WordType>
602  VTKM_CONT void Fill(WordType word) const
603  {
604  vtkm::cont::Token token;
605  this->Fill(word, token);
606  }
607 
609  VTKM_CONT void Fill(bool value, vtkm::cont::Token& token) const
610  {
611  using WordType = WordTypePreferred;
612  this->Fill(value ? ~WordType{ 0 } : WordType{ 0 }, token);
613  }
614  VTKM_CONT void Fill(bool value) const
615  {
616  vtkm::cont::Token token;
617  this->Fill(value, token);
618  }
619 
621  VTKM_CONT void ReleaseResourcesExecution();
622 
624  VTKM_CONT void ReleaseResources();
625 
627  VTKM_CONT void SyncControlArray() const;
628 
632  VTKM_CONT bool IsOnDevice(vtkm::cont::DeviceAdapterId device) const;
633 
637  VTKM_CONT bool IsOnHost() const
638  {
639  return this->IsOnDevice(vtkm::cont::DeviceAdapterTagUndefined{});
640  }
641 
645  VTKM_CONT WritePortalType WritePortal() const;
646 
650  VTKM_CONT ReadPortalType ReadPortal() const;
651 
657  VTKM_CONT ReadPortalType PrepareForInput(vtkm::cont::DeviceAdapterId device,
658  vtkm::cont::Token& token) const;
659 
666  VTKM_CONT WritePortalType PrepareForOutput(vtkm::Id numBits,
668  vtkm::cont::Token& token) const;
669 
675  VTKM_CONT WritePortalType PrepareForInPlace(vtkm::cont::DeviceAdapterId device,
676  vtkm::cont::Token& token) const;
677 
678 private:
679  mutable vtkm::cont::internal::Buffer Buffer;
680 };
681 }
682 } // end namespace vtkm::cont
683 
684 #endif // vtk_m_cont_BitField_h
vtkm::cont::BitField::operator!=
bool operator!=(const BitField &rhs) const
Definition: BitField.h:542
vtkm::cont::BitField::ReadPortalType
detail::BitPortalConst ReadPortalType
A read-only BitPortal used in the control environment.
Definition: BitField.h:506
vtkm::cont::BitField::IsValidWordTypeAtomic
detail::BitFieldTraits::IsValidWordTypeAtomic< WordType > IsValidWordTypeAtomic
Check whether a word type is valid for atomic operations.
Definition: BitField.h:529
Atomic.h
ArrayHandle.h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::AtomicLoad
T AtomicLoad(T *const pointer, vtkm::MemoryOrder order=vtkm::MemoryOrder::Acquire)
Atomic function to load a value from a shared memory location.
Definition: Atomic.h:786
vtkm::cont::BitField::Buffer
vtkm::cont::internal::Buffer Buffer
Definition: BitField.h:679
Types.h
VTKM_EXEC_CONT
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
vtkm::BufferSizeType
vtkm::Int64 BufferSizeType
Definition: DeviceAdapterMemoryManager.h:27
vtkm::AtomicNot
T AtomicNot(T *pointer, vtkm::MemoryOrder order=vtkm::MemoryOrder::SequentiallyConsistent)
Atomic function to NOT bits to a shared memory location.
Definition: Atomic.h:946
vtkm::cont::BitField::AllocateAndFill
void AllocateAndFill(vtkm::Id numberOfBits, ValueType value) const
Definition: BitField.h:583
vtkm::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::cont::BitField::Fill
void Fill(bool value, vtkm::cont::Token &token) const
Set all the bits to the given value.
Definition: BitField.h:609
vtkm::cont::BitField::GetNumberOfWords
vtkm::Id GetNumberOfWords() const
Return the number of words (of WordType) stored in this bit fields.
Definition: BitField.h:553
VTKM_STATIC_ASSERT
#define VTKM_STATIC_ASSERT(condition)
Definition: StaticAssert.h:16
vtkm::AtomicXor
T AtomicXor(T *pointer, T operand, vtkm::MemoryOrder order=vtkm::MemoryOrder::SequentiallyConsistent)
Atomic function to XOR bits to a shared memory location.
Definition: Atomic.h:919
vtkm::ListHas
typename detail::ListHasImpl< List, T >::type ListHas
Checks to see if the given T is in the list pointed to by List.
Definition: List.h:577
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::BitField::GetBuffer
vtkm::cont::internal::Buffer GetBuffer() const
Return the internal Buffer used to store the BitField.
Definition: BitField.h:545
vtkm::cont::BitField::Fill
void Fill(WordType word, vtkm::cont::Token &token) const
Set subsequent words to the given word of bits.
Definition: BitField.h:597
vtkm::cont::BitField::ExecutionTypes::PortalConst
detail::BitPortalConst PortalConst
A read-only BitPortal that is usable on the specified device.
Definition: BitField.h:520
vtkm_cont_export.h
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::Id
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
vtkm::cont::BitField::IsOnHost
bool IsOnHost() const
Returns true if the BitField's data is on the host.
Definition: BitField.h:637
vtkm::cont::BitField::WritePortalType
detail::BitPortal WritePortalType
The BitPortal used in the control environment.
Definition: BitField.h:503
vtkm::cont::BitField::WordTypePreferred
vtkm::AtomicTypePreferred WordTypePreferred
Definition: BitField.h:508
vtkm::AtomicTypePreferred
vtkm::UInt32 AtomicTypePreferred
The preferred type to use for atomic operations.
Definition: Atomic.h:768
VTKM_ALLOCATION_ALIGNMENT
#define VTKM_ALLOCATION_ALIGNMENT
Definition: Configure.h:108
vtkm::cont::DeviceAdapterId
An object used to specify a device.
Definition: DeviceAdapterTag.h:58
vtkm::cont::BitField::IsValidWordType
detail::BitFieldTraits::IsValidWordType< WordType > IsValidWordType
Check whether a word type is valid for non-atomic operations.
Definition: BitField.h:525
vtkm::CopyFlag::Off
@ Off
vtkm::cont::BitField
Definition: BitField.h:497
vtkm::AtomicOr
T AtomicOr(T *pointer, T operand, vtkm::MemoryOrder order=vtkm::MemoryOrder::SequentiallyConsistent)
Atomic function to OR bits to a shared memory location.
Definition: Atomic.h:892
vtkm::cont::DeviceAdapterTagUndefined
Tag for a device adapter used to avoid specifying a device.
Definition: DeviceAdapterTag.h:187
vtkm::Int32
int32_t Int32
Base type to use for 32-bit signed integer numbers.
Definition: Types.h:181
vtkm::CopyFlag
CopyFlag
Identifier used to specify whether a function should deep copy data.
Definition: Flags.h:17
vtkm::cont::BitField::Fill
void Fill(bool value) const
Definition: BitField.h:614
vtkm::AtomicCompareExchange
bool AtomicCompareExchange(T *shared, T *expected, T desired, vtkm::MemoryOrder order=vtkm::MemoryOrder::SequentiallyConsistent)
Atomic function that replaces a value given a condition.
Definition: Atomic.h:976
vtkm::cont::BitField::Fill
void Fill(WordType word) const
Definition: BitField.h:602
vtkm::cont::BitField::AllocateAndFill
void AllocateAndFill(vtkm::Id numberOfBits, ValueType value, vtkm::cont::Token &token) const
Allocate the requested number of bits and fill with the requested bit or word.
Definition: BitField.h:575
VTKM_ALWAYS_EXPORT
#define VTKM_ALWAYS_EXPORT
Definition: ExportMacros.h:89
vtkm::cont::BitField::ExecutionTypes
Definition: BitField.h:511
vtkm::cont::BitField::Allocate
void Allocate(vtkm::Id numberOfBits, vtkm::CopyFlag preserve=vtkm::CopyFlag::Off) const
Allocate the requested number of bits.
Definition: BitField.h:566
vtkm::AtomicAnd
T AtomicAnd(T *pointer, T operand, vtkm::MemoryOrder order=vtkm::MemoryOrder::SequentiallyConsistent)
Atomic function to AND bits to a shared memory location.
Definition: Atomic.h:860
vtkm::cont::BitField::ExecutionTypes::Portal
detail::BitPortal Portal
A BitPortal that is usable on the specified device.
Definition: BitField.h:517
List.h
vtkm::cont::BitField::ExecutionTypes::WordTypePreferred
vtkm::AtomicTypePreferred WordTypePreferred
The preferred word type used by the specified device.
Definition: BitField.h:514
vtkm::AtomicStore
void AtomicStore(T *pointer, T value, vtkm::MemoryOrder order=vtkm::MemoryOrder::Release)
Atomic function to save a value to a shared memory location.
Definition: Atomic.h:800