| | |
| | | #include <ammintrin.h> |
| | | #include <immintrin.h> |
| | | #include <smmintrin.h> |
| | | #include <cpuid.h> |
| | | |
| | | void asm_cpuid(uint32_t* abcd, uint32_t eax) |
| | | { |
| | |
| | | abcd[2] = ecx; |
| | | abcd[3] = edx; |
| | | } |
| | | |
| | | #endif |
| | | |
| | | inline int simd_detect_x86(unsigned int idFeature) |
| | | int simd_detect_x86(unsigned int idFeature) |
| | | { |
| | | uint32_t regs[4]; // EAX, EBX, ECX, EDX; |
| | | #ifdef _WIN32 |
| | | __cpuid(regs, 0); |
| | | if (regs[0] > 1U) __cpuid(regs, 1); |
| | | #else |
| | | asm_cpuid(regs, 0); |
| | | if (regs[0] > 1U) asm_cpuid(regs, 0); |
| | | __get_cpuid(0, ®s[0], ®s[1], ®s[2], ®s[3]); |
| | | if(regs[0] > 1U) __get_cpuid(1, ®s[0], ®s[1], ®s[2], ®s[3]); |
| | | #endif |
| | | |
| | | if ((regs[2] & idFeature) != idFeature) |
| | |
| | | return 1; |
| | | } |
| | | |
| | | inline int is_fma_avx() { |
| | | int is_fma_avx() { |
| | | static int result = -1; |
| | | if (result == -1) { |
| | | result = simd_detect_x86(AVXFlag); |