fix __popc

This commit is contained in:
amdsc21 2023-03-10 17:14:31 +01:00
parent e1ddb5ae58
commit 9f072b50ba

View File

@ -134,9 +134,9 @@ int32_t NativePopc(T v) {
} }
inline LINALG_HD int Popc(uint32_t v) { inline LINALG_HD int Popc(uint32_t v) {
#if defined(__CUDA_ARCH__) || defined(__HIP_PLATFORM_AMD__) #if defined(__CUDA_ARCH__)
return __popc(v); return __popc(v);
#elif defined(__GNUC__) || defined(__clang__) #elif defined(__GNUC__) || defined(__clang__) || defined(__HIP_PLATFORM_AMD__)
return __builtin_popcount(v); return __builtin_popcount(v);
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
return __popcnt(v); return __popcnt(v);
@ -146,9 +146,9 @@ inline LINALG_HD int Popc(uint32_t v) {
} }
inline LINALG_HD int Popc(uint64_t v) { inline LINALG_HD int Popc(uint64_t v) {
#if defined(__CUDA_ARCH__) || defined(__HIP_PLATFORM_AMD__) #if defined(__CUDA_ARCH__)
return __popcll(v); return __popcll(v);
#elif defined(__GNUC__) || defined(__clang__) #elif defined(__GNUC__) || defined(__clang__) || defined(__HIP_PLATFORM_AMD__)
return __builtin_popcountll(v); return __builtin_popcountll(v);
#elif defined(_MSC_VER) && _defined(_M_X64) #elif defined(_MSC_VER) && _defined(_M_X64)
return __popcnt64(v); return __popcnt64(v);