Contents

<cuda/std/bit>#

2026-10-07

1 min read time

Applies to Linux and Windows

This page documents <cuda/std/bit> in libhipcxx, which provides the C++ Standard Library bit manipulation functions, such as popcount, rotl, rotr, and bit_width, in host and device code.

Notes#

  • All functions are marked [[nodiscard]] and noexcept.

  • All functions support 128-bit integer types.

  • bit_ceil() checks for overflow in debug mode.

  • rotl()/rotr() checks for invalid count value (INT_MIN) in debug mode.

  • The functions are constexpr: for compile-time inputs libhipcxx evaluates them with a portable implementation, so the compiler folds them. For runtime inputs in device code it dispatches to the HIP device intrinsics, such as __popc for popcount() and __clz for countl_zero(), while byteswap() uses __builtin_bswap32.