MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / feature_detect_avx2

Function feature_detect_avx2

dnn/src/x86/utils.cpp:62–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62bool feature_detect_avx2() {
63 uint32_t eax, ebx, ecx, edx;
64
65 // check cpu support
66#if defined(_WIN32)
67 int cpuInfo[4];
68 __cpuid(cpuInfo, 7);
69 eax = cpuInfo[0];
70 ebx = cpuInfo[1];
71 ecx = cpuInfo[2];
72 edx = cpuInfo[3];
73#else
74 asm volatile("cpuid\n"
75 : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx)
76 : "a"(7), "c"(0)
77 : "cc");
78#endif
79
80 if (!(bit(ebx, 3) && bit(ebx, 5) && bit(ebx, 8)))
81 return false;
82
83 // check os support
84 asm volatile("xgetbv" : "=a"(eax), "=d"(edx) : "c"(0));
85
86 return (eax & 6) == 6;
87}
88
89bool feature_detect_vnni() {
90 uint32_t eax, ebx, ecx, edx;

Callers 1

utils.cppFile · 0.85

Calls 1

bitFunction · 0.85

Tested by

no test coverage detected