15 return n != 0 && (
n & (
n - 1)) == 0;
60template <
typename TagType,
typename WordType>
62 static_assert(
sizeof(WordType) == 4 ||
sizeof(WordType) == 8,
"WordType must be 32 or 64 bits");
64 if constexpr (
sizeof(WordType) == 8) {
65 if constexpr (
sizeof(TagType) == 1) {
66 return (
v - 0x0101010101010101ULL) &
~v & 0x8080808080808080ULL;
67 }
else if constexpr (
sizeof(TagType) == 2) {
68 return (
v - 0x0001000100010001ULL) &
~v & 0x8000800080008000ULL;
69 }
else if constexpr (
sizeof(TagType) == 4) {
70 return (
v - 0x0000000100000001ULL) &
~v & 0x8000000080000000ULL;
75 if constexpr (
sizeof(TagType) == 1) {
76 return (
v - 0x01010101U) &
~v & 0x80808080U;
77 }
else if constexpr (
sizeof(TagType) == 2) {
78 return (
v - 0x00010001U) &
~v & 0x80008000U;
79 }
else if constexpr (
sizeof(TagType) == 4) {
80 return (
v - 0x00000001U) &
~v & 0x80000000U;
95template <
typename TagType,
typename WordType>
108template <
typename TagType,
typename WordType>
110 static_assert(
sizeof(WordType) == 4 ||
sizeof(WordType) == 8,
"WordType must be 32 or 64 bits");
112 if constexpr (
sizeof(WordType) == 8) {
113 if constexpr (
sizeof(TagType) == 1) {
114 return static_cast<uint64_t>(
tag) * 0x0101010101010101ULL;
115 }
else if constexpr (
sizeof(TagType) == 2) {
116 return static_cast<uint64_t>(
tag) * 0x0001000100010001ULL;
117 }
else if constexpr (
sizeof(TagType) == 4) {
118 return static_cast<uint64_t>(
tag) * 0x0000000100000001ULL;
123 if constexpr (
sizeof(TagType) == 1) {
125 }
else if constexpr (
sizeof(TagType) == 2) {
127 }
else if constexpr (
sizeof(TagType) == 4) {
135#if __CUDA_ARCH__ >= 1000
153 static_assert(
sizeof(T) == 4 ||
sizeof(T) == 8,
"T must be uint32_t or uint64_t");
155 if constexpr (
sizeof(T) == 8) {
156 asm volatile(
"ld.global.nc.v4.u64 {%0, %1, %2, %3}, [%4];"
157 :
"=l"(
out[0]),
"=l"(
out[1]),
"=l"(
out[2]),
"=l"(
out[3])
160 asm volatile(
"ld.global.nc.v8.u32 {%0, %1, %2, %3, %4, %5, %6, %7}, [%8];"
178#define SDIV(x, y) (((x) + (y) - 1) / (y))
184#define CUCKOO_CUDA_CALL(err) \
186 cudaError_t err_ = (err); \
187 if (err_ == cudaSuccess) [[likely]] { \
190 printf("%s:%d %s\n", __FILE__, __LINE__, cudaGetErrorString(err_)); \
203template <
typename Kernel>
constexpr size_t maxOccupancyGridSize(int32_t blockSize, Kernel kernel, size_t dynamicSMemSize)
Calculates the maximum occupancy grid size for a kernel.
constexpr size_t nextPowerOfTwo(size_t n)
Calculates the next power of two greater than or equal to n.
__host__ __device__ __forceinline__ constexpr WordType getZeroMask(WordType v)
Returns a bitmask indicating which slots in a packed word are zero.
__host__ __device__ __forceinline__ constexpr bool hasZero(WordType v)
Checks if a packed word contains a zero slot.
__host__ __device__ __forceinline__ uint32_t globalThreadId()
Calculates the global thread ID in a 1D grid.
__host__ __device__ __forceinline__ constexpr WordType replicateTag(TagType tag)
Replicates a tag value across all slots in a word.
constexpr bool powerOfTwo(size_t n)
Checks if a number is a power of two.