Celeritas  0.5.0-86+4a8eea4
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 = unsigned int
 

Public Member Functions

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

The following methods are not implemented:


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