mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-22 18:13:42 +08:00
Merge pull request #2620 from stweil/simd
simd: Check whether the OS supports FMA, AVX, ...
This commit is contained in:
commit
0a3a351cb3
@ -120,18 +120,19 @@ SIMDDetect::SIMDDetect() {
|
||||
__cpuid(cpuInfo, 0);
|
||||
max_function_id = cpuInfo[0];
|
||||
if (max_function_id >= 1) {
|
||||
bool xmm_ymm_state_enabled = (_xgetbv(0) & 6) == 6;
|
||||
__cpuid(cpuInfo, 1);
|
||||
#if defined(SSE4_1)
|
||||
sse_available_ = (cpuInfo[2] & 0x00080000) != 0;
|
||||
#endif
|
||||
#if defined(FMA)
|
||||
fma_available_ = (cpuInfo[2] & 0x00001000) != 0;
|
||||
fma_available_ = xmm_ymm_state_enabled && (cpuInfo[2] & 0x00001000) != 0;
|
||||
#endif
|
||||
#if defined(AVX)
|
||||
avx_available_ = (cpuInfo[2] & 0x10000000) != 0;
|
||||
#endif
|
||||
#if defined(AVX2)
|
||||
if (max_function_id >= 7) {
|
||||
if (max_function_id >= 7 && xmm_ymm_state_enabled) {
|
||||
__cpuid(cpuInfo, 7);
|
||||
avx2_available_ = (cpuInfo[1] & 0x00000020) != 0;
|
||||
avx512F_available_ = (cpuInfo[1] & 0x00010000) != 0;
|
||||
|
Loading…
Reference in New Issue
Block a user