Files | Functions
Bitmask

Files

file  bit.hpp
 Utilities for bit and bitmask operations.
 

Functions

constexpr CUDF_HOST_DEVICE size_type cudf::word_index (size_type bit_index)
 Returns the index of the word containing the specified bit.
 
constexpr CUDF_HOST_DEVICE size_type cudf::intra_word_index (size_type bit_index)
 Returns the position within a word of the specified bit.
 
CUDF_HOST_DEVICE void cudf::set_bit_unsafe (bitmask_type *bitmask, size_type bit_index)
 Sets the specified bit to 1 More...
 
CUDF_HOST_DEVICE void cudf::clear_bit_unsafe (bitmask_type *bitmask, size_type bit_index)
 Sets the specified bit to 0 More...
 
CUDF_HOST_DEVICE bool cudf::bit_is_set (bitmask_type const *bitmask, size_type bit_index)
 Indicates whether the specified bit is set to 1 More...
 
CUDF_HOST_DEVICE bool cudf::bit_value_or (bitmask_type const *bitmask, size_type bit_index, bool default_value)
 optional-like interface to check if a specified bit of a bitmask is set. More...
 
constexpr CUDF_HOST_DEVICE bitmask_type cudf::set_least_significant_bits (size_type n)
 Returns a bitmask word with the n least significant bits set. More...
 
constexpr CUDF_HOST_DEVICE bitmask_type cudf::set_most_significant_bits (size_type n)
 Returns a bitmask word with the n most significant bits set. More...
 

Detailed Description

Function Documentation

◆ bit_is_set()

CUDF_HOST_DEVICE bool cudf::bit_is_set ( bitmask_type const *  bitmask,
size_type  bit_index 
)
inline

Indicates whether the specified bit is set to 1

Parameters
bitmaskThe bitmask containing the bit to clear
bit_indexIndex of the bit to test
Returns
true The specified bit is 1
false The specified bit is 0

Definition at line 112 of file bit.hpp.

◆ bit_value_or()

CUDF_HOST_DEVICE bool cudf::bit_value_or ( bitmask_type const *  bitmask,
size_type  bit_index,
bool  default_value 
)
inline

optional-like interface to check if a specified bit of a bitmask is set.

Parameters
bitmaskThe bitmask containing the bit to clear
bit_indexIndex of the bit to test
default_valueValue to return if bitmask is nullptr
Returns
true The specified bit is 1
false The specified bit is 0
default_value if bitmask is nullptr

Definition at line 128 of file bit.hpp.

◆ clear_bit_unsafe()

CUDF_HOST_DEVICE void cudf::clear_bit_unsafe ( bitmask_type *  bitmask,
size_type  bit_index 
)
inline

Sets the specified bit to 0

This function is not thread-safe, i.e., attempting to update bits within the same word concurrently from multiple threads results in undefined behavior.

Parameters
bitmaskThe bitmask containing the bit to clear
bit_indexThe index of the bit to clear

Definition at line 98 of file bit.hpp.

◆ set_bit_unsafe()

CUDF_HOST_DEVICE void cudf::set_bit_unsafe ( bitmask_type *  bitmask,
size_type  bit_index 
)
inline

Sets the specified bit to 1

This function is not thread-safe, i.e., attempting to update bits within the same word concurrently from multiple threads results in undefined behavior.

Parameters
bitmaskThe bitmask containing the bit to set
bit_indexIndex of the bit to set

Definition at line 83 of file bit.hpp.

◆ set_least_significant_bits()

constexpr CUDF_HOST_DEVICE bitmask_type cudf::set_least_significant_bits ( size_type  n)
inlineconstexpr

Returns a bitmask word with the n least significant bits set.

Behavior is undefined if n < 0 or if n >= size_in_bits<bitmask_type>()

Parameters
nThe number of least significant bits to set
Returns
A bitmask word with n least significant bits set

Definition at line 143 of file bit.hpp.

◆ set_most_significant_bits()

constexpr CUDF_HOST_DEVICE bitmask_type cudf::set_most_significant_bits ( size_type  n)
inlineconstexpr

Returns a bitmask word with the n most significant bits set.

Behavior is undefined if n < 0 or if n >= size_in_bits<bitmask_type>()

Parameters
nThe number of most significant bits to set
Returns
A bitmask word with n most significant bits set

Definition at line 157 of file bit.hpp.