14 #if __has_include(<version>)
17 #ifdef __cpp_lib_bitops
37 template<
typename Un
signedIntegral>
40 #ifdef __cpp_lib_bitops
42 #elif BOOST_COMP_GNUC || BOOST_COMP_CLANG
43 if constexpr(
sizeof(UnsignedIntegral) == 8)
44 return __builtin_popcountll(value);
46 return __builtin_popcount(value);
48 if constexpr(
sizeof(UnsignedIntegral) == 8)
49 return static_cast<std::int32_t
>(__popcnt64(value));
51 return __popcnt(value);
54 return static_cast<std::int32_t
>(std::bitset<sizeof(UnsignedIntegral) * CHAR_BIT>(value).count());
63 template<
typename Integral>
66 #ifdef __cpp_lib_bitops
67 return value == 0 ? 0 : std::countr_zero(
static_cast<std::make_unsigned_t<Integral>
>(value)) + 1;
68 #elif BOOST_COMP_GNUC || BOOST_COMP_CLANG
69 if constexpr(
sizeof(Integral) == 8)
70 return __builtin_ffsll(value);
72 return __builtin_ffs(value);
76 unsigned long index = 0u;
77 if constexpr(
sizeof(Integral) == 8)
78 return _BitScanForward64(&index, value) == 0 ? 0 :
static_cast<std::int32_t
>(index + 1u);
80 return _BitScanForward(&index, value) == 0 ? 0 :
static_cast<std::int32_t
>(index + 1u);
#define ALPAKA_UNREACHABLE(...)
Before CUDA 11.5 nvcc is unable to correctly identify return statements in 'if constexpr' branches....
static auto ffsFallback(TValue value) -> std::int32_t
Fallback implementation of ffs.
The alpaka accelerator library.
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_ACC auto popcount(TIntrinsic const &intrinsic, std::uint32_t value) -> std::int32_t
Returns the number of 1 bits in the given 32-bit value.
Tag used in class inheritance hierarchies that describes that a specific interface (TInterface) is im...
static auto ffs(IntrinsicCpu const &, Integral value) -> std::int32_t
static auto popcount(IntrinsicCpu const &, UnsignedIntegral value) -> std::int32_t