Viskores  1.0
BitField.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 
19 #ifndef viskores_cont_BitField_h
20 #define viskores_cont_BitField_h
21 
24 
25 #include <viskores/Atomic.h>
26 #include <viskores/List.h>
27 #include <viskores/Types.h>
28 
29 #include <cassert>
30 #include <climits>
31 #include <memory>
32 #include <type_traits>
33 
34 namespace viskores
35 {
36 namespace cont
37 {
38 
39 class BitField;
40 
41 namespace internal
42 {
43 
44 struct StorageTagBitField;
45 
46 struct VISKORES_ALWAYS_EXPORT BitFieldMetaData
47 {
48  viskores::Id NumberOfBits = 0;
49 };
50 
51 }
52 
53 namespace detail
54 {
55 
56 struct BitFieldTraits
57 {
58  // Allocations will occur in blocks of BlockSize bytes. This ensures that
59  // power-of-two word sizes up to BlockSize will not access invalid data
60  // during word-based access, and that atomic values will be properly aligned.
61  // We use the default StorageBasic alignment for this.
62  constexpr static viskores::Id BlockSize = VISKORES_ALLOCATION_ALIGNMENT;
63 
64  // Make sure the blocksize is at least 64. Eventually we may implement SIMD
65  // bit operations, and the current largest vector width is 512 bits.
66  VISKORES_STATIC_ASSERT(BlockSize >= 64);
67 
69  template <typename WordType>
70  using IsValidWordType =
71  std::integral_constant<bool,
72  /* is unsigned */
73  std::is_unsigned<WordType>::value &&
74  /* doesn't exceed blocksize */
75  sizeof(WordType) <= static_cast<size_t>(BlockSize) &&
76  /* BlockSize is a multiple of WordType */
77  static_cast<size_t>(BlockSize) % sizeof(WordType) == 0>;
78 
81  template <typename WordType>
82  using IsValidWordTypeAtomic =
83  std::integral_constant<bool,
84  /* is unsigned */
85  std::is_unsigned<WordType>::value &&
86  /* doesn't exceed blocksize */
87  sizeof(WordType) <= static_cast<size_t>(BlockSize) &&
88  /* BlockSize is a multiple of WordType */
89  static_cast<size_t>(BlockSize) % sizeof(WordType) == 0 &&
90  /* Supported by atomic interface */
92 };
93 
96 struct BitCoordinate
97 {
99  viskores::Id WordIndex;
100 
102  viskores::Int32 BitOffset; // [0, bitsInWord)
103 };
104 
108 template <bool IsConst>
109 class BitPortalBase
110 {
111  // Checks if PortalType has a GetIteratorBegin() method that returns a
112  // pointer.
113  template <typename PortalType,
114  typename PointerType = decltype(std::declval<PortalType>().GetIteratorBegin())>
115  struct HasPointerAccess : public std::is_pointer<PointerType>
116  {
117  };
118 
119  // Determine whether we should store a const vs. mutable pointer:
120  template <typename T>
121  using MaybeConstPointer = typename std::conditional<IsConst, T const*, T*>::type;
122  using BufferType = MaybeConstPointer<void>; // void* or void const*, as appropriate
123 
124 public:
126  using WordTypePreferred = viskores::AtomicTypePreferred;
127 
129  template <typename WordType>
130  using IsValidWordType = BitFieldTraits::IsValidWordType<WordType>;
131 
133  template <typename WordType>
134  using IsValidWordTypeAtomic = BitFieldTraits::IsValidWordTypeAtomic<WordType>;
135 
136  VISKORES_STATIC_ASSERT_MSG(IsValidWordType<WordTypeDefault>::value,
137  "Internal error: Default word type is invalid.");
138  VISKORES_STATIC_ASSERT_MSG(IsValidWordType<WordTypePreferred>::value,
139  "Device-specific fast word type is invalid.");
140 
141  VISKORES_STATIC_ASSERT_MSG(IsValidWordTypeAtomic<WordTypeDefault>::value,
142  "Internal error: Default word type is invalid.");
143  VISKORES_STATIC_ASSERT_MSG(IsValidWordTypeAtomic<WordTypePreferred>::value,
144  "Device-specific fast word type is invalid for atomic operations.");
145 
146 protected:
147  friend class viskores::cont::BitField;
148  friend class viskores::cont::internal::Storage<bool,
149  viskores::cont::internal::StorageTagBitField>;
150 
152  VISKORES_CONT BitPortalBase(BufferType rawArray, viskores::Id numberOfBits)
153  : Data{ rawArray }
154  , NumberOfBits{ numberOfBits }
155  {
156  }
157 
158 public:
159  BitPortalBase() noexcept = default;
160  BitPortalBase(const BitPortalBase&) noexcept = default;
161  BitPortalBase(BitPortalBase&&) noexcept = default;
162  BitPortalBase& operator=(const BitPortalBase&) noexcept = default;
163  BitPortalBase& operator=(BitPortalBase&&) noexcept = default;
164 
167  viskores::Id GetNumberOfBits() const noexcept { return this->NumberOfBits; }
168 
172  template <typename WordType = WordTypePreferred>
173  VISKORES_EXEC_CONT viskores::Id GetNumberOfWords() const noexcept
174  {
175  VISKORES_STATIC_ASSERT(IsValidWordType<WordType>::value);
176  static constexpr viskores::Id WordSize = static_cast<viskores::Id>(sizeof(WordType));
177  static constexpr viskores::Id WordBits = WordSize * CHAR_BIT;
178  return (this->NumberOfBits + WordBits - 1) / WordBits;
179  }
180 
183  template <typename WordType = WordTypePreferred>
184  VISKORES_EXEC_CONT WordType GetFinalWordMask() const noexcept
185  {
186  if (this->NumberOfBits == 0)
187  {
188  return WordType{ 0 };
189  }
190 
191  static constexpr viskores::Int32 BitsPerWord =
192  static_cast<viskores::Int32>(sizeof(WordType) * CHAR_BIT);
193 
194  const auto maxBit = this->NumberOfBits - 1;
195  const auto coord = this->GetBitCoordinateFromIndex<WordType>(maxBit);
196  const viskores::Int32 shift = BitsPerWord - coord.BitOffset - 1;
197  return (~WordType{ 0 }) >> shift;
198  }
199 
202  template <typename WordType = WordTypePreferred>
203  VISKORES_EXEC_CONT static BitCoordinate GetBitCoordinateFromIndex(viskores::Id bitIdx) noexcept
204  {
205  VISKORES_STATIC_ASSERT(IsValidWordType<WordType>::value);
206  static constexpr viskores::Id BitsPerWord =
207  static_cast<viskores::Id>(sizeof(WordType) * CHAR_BIT);
208  return { static_cast<viskores::Id>(bitIdx / BitsPerWord),
209  static_cast<viskores::Int32>(bitIdx % BitsPerWord) };
210  }
211 
217  void SetBit(viskores::Id bitIdx, bool val) const noexcept
218  {
219  VISKORES_STATIC_ASSERT_MSG(!IsConst, "'Set' method called on const BitField portal.");
220  using WordType = WordTypePreferred;
221  const auto coord = this->GetBitCoordinateFromIndex<WordType>(bitIdx);
222  const auto mask = WordType(1) << coord.BitOffset;
223  WordType* wordAddr = this->GetWordAddress<WordType>(coord.WordIndex);
224  if (val)
225  {
226  *wordAddr |= mask;
227  }
228  else
229  {
230  *wordAddr &= ~mask;
231  }
232  }
233 
237  void SetBitAtomic(viskores::Id bitIdx, bool val) const
238  {
239  VISKORES_STATIC_ASSERT_MSG(!IsConst, "'Set' method called on const BitField portal.");
240  using WordType = WordTypePreferred;
241  const auto coord = this->GetBitCoordinateFromIndex<WordType>(bitIdx);
242  const auto mask = WordType(1) << coord.BitOffset;
243  if (val)
244  {
245  this->OrWordAtomic(coord.WordIndex, mask);
246  }
247  else
248  {
249  this->AndWordAtomic(coord.WordIndex, ~mask);
250  }
251  }
252 
256  bool GetBit(viskores::Id bitIdx) const noexcept
257  {
258  using WordType = WordTypePreferred;
259  const auto coord = this->GetBitCoordinateFromIndex<WordType>(bitIdx);
260  const auto word = this->GetWord<WordType>(coord.WordIndex);
261  const auto mask = WordType(1) << coord.BitOffset;
262  return (word & mask) != WordType(0);
263  }
264 
269  bool GetBitAtomic(viskores::Id bitIdx) const
270  {
271  using WordType = WordTypePreferred;
272  const auto coord = this->GetBitCoordinateFromIndex<WordType>(bitIdx);
273  const auto word = this->GetWordAtomic<WordType>(coord.WordIndex);
274  const auto mask = WordType(1) << coord.BitOffset;
275  return (word & mask) != WordType(0);
276  }
277 
280  template <typename WordType = WordTypePreferred>
281  VISKORES_EXEC_CONT void SetWord(viskores::Id wordIdx, WordType word) const noexcept
282  {
283  VISKORES_STATIC_ASSERT_MSG(!IsConst, "'Set' method called on const BitField portal.");
284  *this->GetWordAddress<WordType>(wordIdx) = word;
285  }
286 
289  template <typename WordType = WordTypePreferred>
290  VISKORES_EXEC_CONT void SetWordAtomic(viskores::Id wordIdx, WordType word) const
291  {
292  VISKORES_STATIC_ASSERT_MSG(!IsConst, "'Set' method called on const BitField portal.");
293  VISKORES_STATIC_ASSERT_MSG(IsValidWordTypeAtomic<WordType>::value,
294  "Requested WordType does not support atomic"
295  " operations on target execution platform.");
296  viskores::AtomicStore(this->GetWordAddress<WordType>(wordIdx), word);
297  }
298 
301  template <typename WordType = WordTypePreferred>
302  VISKORES_EXEC_CONT WordType GetWord(viskores::Id wordIdx) const noexcept
303  {
304  return *this->GetWordAddress<WordType>(wordIdx);
305  }
306 
309  template <typename WordType = WordTypePreferred>
310  VISKORES_EXEC_CONT WordType GetWordAtomic(viskores::Id wordIdx) const
311  {
312  VISKORES_STATIC_ASSERT_MSG(IsValidWordTypeAtomic<WordType>::value,
313  "Requested WordType does not support atomic"
314  " operations on target execution platform.");
315  return viskores::AtomicLoad(this->GetWordAddress<WordType>(wordIdx));
316  }
317 
321  bool NotBitAtomic(viskores::Id bitIdx) const
322  {
323  VISKORES_STATIC_ASSERT_MSG(!IsConst, "Attempt to modify const BitField portal.");
324  using WordType = WordTypePreferred;
325  const auto coord = this->GetBitCoordinateFromIndex<WordType>(bitIdx);
326  const auto mask = WordType(1) << coord.BitOffset;
327  const auto oldWord = this->XorWordAtomic(coord.WordIndex, mask);
328  return (oldWord & mask) != WordType(0);
329  }
330 
333  template <typename WordType = WordTypePreferred>
334  VISKORES_EXEC_CONT WordType NotWordAtomic(viskores::Id wordIdx) const
335  {
336  VISKORES_STATIC_ASSERT_MSG(!IsConst, "Attempt to modify const BitField portal.");
337  VISKORES_STATIC_ASSERT_MSG(IsValidWordTypeAtomic<WordType>::value,
338  "Requested WordType does not support atomic"
339  " operations on target execution platform.");
340  WordType* addr = this->GetWordAddress<WordType>(wordIdx);
341  return viskores::AtomicNot(addr);
342  }
343 
348  bool AndBitAtomic(viskores::Id bitIdx, bool val) const
349  {
350  VISKORES_STATIC_ASSERT_MSG(!IsConst, "Attempt to modify const BitField portal.");
351  using WordType = WordTypePreferred;
352  const auto coord = this->GetBitCoordinateFromIndex<WordType>(bitIdx);
353  const auto bitmask = WordType(1) << coord.BitOffset;
354  // wordmask is all 1's, except for BitOffset which is (val ? 1 : 0)
355  const auto wordmask = val ? ~WordType(0) : ~bitmask;
356  const auto oldWord = this->AndWordAtomic(coord.WordIndex, wordmask);
357  return (oldWord & bitmask) != WordType(0);
358  }
359 
363  template <typename WordType = WordTypePreferred>
364  VISKORES_EXEC_CONT WordType AndWordAtomic(viskores::Id wordIdx, WordType wordmask) const
365  {
366  VISKORES_STATIC_ASSERT_MSG(!IsConst, "Attempt to modify const BitField portal.");
367  VISKORES_STATIC_ASSERT_MSG(IsValidWordTypeAtomic<WordType>::value,
368  "Requested WordType does not support atomic"
369  " operations on target execution platform.");
370  WordType* addr = this->GetWordAddress<WordType>(wordIdx);
371  return viskores::AtomicAnd(addr, wordmask);
372  }
373 
378  bool OrBitAtomic(viskores::Id bitIdx, bool val) const
379  {
380  VISKORES_STATIC_ASSERT_MSG(!IsConst, "Attempt to modify const BitField portal.");
381  using WordType = WordTypePreferred;
382  const auto coord = this->GetBitCoordinateFromIndex<WordType>(bitIdx);
383  const auto bitmask = WordType(1) << coord.BitOffset;
384  // wordmask is all 0's, except for BitOffset which is (val ? 1 : 0)
385  const auto wordmask = val ? bitmask : WordType(0);
386  const auto oldWord = this->OrWordAtomic(coord.WordIndex, wordmask);
387  return (oldWord & bitmask) != WordType(0);
388  }
389 
393  template <typename WordType = WordTypePreferred>
394  VISKORES_EXEC_CONT WordType OrWordAtomic(viskores::Id wordIdx, WordType wordmask) const
395  {
396  VISKORES_STATIC_ASSERT_MSG(!IsConst, "Attempt to modify const BitField portal.");
397  VISKORES_STATIC_ASSERT_MSG(IsValidWordTypeAtomic<WordType>::value,
398  "Requested WordType does not support atomic"
399  " operations on target execution platform.");
400  WordType* addr = this->GetWordAddress<WordType>(wordIdx);
401  return viskores::AtomicOr(addr, wordmask);
402  }
403 
408  bool XorBitAtomic(viskores::Id bitIdx, bool val) const
409  {
410  VISKORES_STATIC_ASSERT_MSG(!IsConst, "Attempt to modify const BitField portal.");
411  using WordType = WordTypePreferred;
412  const auto coord = this->GetBitCoordinateFromIndex<WordType>(bitIdx);
413  const auto bitmask = WordType(1) << coord.BitOffset;
414  // wordmask is all 0's, except for BitOffset which is (val ? 1 : 0)
415  const auto wordmask = val ? bitmask : WordType(0);
416  const auto oldWord = this->XorWordAtomic(coord.WordIndex, wordmask);
417  return (oldWord & bitmask) != WordType(0);
418  }
419 
423  template <typename WordType = WordTypePreferred>
424  VISKORES_EXEC_CONT WordType XorWordAtomic(viskores::Id wordIdx, WordType wordmask) const
425  {
426  VISKORES_STATIC_ASSERT_MSG(!IsConst, "Attempt to modify const BitField portal.");
427  VISKORES_STATIC_ASSERT_MSG(IsValidWordTypeAtomic<WordType>::value,
428  "Requested WordType does not support atomic"
429  " operations on target execution platform.");
430  WordType* addr = this->GetWordAddress<WordType>(wordIdx);
431  return viskores::AtomicXor(addr, wordmask);
432  }
433 
441  bool CompareExchangeBitAtomic(viskores::Id bitIdx, bool* oldBit, bool newBit) const
442  {
443  VISKORES_STATIC_ASSERT_MSG(!IsConst, "Attempt to modify const BitField portal.");
444  using WordType = WordTypePreferred;
445  const auto coord = this->GetBitCoordinateFromIndex<WordType>(bitIdx);
446  const auto bitmask = WordType(1) << coord.BitOffset;
447 
448  WordType oldWord = this->GetWord<WordType>(coord.WordIndex);
449  do
450  {
451  bool actualBit = (oldWord & bitmask) != WordType(0);
452  if (actualBit != *oldBit)
453  { // The bit-of-interest does not match what we expected.
454  *oldBit = actualBit;
455  return false;
456  }
457  else if (actualBit == newBit)
458  { // The bit hasn't changed, but also already matches newVal. We're done.
459  return true;
460  }
461 
462  // Attempt to update the word with a compare-exchange in the loop condition.
463  // If the old word changed since last queried, oldWord will get updated and
464  // the loop will continue until it succeeds.
465  } while (!this->CompareExchangeWordAtomic(coord.WordIndex, &oldWord, oldWord ^ bitmask));
466 
467  return true;
468  }
469 
476  template <typename WordType = WordTypePreferred>
477  VISKORES_EXEC_CONT bool CompareExchangeWordAtomic(viskores::Id wordIdx,
478  WordType* oldWord,
479  WordType newWord) const
480  {
481  VISKORES_STATIC_ASSERT_MSG(!IsConst, "Attempt to modify const BitField portal.");
482  VISKORES_STATIC_ASSERT_MSG(IsValidWordTypeAtomic<WordType>::value,
483  "Requested WordType does not support atomic"
484  " operations on target execution platform.");
485  WordType* addr = this->GetWordAddress<WordType>(wordIdx);
486  return viskores::AtomicCompareExchange(addr, oldWord, newWord);
487  }
488 
489 private:
490  template <typename WordType>
491  VISKORES_EXEC_CONT MaybeConstPointer<WordType> GetWordAddress(viskores::Id wordId) const noexcept
492  {
493  VISKORES_STATIC_ASSERT(IsValidWordType<WordType>::value);
494  return reinterpret_cast<MaybeConstPointer<WordType>>(this->Data) + wordId;
495  }
496 
497  BufferType Data{ nullptr };
498  viskores::Id NumberOfBits{ 0 };
499 };
500 
501 using BitPortal = BitPortalBase<false>;
502 
503 using BitPortalConst = BitPortalBase<true>;
504 
505 } // end namespace detail
506 
507 class VISKORES_CONT_EXPORT BitField
508 {
509  static constexpr viskores::Id BlockSize = detail::BitFieldTraits::BlockSize;
510 
511 public:
513  using WritePortalType = detail::BitPortal;
514 
516  using ReadPortalType = detail::BitPortalConst;
517 
519 
520  template <typename Device>
522  {
525 
527  using Portal = detail::BitPortal;
528 
530  using PortalConst = detail::BitPortalConst;
531  };
532 
534  template <typename WordType>
535  using IsValidWordType = detail::BitFieldTraits::IsValidWordType<WordType>;
536 
538  template <typename WordType, typename Device = void>
539  using IsValidWordTypeAtomic = detail::BitFieldTraits::IsValidWordTypeAtomic<WordType>;
540 
542  VISKORES_CONT BitField(const BitField&) = default;
543  VISKORES_CONT BitField(BitField&&) noexcept = default;
544  VISKORES_CONT ~BitField() = default;
545  VISKORES_CONT BitField& operator=(const BitField&) = default;
546  VISKORES_CONT BitField& operator=(BitField&&) noexcept = default;
547 
549  bool operator==(const BitField& rhs) const { return this->Buffer == rhs.Buffer; }
550 
552  bool operator!=(const BitField& rhs) const { return this->Buffer != rhs.Buffer; }
553 
555  VISKORES_CONT viskores::cont::internal::Buffer GetBuffer() const { return this->Buffer; }
556 
558  VISKORES_CONT viskores::Id GetNumberOfBits() const;
559 
562  template <typename WordType>
564  {
566  static constexpr viskores::Id WordBits = static_cast<viskores::Id>(sizeof(WordType) * CHAR_BIT);
567  return (this->GetNumberOfBits() + WordBits - 1) / WordBits;
568  }
569 
571  VISKORES_CONT void Allocate(viskores::Id numberOfBits,
572  viskores::CopyFlag preserve,
573  viskores::cont::Token& token) const;
574 
578  {
579  viskores::cont::Token token;
580  this->Allocate(numberOfBits, preserve, token);
581  }
582 
584  template <typename ValueType>
586  ValueType value,
587  viskores::cont::Token& token) const
588  {
589  this->Allocate(numberOfBits, viskores::CopyFlag::Off, token);
590  this->Fill(value, token);
591  }
592  template <typename ValueType>
593  VISKORES_CONT void AllocateAndFill(viskores::Id numberOfBits, ValueType value) const
594  {
595  viskores::cont::Token token;
596  this->AllocateAndFill(numberOfBits, value, token);
597  }
598 
599 private:
600  VISKORES_CONT void FillImpl(const void* word,
601  viskores::BufferSizeType wordSize,
602  viskores::cont::Token& token) const;
603 
604 public:
606  template <typename WordType>
607  VISKORES_CONT void Fill(WordType word, viskores::cont::Token& token) const
608  {
609  this->FillImpl(&word, static_cast<viskores::BufferSizeType>(sizeof(WordType)), token);
610  }
611  template <typename WordType>
612  VISKORES_CONT void Fill(WordType word) const
613  {
614  viskores::cont::Token token;
615  this->Fill(word, token);
616  }
617 
619  VISKORES_CONT void Fill(bool value, viskores::cont::Token& token) const
620  {
621  using WordType = WordTypePreferred;
622  this->Fill(value ? ~WordType{ 0 } : WordType{ 0 }, token);
623  }
624  VISKORES_CONT void Fill(bool value) const
625  {
626  viskores::cont::Token token;
627  this->Fill(value, token);
628  }
629 
631  VISKORES_CONT void ReleaseResourcesExecution();
632 
634  VISKORES_CONT void ReleaseResources();
635 
637  VISKORES_CONT void SyncControlArray() const;
638 
642  VISKORES_CONT bool IsOnDevice(viskores::cont::DeviceAdapterId device) const;
643 
647  VISKORES_CONT bool IsOnHost() const
648  {
649  return this->IsOnDevice(viskores::cont::DeviceAdapterTagUndefined{});
650  }
651 
655  VISKORES_CONT WritePortalType WritePortal() const;
656 
660  VISKORES_CONT ReadPortalType ReadPortal() const;
661 
667  VISKORES_CONT ReadPortalType PrepareForInput(viskores::cont::DeviceAdapterId device,
668  viskores::cont::Token& token) const;
669 
676  VISKORES_CONT WritePortalType PrepareForOutput(viskores::Id numBits,
678  viskores::cont::Token& token) const;
679 
685  VISKORES_CONT WritePortalType PrepareForInPlace(viskores::cont::DeviceAdapterId device,
686  viskores::cont::Token& token) const;
687 
688 private:
689  mutable viskores::cont::internal::Buffer Buffer;
690 };
691 }
692 } // end namespace viskores::cont
693 
694 #endif // viskores_cont_BitField_h
viskores::cont::BitField::Fill
void Fill(WordType word) const
Definition: BitField.h:612
Atomic.h
ArrayHandle.h
viskores::cont::BitField::Fill
void Fill(bool value) const
Definition: BitField.h:624
viskores::cont::BitField::AllocateAndFill
void AllocateAndFill(viskores::Id numberOfBits, ValueType value, viskores::cont::Token &token) const
Allocate the requested number of bits and fill with the requested bit or word.
Definition: BitField.h:585
viskores::CopyFlag::Off
@ Off
viskores::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:596
Types.h
viskores::AtomicNot
T AtomicNot(T *pointer, viskores::MemoryOrder order=viskores::MemoryOrder::SequentiallyConsistent)
Atomic function to NOT bits to a shared memory location.
Definition: Atomic.h:974
viskores::cont::BitField::Buffer
viskores::cont::internal::Buffer Buffer
Definition: BitField.h:689
viskores::AtomicTypePreferred
viskores::UInt32 AtomicTypePreferred
The preferred type to use for atomic operations.
Definition: Atomic.h:794
viskores::cont::BitField::ExecutionTypes::WordTypePreferred
viskores::AtomicTypePreferred WordTypePreferred
The preferred word type used by the specified device.
Definition: BitField.h:524
VISKORES_ALLOCATION_ALIGNMENT
#define VISKORES_ALLOCATION_ALIGNMENT
Definition: Configure.h:116
viskores::AtomicStore
void AtomicStore(T *pointer, T value, viskores::MemoryOrder order=viskores::MemoryOrder::Release)
Atomic function to save a value to a shared memory location.
Definition: Atomic.h:827
viskores::AtomicOr
T AtomicOr(T *pointer, T operand, viskores::MemoryOrder order=viskores::MemoryOrder::SequentiallyConsistent)
Atomic function to OR bits to a shared memory location.
Definition: Atomic.h:917
VISKORES_EXEC_CONT
#define VISKORES_EXEC_CONT
Definition: ExportMacros.h:60
viskores::cont::BitField::WritePortalType
detail::BitPortal WritePortalType
The BitPortal used in the control environment.
Definition: BitField.h:513
viskores::AtomicAnd
T AtomicAnd(T *pointer, T operand, viskores::MemoryOrder order=viskores::MemoryOrder::SequentiallyConsistent)
Atomic function to AND bits to a shared memory location.
Definition: Atomic.h:886
viskores::cont::BitField::GetBuffer
viskores::cont::internal::Buffer GetBuffer() const
Return the internal Buffer used to store the BitField.
Definition: BitField.h:555
viskores::Id
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
viskores::cont::BitField::IsValidWordTypeAtomic
detail::BitFieldTraits::IsValidWordTypeAtomic< WordType > IsValidWordTypeAtomic
Check whether a word type is valid for atomic operations.
Definition: BitField.h:539
VISKORES_CONT
#define VISKORES_CONT
Definition: ExportMacros.h:65
viskores::cont::BitField
Definition: BitField.h:507
viskores
Groups connected points that have the same field value.
Definition: Atomic.h:27
viskores::cont::BitField::Fill
void Fill(WordType word, viskores::cont::Token &token) const
Set subsequent words to the given word of bits.
Definition: BitField.h:607
viskores::AtomicCompareExchange
bool AtomicCompareExchange(T *shared, T *expected, T desired, viskores::MemoryOrder order=viskores::MemoryOrder::SequentiallyConsistent)
Atomic function that replaces a value given a condition.
Definition: Atomic.h:1004
viskores::cont::DeviceAdapterTagUndefined
Tag for a device adapter used to avoid specifying a device.
Definition: DeviceAdapterTag.h:201
viskores::cont::BitField::ReadPortalType
detail::BitPortalConst ReadPortalType
A read-only BitPortal used in the control environment.
Definition: BitField.h:516
viskores::BufferSizeType
viskores::Int64 BufferSizeType
Definition: DeviceAdapterMemoryManager.h:35
VISKORES_STATIC_ASSERT_MSG
#define VISKORES_STATIC_ASSERT_MSG(condition, message)
Definition: StaticAssert.h:26
viskores::cont::BitField::WordTypePreferred
viskores::AtomicTypePreferred WordTypePreferred
Definition: BitField.h:518
viskores::AtomicXor
T AtomicXor(T *pointer, T operand, viskores::MemoryOrder order=viskores::MemoryOrder::SequentiallyConsistent)
Atomic function to XOR bits to a shared memory location.
Definition: Atomic.h:947
viskores::cont::DeviceAdapterId
An object used to specify a device.
Definition: DeviceAdapterTag.h:66
viskores::Int32
int32_t Int32
Base type to use for 32-bit signed integer numbers.
Definition: Types.h:189
viskores::cont::BitField::Allocate
void Allocate(viskores::Id numberOfBits, viskores::CopyFlag preserve=viskores::CopyFlag::Off) const
Allocate the requested number of bits.
Definition: BitField.h:576
viskores::cont::BitField::IsValidWordType
detail::BitFieldTraits::IsValidWordType< WordType > IsValidWordType
Check whether a word type is valid for non-atomic operations.
Definition: BitField.h:535
viskores::cont::BitField::IsOnHost
bool IsOnHost() const
Returns true if the BitField's data is on the host.
Definition: BitField.h:647
viskores::cont::BitField::Fill
void Fill(bool value, viskores::cont::Token &token) const
Set all the bits to the given value.
Definition: BitField.h:619
viskores::AtomicLoad
T AtomicLoad(T *const pointer, viskores::MemoryOrder order=viskores::MemoryOrder::Acquire)
Atomic function to load a value from a shared memory location.
Definition: Atomic.h:812
viskores::cont::BitField::ExecutionTypes::PortalConst
detail::BitPortalConst PortalConst
A read-only BitPortal that is usable on the specified device.
Definition: BitField.h:530
viskores::cont::BitField::ExecutionTypes::Portal
detail::BitPortal Portal
A BitPortal that is usable on the specified device.
Definition: BitField.h:527
viskores::CopyFlag
CopyFlag
Identifier used to specify whether a function should deep copy data.
Definition: Flags.h:25
viskores::cont::BitField::AllocateAndFill
void AllocateAndFill(viskores::Id numberOfBits, ValueType value) const
Definition: BitField.h:593
viskores::cont::BitField::ExecutionTypes
Definition: BitField.h:521
viskores::cont::Token
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:43
viskores::cont::BitField::operator!=
bool operator!=(const BitField &rhs) const
Definition: BitField.h:552
viskores::cont::BitField::GetNumberOfWords
viskores::Id GetNumberOfWords() const
Return the number of words (of WordType) stored in this bit fields.
Definition: BitField.h:563
VISKORES_STATIC_ASSERT
#define VISKORES_STATIC_ASSERT(condition)
Definition: StaticAssert.h:24
List.h
viskores_cont_export.h