* @brief Detect platform CPU ISA support and update global trackers. */
| 68 | * @brief Detect platform CPU ISA support and update global trackers. |
| 69 | */ |
| 70 | static void detect_cpu_isa() |
| 71 | { |
| 72 | int data[4]; |
| 73 | |
| 74 | __cpuid(data, 0); |
| 75 | int num_id = data[0]; |
| 76 | |
| 77 | if (num_id >= 1) |
| 78 | { |
| 79 | __cpuidex(data, 1, 0); |
| 80 | // SSE41 = Bank 1, ECX, bit 19 |
| 81 | g_cpu_has_sse41 = data[2] & (1 << 19) ? true : false; |
| 82 | // POPCNT = Bank 1, ECX, bit 23 |
| 83 | g_cpu_has_popcnt = data[2] & (1 << 23) ? true : false; |
| 84 | // F16C = Bank 1, ECX, bit 29 |
| 85 | g_cpu_has_f16c = data[2] & (1 << 29) ? true : false; |
| 86 | } |
| 87 | |
| 88 | if (num_id >= 7) |
| 89 | { |
| 90 | __cpuidex(data, 7, 0); |
| 91 | // AVX2 = Bank 7, EBX, bit 5 |
| 92 | g_cpu_has_avx2 = data[1] & (1 << 5) ? true : false; |
| 93 | } |
| 94 | |
| 95 | // Ensure state bits are updated before init flag is updated |
| 96 | MemoryBarrier(); |
| 97 | g_init = true; |
| 98 | } |
| 99 | |
| 100 | /* ============================================================================ |
| 101 | Platform code for GCC and Clang |
no outgoing calls
no test coverage detected