| 5 | namespace cpu_features |
| 6 | { |
| 7 | cpu_features_t get_cpu_features() |
| 8 | { |
| 9 | std::string machine_string(volk_get_machine()); |
| 10 | cpu_features_t f; |
| 11 | |
| 12 | // X86 SSE |
| 13 | if (machine_string.find("sse2") != std::string::npos) |
| 14 | f.CPU_X86_SSE2 = true; |
| 15 | if (machine_string.find("sse3") != std::string::npos) |
| 16 | f.CPU_X86_SSE3 = f.CPU_X86_SSE2 = true; |
| 17 | if (machine_string.find("sse4_a") != std::string::npos) |
| 18 | f.CPU_X86_SSE4A = f.CPU_X86_SSE3 = f.CPU_X86_SSE2 = true; |
| 19 | if (machine_string.find("sse4_1") != std::string::npos) |
| 20 | f.CPU_X86_SSE41 = f.CPU_X86_SSE4A = f.CPU_X86_SSE3 = f.CPU_X86_SSE2 = true; |
| 21 | if (machine_string.find("sse4_2") != std::string::npos) |
| 22 | f.CPU_X86_SSE42 = f.CPU_X86_SSE41 = f.CPU_X86_SSE4A = f.CPU_X86_SSE3 = f.CPU_X86_SSE2 = true; |
| 23 | |
| 24 | // X86 AVX |
| 25 | if (machine_string.find("avx") != std::string::npos) |
| 26 | f.CPU_X86_AVX = f.CPU_X86_SSE42 = f.CPU_X86_SSE41 = f.CPU_X86_SSE4A = f.CPU_X86_SSE3 = f.CPU_X86_SSE2 = true; |
| 27 | if (machine_string.find("avx2") != std::string::npos) |
| 28 | f.CPU_X86_AVX2 = f.CPU_X86_AVX = f.CPU_X86_SSE42 = f.CPU_X86_SSE41 = f.CPU_X86_SSE4A = f.CPU_X86_SSE3 = f.CPU_X86_SSE2 = true; |
| 29 | |
| 30 | // ARM NEON |
| 31 | if (machine_string.find("neon") != std::string::npos) |
| 32 | f.CPU_ARM_NEON = true; |
| 33 | if (machine_string.find("neonv7") != std::string::npos) |
| 34 | f.CPU_ARM_NEON7 = f.CPU_ARM_NEON = true; |
| 35 | if (machine_string.find("neonv8") != std::string::npos) |
| 36 | f.CPU_ARM_NEON8 = f.CPU_ARM_NEON = true; |
| 37 | |
| 38 | return f; |
| 39 | } |
| 40 | |
| 41 | void print_features(cpu_features_t f) |
| 42 | { |