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

Function cpu_features

engine/src/kernels/cpu/expert_layout.cpp:424–449  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

422}
423
424CpuFeatures cpu_features() {
425 CpuFeatures f;
426#if !defined(__x86_64__) && !defined(__i386__) && !defined(_M_X64) && !defined(_M_IX86)
427 return f; // the AVX-512 kernels are x86-only: no AVX-512 on this architecture
428#else
429 int reg[4] = {0, 0, 0, 0};
430#if defined(_MSC_VER)
431 __cpuid(reg, 0);
432 if (reg[0] < 7) return f;
433 __cpuidex(reg, 7, 0);
434#else
435 unsigned r[4] = {0, 0, 0, 0};
436 __cpuid_count(0, 0, r[0], r[1], r[2], r[3]);
437 if (r[0] < 7) return f;
438 __cpuid_count(7, 0, r[0], r[1], r[2], r[3]);
439 for (int i = 0; i < 4; ++i) reg[i] = (int) r[i];
440#endif
441 const unsigned ebx = (unsigned) reg[1], ecx = (unsigned) reg[2];
442 f.avx512f = (ebx >> 16) & 1u;
443 f.avx512bw = (ebx >> 30) & 1u;
444 f.avx512vl = (ebx >> 31) & 1u;
445 f.avx512_vnni = (ecx >> 11) & 1u;
446 f.avx512_vbmi = (ecx >> 1) & 1u;
447 return f;
448#endif
449}
450
451void cpu_require_expert_support() {
452 const CpuFeatures f = cpu_features();

Callers 7

mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by 3

mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68