#951 Fix AVX detection.

This commit is contained in:
XMRig 2019-03-05 15:03:43 +07:00
parent 8800219cf4
commit 6052da3c43
2 changed files with 15 additions and 2 deletions

View file

@ -36,6 +36,10 @@
# define bit_AES (1 << 25) # define bit_AES (1 << 25)
#endif #endif
#ifndef bit_OSXSAVE
# define bit_OSXSAVE (1 << 27)
#endif
#ifndef bit_AVX2 #ifndef bit_AVX2
# define bit_AVX2 (1 << 5) # define bit_AVX2 (1 << 5)
#endif #endif
@ -107,10 +111,19 @@ static inline bool has_avx2()
} }
static inline bool has_ossave()
{
int32_t cpu_info[4] = { 0 };
cpuid(PROCESSOR_INFO, cpu_info);
return (cpu_info[ECX_Reg] & bit_OSXSAVE) != 0;
}
xmrig::BasicCpuInfo::BasicCpuInfo() : xmrig::BasicCpuInfo::BasicCpuInfo() :
m_assembly(ASM_NONE), m_assembly(ASM_NONE),
m_aes(has_aes_ni()), m_aes(has_aes_ni()),
m_avx2(has_avx2()), m_avx2(has_avx2() && has_ossave()),
m_brand(), m_brand(),
m_threads(std::thread::hardware_concurrency()) m_threads(std::thread::hardware_concurrency())
{ {

View file

@ -85,7 +85,7 @@ xmrig::AdvancedCpuInfo::AdvancedCpuInfo() :
} }
} }
m_avx2 = data.flags[CPU_FEATURE_AVX2]; m_avx2 = data.flags[CPU_FEATURE_AVX2] && data.flags[CPU_FEATURE_OSXSAVE];
} }