34 #define round_up(x, n) (((x) + (n)-1) & (-n))
35 #define round_down(x, n) ((x) & (-n))
36 #define ceil_int(a, b) ((a) + ((b)-1)) / (b)
38 #if defined(__arm64__) || defined(__arm__) || defined(__aarch64__)
40 #if defined(__ARM_NEON__)
43 #elif defined(_MSC_VER) || defined(__MINGW64__)
46 #include <x86intrin.h>
52 precision = __popcnt(
static_cast<uint32_t
>(num));
53 #elif defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86)
54 precision = _popcnt32(num);
66 static inline uint32_t
int_log2(
const uint32_t x) {
70 _BitScanReverse(&tmp, x);
73 y = 31 - __builtin_clz(x);
75 return (x == 0) ? 0 : y;
82 #elif defined(__AVX2__)
84 #elif defined(__MINGW32__) || defined(__MINGW64__)
86 #elif defined(__ARM_FEATURE_CLZ)
91 return (x == 0) ? 31 : y;
static uint32_t int_log2(const uint32_t x)
Definition: utils.hpp:66
static uint32_t count_leading_zeros(const uint32_t x)
Definition: utils.hpp:78
static size_t popcount32(uintmax_t num)
Definition: utils.hpp:49