512MB 메모리에서 1 개가 얼마나 많은지 알고 싶었는데 gcc
개의 내장 코드에 _mm_popcnt_u64()
과 __builtin_popcountll()
두 가지 가능한 방법이 있습니다.__builtin_popcountll과 _mm_popcnt_u64의 차이점은 무엇입니까?
_mm_popcnt_u64()
는 가장 빠른 것으로 보이는 CPU 소개 SSE4.2를 사용한다고하며, __builtin_popcountll()
은 테이블 조회를 사용하는 것을 제외합니다.
따라서 은 _mm_popcnt_u64()
보다 약간 느려야합니다.
그것은 두 가지 방법이 거의 같은 시간이 걸렸습니다 :
그러나이 같은 결과를 얻었다. 나는 그들이 일하는 데 같은 방법을 사용했다는 것을 매우 의심한다.는 또한 그래서
/* Calculate a number of bits set to 1. */
extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial___))
_mm_popcnt_u32 (unsigned int __X)
{
return __builtin_popcount (__X);
}
#ifdef __x86_64__
extern __inline long long __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_popcnt_u64 (unsigned long long __X)
{
return __builtin_popcountll (__X);
}
#endif
popcntintrin.h
이있어, 나는 지구
내 Skylake CPU에서 타이밍이 비슷합니다 (거의 같습니다). –