Bit manipulation#
Defined in header <Kokkos_BitManipulation.hpp>
which is included from <Kokkos_Core.hpp>
Provides function templates from the standard library header <bit>
(since C++20).
Bit manipulation function templates are defined in the Kokkos::
namespace since Kokkos 4.1
reinterpret the object representation of one type as that of another (see note below) |
|
reverses the bytes in the given integer value |
|
checks if a number is an integral power of two |
|
finds the smallest integral power of two not less than the given value |
|
finds the largest integral power of two not greater than the given value |
|
finds the smallest number of bits needed to represent the given value |
|
computes the result of bitwise left-rotation |
|
computes the result of bitwise right-rotation |
|
counts the number of consecutive 0 bits, starting from the most significant bit |
|
counts the number of consecutive 1 bits, starting from the most significant bit |
|
counts the number of consecutive 0 bits, starting from the least significant bit |
|
counts the number of consecutive 1 bits, starting from the least significant bit |
|
counts the number of 1 bits in an unsigned integer |
Notes#
For all the above template functions, a non-
constexpr
counterpart ending with the*_builtin
suffix is provided in theKokkos::Experimental::
namespace to make up for some compiler intrinsics that cannot appear in constant expressions.In contrast to its counterpart in the C++ standard library,
Kokkos::bit_cast
is not usable in constant expressions (not aconstexpr
function) as it is not implementable as a library facility and requires compiler magic which is not available to us.