Celeritas 0.7.0-dev.245+develop.a7be925e
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
celeritas::Bitset< N > Class Template Reference

Device-compatible bitset implementation. More...

#include <Bitset.hh>

Classes

class  reference
 Reference to a single bit in the bitset. More...
 

Public Types

Type aliases
using word_type = std::conditional_t<(N<=8), std::uint8_t, std::conditional_t<(N<=16), std::uint16_t, size_type > >
 

Public Member Functions

constexpr Bitset (word_type value) noexcept
 Construct from a word value.
 
constexpr bool operator== (Bitset const &other) const noexcept
 Compare for equality.
 
constexpr bool operator!= (Bitset const &other) const noexcept
 Compare for inequality.
 
constexpr bool operator[] (size_type pos) const noexcept(! 0)
 Access a single bit.
 
constexpr reference operator[] (size_type pos) noexcept(! 0)
 Mutable access to a single bit.
 
constexpr bool all () const noexcept
 Check if all bits are set.
 
constexpr bool any () const noexcept
 Check if any bits are set.
 
constexpr bool none () const noexcept
 Check if no bits are set.
 
constexpr size_type count () const noexcept
 Number of bits set to true.
 
constexpr size_type size () const noexcept
 Number of bits in the bitset.
 
constexpr Bitsetoperator&= (Bitset const &other) noexcept
 Bitwise AND with another bitset.
 
constexpr Bitsetoperator|= (Bitset const &other) noexcept
 Bitwise OR with another bitset.
 
constexpr Bitsetoperator^= (Bitset const &other) noexcept
 Bitwise XOR with another bitset.
 
constexpr Bitset operator~ () const noexcept
 Return a copy with all bits flipped (binary NOT)
 
constexpr Bitsetset () noexcept
 Set all bits.
 
constexpr Bitsetset (size_type pos, bool value=true) noexcept(! 0)
 Set the bit at position pos.
 
constexpr Bitsetreset () noexcept
 Reset all bits.
 
constexpr Bitsetreset (size_type pos) noexcept(! 0)
 Reset the bit at position pos.
 
constexpr Bitsetflip () noexcept
 Flip all bits.
 
constexpr Bitsetflip (size_type pos) noexcept(! 0)
 Flip the bit at position pos.
 

Detailed Description

template<size_type N>
class celeritas::Bitset< N >

Device-compatible bitset implementation.

This implementation is based on libstdc++'s std::bitset implementation. It it a subset of the C++ standard, but it should be sufficient for our current use case. Given that GPU typically use 32-bit words, this uses unsigned int as the word type instead of the unsigned long used by the standard library. This container is not thread-safe, multiple threads are likely to manipulate the same word, even when accessing different indices.

The following methods are not implemented:


The documentation for this class was generated from the following file: