MCPcopy Create free account
hub / github.com/ARM-software/astc-encoder / detect_cpu_isa

Function detect_cpu_isa

Source/astcenccli_entry.cpp:70–98  ·  view source on GitHub ↗

* @brief Detect platform CPU ISA support and update global trackers. */

Source from the content-addressed store, hash-verified

68 * @brief Detect platform CPU ISA support and update global trackers.
69 */
70static 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

Callers 4

cpu_supports_popcntFunction · 0.85
cpu_supports_f16cFunction · 0.85
cpu_supports_sse41Function · 0.85
cpu_supports_avx2Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected