MCPcopy Create free account
hub / github.com/Niko1221/Strata / probe

Function probe

engine/src/quant/isa.cpp:59–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59Caps probe() {
60 Caps c;
61#ifdef STRATA_QUANT_X86
62 unsigned r[4] = {0, 0, 0, 0};
63 cpuid(0, 0, r);
64 const unsigned maxleaf = r[0];
65 cpuid(1, 0, r);
66 const unsigned ecx1 = r[2];
67 c.sse42 = (ecx1 >> 20) & 1;
68 const bool osxsave = (ecx1 >> 27) & 1;
69 const unsigned long long xcr0 = osxsave ? xgetbv0() : 0;
70 const bool ymm = (xcr0 & 6) == 6;
71 const bool zmm = ymm && (xcr0 & 0xE0) == 0xE0;
72 c.avx = ymm && ((ecx1 >> 28) & 1);
73 const bool fma = (ecx1 >> 12) & 1, f16c = (ecx1 >> 29) & 1;
74 if (maxleaf >= 7) {
75 cpuid(7, 0, r);
76 const unsigned ebx = r[1], ecx = r[2];
77 c.avx2 = c.avx && fma && f16c && ((ebx >> 5) & 1);
78 c.bmi2 = (ebx >> 8) & 1;
79 c.avx512 = zmm && ((ebx >> 16) & 1) && ((ebx >> 17) & 1) && ((ebx >> 30) & 1) && ((ebx >> 31) & 1); // F, DQ, BW, VL
80 c.avx512_vnni = c.avx512 && ((ecx >> 11) & 1);
81 cpuid(7, 1, r);
82 c.avx_vnni = c.avx2 && ((r[0] >> 4) & 1);
83 }
84 const int cap = isa_cap();
85 if (cap < 3) c.avx512 = c.avx512_vnni = false;
86 if (cap < 2) c.avx2 = c.avx_vnni = c.bmi2 = false;
87 if (cap < 1) c.avx = false;
88#elif defined(STRATA_QUANT_ARM64)
89 c.neon = true;
90#if defined(__linux__)
91 const unsigned long hw = getauxval(AT_HWCAP);
92 c.dotprod = (hw >> 20) & 1; // HWCAP_ASIMDDP
93 const unsigned long hw2 = getauxval(AT_HWCAP2);
94 c.i8mm = (hw2 >> 13) & 1; // HWCAP2_I8MM
95#elif defined(__APPLE__)
96 int v = 0;
97 size_t sz = sizeof v;
98 c.dotprod = sysctlbyname("hw.optional.arm.FEAT_DotProd", &v, &sz, nullptr, 0) == 0 && v;
99 v = 0;
100 sz = sizeof v;
101 c.i8mm = sysctlbyname("hw.optional.arm.FEAT_I8MM", &v, &sz, nullptr, 0) == 0 && v;
102#endif
103#endif
104 return c;
105}
106
107} // namespace
108

Callers 12

isa.cppFile · 0.70
run_poisonFunction · 0.50
run_poison2Function · 0.50
mainFunction · 0.50
detectMethod · 0.50
peer_decideFunction · 0.50
test_host_memoryFunction · 0.50
test_host_memoryFunction · 0.50
mainFunction · 0.50
mainFunction · 0.50
getMethod · 0.50
volta_forever_versionFunction · 0.50

Calls 3

isa_capFunction · 0.85
cpuidFunction · 0.70
xgetbv0Function · 0.70

Tested by 4

test_host_memoryFunction · 0.40
test_host_memoryFunction · 0.40
mainFunction · 0.40
mainFunction · 0.40