Skip to content

Commit b9d92a6

Browse files
committed
added HasAMX flag
1 parent 724506b commit b9d92a6

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/internal/cpu/cpu.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var X86 struct {
2929
HasADX bool
3030
HasAVX bool
3131
HasAVX2 bool
32+
HasAMX bool
3233
HasBMI1 bool
3334
HasBMI2 bool
3435
HasERMS bool

src/internal/cpu/cpu_x86.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ const (
4141
cpuid_ADX = 1 << 19
4242
cpuid_SHA = 1 << 29
4343

44+
// edx bits
45+
cpuid_AMX = 1 << 24
46+
4447
// edx bits for CPUID 0x80000001
4548
cpuid_RDTSCP = 1 << 27
4649
)
@@ -73,6 +76,7 @@ func doinit() {
7376
options = append(options,
7477
option{Name: "avx", Feature: &X86.HasAVX},
7578
option{Name: "avx2", Feature: &X86.HasAVX2},
79+
option{Name: "amx", Feature: &X86.HasAMX},
7680
option{Name: "bmi1", Feature: &X86.HasBMI1},
7781
option{Name: "bmi2", Feature: &X86.HasBMI2},
7882
option{Name: "fma", Feature: &X86.HasFMA})
@@ -121,14 +125,14 @@ func doinit() {
121125
return
122126
}
123127

124-
_, ebx7, _, _ := cpuid(7, 0)
128+
_, ebx7, _, edx7 := cpuid(7, 0)
125129
X86.HasBMI1 = isSet(ebx7, cpuid_BMI1)
126130
X86.HasAVX2 = isSet(ebx7, cpuid_AVX2) && osSupportsAVX
131+
X86.HasAMX = isSet(edx7, cpuid_AMX) && osSupportsAVX
127132
X86.HasBMI2 = isSet(ebx7, cpuid_BMI2)
128133
X86.HasERMS = isSet(ebx7, cpuid_ERMS)
129134
X86.HasADX = isSet(ebx7, cpuid_ADX)
130135
X86.HasSHA = isSet(ebx7, cpuid_SHA)
131-
132136
var maxExtendedInformation uint32
133137
maxExtendedInformation, _, _, _ = cpuid(0x80000000, 0)
134138

0 commit comments

Comments
 (0)