diff --git a/deps/oblib/src/lib/cpu/ob_cpu_topology.h b/deps/oblib/src/lib/cpu/ob_cpu_topology.h index ca59f37d11..033aacf2f2 100644 --- a/deps/oblib/src/lib/cpu/ob_cpu_topology.h +++ b/deps/oblib/src/lib/cpu/ob_cpu_topology.h @@ -41,12 +41,24 @@ inline uint64_t our_xgetbv(uint32_t xcr) noexcept return (static_cast(edx) << 32) | eax; } #endif +inline bool haveOSXSAVE(); inline bool have_sse42(); inline bool have_avx(); inline bool have_avx2(); inline bool have_avxf(); inline bool have_avx512bw(); +inline bool haveOSXSAVE() +{ +#if defined(__x86_64__) + int regs[4]; + get_cpuid(regs, 0x1); + return (regs[2] >> 27) & 1u; +#else + return false; +#endif +} + inline bool have_sse42() { #if defined(__x86_64__) @@ -62,7 +74,7 @@ inline bool have_avx() #if defined(__x86_64__) int regs[4]; get_cpuid(regs, 0x1); - return ((our_xgetbv(0) & 6u) == 6u) && (regs[2] >> 28 & 1); + return haveOSXSAVE() && ((our_xgetbv(0) & 6u) == 6u) && (regs[2] >> 28 & 1); #else return false; #endif