Skip to content

Commit c9295f4

Browse files
committed
Add AVX512-VNNI detection
Add detection of VNNI (Vector Neural Network Instructions) Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
1 parent cf2ded4 commit c9295f4

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

cpuid.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const (
7373
AVX512BW // AVX-512 Byte and Word Instructions
7474
AVX512VL // AVX-512 Vector Length Extensions
7575
AVX512VBMI // AVX-512 Vector Bit Manipulation Instructions
76+
AVX512VNNI // AVX-512 Vector Neural Network Instructions
7677
MPX // Intel MPX (Memory Protection Extensions)
7778
ERMS // Enhanced REP MOVSB/STOSB
7879
RDTSCP // RDTSCP Instruction
@@ -131,6 +132,7 @@ var flagNames = map[Flags]string{
131132
AVX512BW: "AVX512BW", // AVX-512 Byte and Word Instructions
132133
AVX512VL: "AVX512VL", // AVX-512 Vector Length Extensions
133134
AVX512VBMI: "AVX512VBMI", // AVX-512 Vector Bit Manipulation Instructions
135+
AVX512VNNI: "AVX512VNNI", // AVX-512 Vector Neural Network Instructions
134136
MPX: "MPX", // Intel MPX (Memory Protection Extensions)
135137
ERMS: "ERMS", // Enhanced REP MOVSB/STOSB
136138
RDTSCP: "RDTSCP", // RDTSCP Instruction
@@ -440,6 +442,11 @@ func (c CPUInfo) AVX512VBMI() bool {
440442
return c.Features&AVX512VBMI != 0
441443
}
442444

445+
// AVX512VNNI indicates support of AVX-512 Vector Neural Network Instructions
446+
func (c CPUInfo) AVX512VNNI() bool {
447+
return c.Features&AVX512VNNI != 0
448+
}
449+
443450
// MPX indicates support of Intel MPX (Memory Protection Extensions)
444451
func (c CPUInfo) MPX() bool {
445452
return c.Features&MPX != 0
@@ -955,6 +962,9 @@ func support() Flags {
955962
if ecx&(1<<1) != 0 {
956963
rval |= AVX512VBMI
957964
}
965+
if ecx&(1<<11) != 0 {
966+
rval |= AVX512VNNI
967+
}
958968
}
959969
}
960970
}

cpuid_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ func TestAVX512VL(t *testing.T) {
554554
t.Log("AVX512VL Support:", got)
555555
}
556556

557-
// TestAVX512VL tests AVX512VBMI() function (AVX-512 Vector Bit Manipulation Instructions)
557+
// TestAVX512VBMI tests AVX512VBMI() function (AVX-512 Vector Bit Manipulation Instructions)
558558
func TestAVX512VBMI(t *testing.T) {
559559
got := CPU.AVX512VBMI()
560560
expected := CPU.Features&AVX512VBMI == AVX512VBMI
@@ -564,6 +564,16 @@ func TestAVX512VBMI(t *testing.T) {
564564
t.Log("AVX512VBMI Support:", got)
565565
}
566566

567+
// TestAVX512VNNI tests AVX512VNNI() function (AVX-512 Vector Neural Network Instructions)
568+
func TestAVX512VNNI(t *testing.T) {
569+
got := CPU.AVX512VNNI()
570+
expected := CPU.Features&AVX512VNNI == AVX512VNNI
571+
if got != expected {
572+
t.Fatalf("AVX512VNNI: expected %v, got %v", expected, got)
573+
}
574+
t.Log("AVX512VNNI Support:", got)
575+
}
576+
567577
// TestMPX tests MPX() function (Intel MPX (Memory Protection Extensions))
568578
func TestMPX(t *testing.T) {
569579
got := CPU.MPX()

0 commit comments

Comments
 (0)