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

Function feature_detect_vnni

dnn/src/x86/utils.cpp:89–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89bool feature_detect_vnni() {
90 uint32_t eax, ebx, ecx, edx;
91
92 // check cpu support
93#if defined(_WIN32)
94 int cpuInfo[4];
95 __cpuid(cpuInfo, 7);
96 eax = cpuInfo[0];
97 ebx = cpuInfo[1];
98 ecx = cpuInfo[2];
99 edx = cpuInfo[3];
100#else
101 asm volatile("cpuid\n"
102 : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx)
103 : "a"(7), "c"(0)
104 : "cc");
105#endif
106 // avx512f ---> 16 ebx
107 // avx512dq ---> 17 ebx
108 // avx512bw ---> 30 ebx
109 // avx512vl ---> 31 ebx
110 // avx512vnni --->11 ecx
111 if (!(bit(ebx, 16) && bit(ebx, 17) && bit(ebx, 30) && bit(ebx, 31) && bit(ecx, 11)))
112 return false;
113
114 // check os support
115 asm volatile("xgetbv" : "=a"(eax), "=d"(edx) : "c"(0));
116
117 return (eax & 6) == 6;
118}
119
120bool feature_detect_avx_fma(int ftr) {
121 // see Detecting Availability and Support in

Callers 1

utils.cppFile · 0.85

Calls 1

bitFunction · 0.85

Tested by

no test coverage detected