提交 5c480d6f 编写于 作者: L liaogang

Add reference to CPUID

上级 4f73e3f6
......@@ -34,7 +34,7 @@ static InitFunction __init_simd_flags(
SIMDFlags::SIMDFlags() {
unsigned int cpuInfo[4];
// CPUID: https://en.wikipedia.org/wiki/CPUID
CPUID(cpuInfo, 0x00000001);
simd_flags_ |= cpuInfo[3] & (1 << 25) ? SIMD_SSE : SIMD_NONE;
simd_flags_ |= cpuInfo[3] & (1 << 26) ? SIMD_SSE2 : SIMD_NONE;
......
......@@ -61,7 +61,7 @@ private:
#define HAS_SSE3 SIMDFlags::instance()->isSSE3()
#define HAS_SSSE3 SIMDFlags::instance()->isSSSE3()
#define HAS_SSE41 SIMDFlags::instance()->isSSE41()
#define HAS_SSS42 SIMDFlags::instance()->isSSE42()
#define HAS_SSE42 SIMDFlags::instance()->isSSE42()
#define HAS_FMA3 SIMDFlags::instance()->isFMA3()
#define HAS_FMA4 SIMDFlags::instance()->isFMA4()
#define HAS_AVX SIMDFlags::instance()->isAVX()
......
......@@ -20,17 +20,14 @@ using namespace paddle; // NOLINT
TEST(SIMDFlags, gccTest) {
#if (defined(__GNUC__) || defined(__GNUG__)) && !(defined(__clang__))
CHECK(__builtin_cpu_supports("sse") == HAS_SSE);
CHECK(__builtin_cpu_supports("sse2") == HAS_SSE2);
CHECK(__builtin_cpu_supports("sse3") == HAS_SSE3);
CHECK(__builtin_cpu_supports("ssse3")== HAS_SSSE3);
CHECK(__builtin_cpu_supports("sse") == HAS_SSE);
CHECK(__builtin_cpu_supports("sse2") == HAS_SSE2);
CHECK(__builtin_cpu_supports("sse3") == HAS_SSE3);
CHECK(__builtin_cpu_supports("ssse3") == HAS_SSSE3);
CHECK(__builtin_cpu_supports("sse4.1")== HAS_SSE41);
CHECK(__builtin_cpu_supports("sse4.2")== HAS_SSE42);
CHECK(__builtin_cpu_supports("fma3")== HAS_FMA3);
CHECK(__builtin_cpu_supports("fma4")== HAS_FMA4);
CHECK(__builtin_cpu_supports("avx")== HAS_AVX);
CHECK(__builtin_cpu_supports("avx2")== HAS_AVX2);
CHECK(__builtin_cpu_supports("avx512f")== HAS_AVX512);
CHECK(__builtin_cpu_supports("avx") == HAS_AVX);
CHECK(__builtin_cpu_supports("avx2") == HAS_AVX2);
#endif
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册