Skip to content

Commit 3c8b153

Browse files
authored
add detection for intel new isa: avx_ne_convert, avx_vnni_int8, avx_vnni_int16 (#232)
Test Plan: ``` bash scripts/local-build.sh ISAS=() OPTIONS=() PLATFORMS=() OPTIONS+=(-quark); PLATFORMS+=("Quark") OPTIONS+=(-p4); PLATFORMS+=("Pentium4") OPTIONS+=(-p4p); PLATFORMS+=("Pentium4 Prescott") OPTIONS+=(-mrm); PLATFORMS+=("Merom") OPTIONS+=(-pnr); PLATFORMS+=("Penryn") OPTIONS+=(-nhm); PLATFORMS+=("Nehalem") OPTIONS+=(-wsm); PLATFORMS+=("Westmere") OPTIONS+=(-snb); PLATFORMS+=("Sandy Bridge") OPTIONS+=(-ivb); PLATFORMS+=("Ivy Bridge") OPTIONS+=(-hsw); PLATFORMS+=("Haswell") OPTIONS+=(-bdw); PLATFORMS+=("Broadwell") OPTIONS+=(-slt); PLATFORMS+=("Saltwell") OPTIONS+=(-slm); PLATFORMS+=("Silvermont") OPTIONS+=(-glm); PLATFORMS+=("Goldmont") OPTIONS+=(-glp); PLATFORMS+=("Goldmont Plus") OPTIONS+=(-tnt); PLATFORMS+=("Tremont") OPTIONS+=(-snr); PLATFORMS+=("Snow Ridge") OPTIONS+=(-skl); PLATFORMS+=("Skylake") OPTIONS+=(-cnl); PLATFORMS+=("Cannon Lake") OPTIONS+=(-icl); PLATFORMS+=("Ice Lake") OPTIONS+=(-skx); PLATFORMS+=("Skylake server") OPTIONS+=(-clx); PLATFORMS+=("Cascade Lake") OPTIONS+=(-cpx); PLATFORMS+=("Cooper Lake") OPTIONS+=(-icx); PLATFORMS+=("Ice Lake server") OPTIONS+=(-knl); PLATFORMS+=("Knights landing") OPTIONS+=(-knm); PLATFORMS+=("Knights mill") OPTIONS+=(-tgl); PLATFORMS+=("Tiger Lake") OPTIONS+=(-adl); PLATFORMS+=("Alder Lake") OPTIONS+=(-mtl); PLATFORMS+=("Meteor Lake") OPTIONS+=(-rpl); PLATFORMS+=("Raptor Lake") OPTIONS+=(-spr); PLATFORMS+=("Sapphire Rapids") OPTIONS+=(-gnr); PLATFORMS+=("Granite Rapids") OPTIONS+=(-gnr256); PLATFORMS+=("Granite Rapids (AVX10.1 / 256VL)") OPTIONS+=(-srf); PLATFORMS+=("Sierra Forest") OPTIONS+=(-arl); PLATFORMS+=("Arrow Lake") OPTIONS+=(-lnl); PLATFORMS+=("Lunar Lake") OPTIONS+=(-future); PLATFORMS+=("Future chip") ISAS+=("AVX_VNNI_INT8") ISAS+=("AVX_VNNI_INT16") ISAS+=("AVX_NE_CONVERT") SDE_BIN="/home/mingfeim/packages/sde-external-9.33.0-2024-01-07-lin/sde" for I in "${!PLATFORMS[@]}"; do echo "${PLATFORMS["${I}"]}" for J in "${!ISAS[@]}"; do "${SDE_BIN}" "${OPTIONS[$I]}" -- ./build/local/isa-info | grep ${ISAS[$J]} done done ``` Results: ``` Quark SDE-ERROR: 64 bits applications are not supported by input chip: PENTIUM or by the input cpuid definition file SDE-ERROR: 64 bits applications are not supported by input chip: PENTIUM or by the input cpuid definition file SDE-ERROR: 64 bits applications are not supported by input chip: PENTIUM or by the input cpuid definition file Pentium4 SDE-ERROR: 64 bits applications are not supported by input chip: PENTIUM4 or by the input cpuid definition file SDE-ERROR: 64 bits applications are not supported by input chip: PENTIUM4 or by the input cpuid definition file SDE-ERROR: 64 bits applications are not supported by input chip: PENTIUM4 or by the input cpuid definition file Pentium4 Prescott AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Merom AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Penryn AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Nehalem AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Westmere AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Sandy Bridge AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Ivy Bridge AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Haswell AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Broadwell AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Saltwell AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Silvermont AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Goldmont AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Goldmont Plus AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Tremont AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Snow Ridge AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Skylake AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Cannon Lake AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Ice Lake AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Skylake server AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Cascade Lake AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Cooper Lake AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Ice Lake server AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Knights landing AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Knights mill AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Tiger Lake AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Alder Lake AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Meteor Lake AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Raptor Lake AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Sapphire Rapids AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Granite Rapids AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Granite Rapids (AVX10.1 / 256VL) AVX_VNNI_INT8: no AVX_VNNI_INT16: no AVX_NE_CONVERT: no Sierra Forest AVX_VNNI_INT8: yes AVX_VNNI_INT16: no AVX_NE_CONVERT: yes Arrow Lake AVX_VNNI_INT8: yes AVX_VNNI_INT16: yes AVX_NE_CONVERT: yes Lunar Lake AVX_VNNI_INT8: yes AVX_VNNI_INT16: yes AVX_NE_CONVERT: yes Future chip AVX_VNNI_INT8: yes AVX_VNNI_INT16: yes AVX_NE_CONVERT: yes ```
1 parent 5de5c70 commit 3c8b153

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

include/cpuinfo.h

+43
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,9 @@ struct cpuinfo_x86_isa {
816816
bool amx_tile;
817817
bool amx_int8;
818818
bool amx_fp16;
819+
bool avx_vnni_int8;
820+
bool avx_vnni_int16;
821+
bool avx_ne_convert;
819822
bool hle;
820823
bool rtm;
821824
bool xtest;
@@ -1384,6 +1387,46 @@ static inline bool cpuinfo_has_x86_amx_fp16(void) {
13841387
#endif
13851388
}
13861389

1390+
/*
1391+
* Intel AVX Vector Neural Network Instructions (VNNI) INT8
1392+
* Supported Platfroms: Sierra Forest, Arrow Lake, Lunar Lake
1393+
*/
1394+
static inline bool cpuinfo_has_x86_avx_vnni_int8(void) {
1395+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1396+
return cpuinfo_isa.avx_vnni_int8;
1397+
#else
1398+
return false;
1399+
#endif
1400+
}
1401+
1402+
/*
1403+
* Intel AVX Vector Neural Network Instructions (VNNI) INT16
1404+
* Supported Platfroms: Arrow Lake, Lunar Lake
1405+
*/
1406+
static inline bool cpuinfo_has_x86_avx_vnni_int16(void) {
1407+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1408+
return cpuinfo_isa.avx_vnni_int16;
1409+
#else
1410+
return false;
1411+
#endif
1412+
}
1413+
1414+
/*
1415+
* A new set of instructions, which can convert low precision floating point
1416+
* like BF16/FP16 to high precision floating point FP32, as well as convert FP32
1417+
* elements to BF16. This instruction allows the platform to have improved AI
1418+
* capabilities and better compatibility.
1419+
*
1420+
* Supported Platforms: Sierra Forest, Arrow Lake, Lunar Lake
1421+
*/
1422+
static inline bool cpuinfo_has_x86_avx_ne_convert(void) {
1423+
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
1424+
return cpuinfo_isa.avx_ne_convert;
1425+
#else
1426+
return false;
1427+
#endif
1428+
}
1429+
13871430
static inline bool cpuinfo_has_x86_hle(void) {
13881431
#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64
13891432
return cpuinfo_isa.hle;

src/x86/isa.c

+18
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,24 @@ struct cpuinfo_x86_isa cpuinfo_x86_detect_isa(
561561
*/
562562
isa.amx_fp16 = avx512_regs && !!(structured_feature_info1.eax & UINT32_C(0x00200000));
563563

564+
/*
565+
* AVX_VNNI_INT8 instructions:
566+
* - Intel: edx[bit 4] in structured feature info (ecx = 1).
567+
*/
568+
isa.avx_vnni_int8 = avx_regs && !!(structured_feature_info1.edx & UINT32_C(0x00000010));
569+
570+
/*
571+
* AVX_VNNI_INT16 instructions:
572+
* - Intel: edx[bit 10] in structured feature info (ecx = 1).
573+
*/
574+
isa.avx_vnni_int16 = avx_regs && !!(structured_feature_info1.edx & UINT32_C(0x00000400));
575+
576+
/*
577+
* AVX_NE_CONVERT instructions:
578+
* - Intel: edx[bit 5] in structured feature info (ecx = 1).
579+
*/
580+
isa.avx_ne_convert = avx_regs && !!(structured_feature_info1.edx & UINT32_C(0x00000020));
581+
564582
/*
565583
* HLE instructions:
566584
* - Intel: ebx[bit 4] in structured feature info (ecx = 0).

tools/isa-info.c

+3
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ int main(int argc, char** argv) {
7575
printf("\tAMX_INT8: %s\n", cpuinfo_has_x86_amx_int8() ? "yes" : "no");
7676
printf("\tAMX_FP16: %s\n", cpuinfo_has_x86_amx_fp16() ? "yes" : "no");
7777
printf("\tAVXVNNI: %s\n", cpuinfo_has_x86_avxvnni() ? "yes" : "no");
78+
printf("\tAVX_VNNI_INT8: %s\n", cpuinfo_has_x86_avx_vnni_int8() ? "yes" : "no");
79+
printf("\tAVX_VNNI_INT16: %s\n", cpuinfo_has_x86_avx_vnni_int16() ? "yes" : "no");
80+
printf("\tAVX_NE_CONVERT: %s\n", cpuinfo_has_x86_avx_ne_convert() ? "yes" : "no");
7881

7982
printf("Multi-threading extensions:\n");
8083
printf("\tMONITOR/MWAIT: %s\n", cpuinfo_has_x86_mwait() ? "yes" : "no");

0 commit comments

Comments
 (0)