This CL amends HasAVX512 flag with GFNI check.
This is needed because our SIMD API supports Galois Field operations.
Change-Id: I3e957b7b2215d2b7b6b8a7a0ca3e2e60d453b2e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/685295
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
// in addition to the cpuid feature bit being set.
// The struct is padded to avoid false sharing.
var X86 struct {
- _ CacheLinePad
- HasAES bool
- HasADX bool
- HasAVX bool
- HasAVX2 bool
- HasAVX512 bool // Virtual feature: F+CD+BW+DQ+VL
- HasAVX512F bool
- HasAVX512CD bool
- HasAVX512BW bool
- HasAVX512DQ bool
- HasAVX512VL bool
- HasBMI1 bool
- HasBMI2 bool
- HasERMS bool
- HasFSRM bool
- HasFMA bool
- HasOSXSAVE bool
- HasPCLMULQDQ bool
- HasPOPCNT bool
- HasRDTSCP bool
- HasSHA bool
- HasSSE3 bool
- HasSSSE3 bool
- HasSSE41 bool
- HasSSE42 bool
- _ CacheLinePad
+ _ CacheLinePad
+ HasAES bool
+ HasADX bool
+ HasAVX bool
+ HasAVX2 bool
+ HasAVX512GFNI bool // Virtual feature: F+CD+BW+DQ+VL+GFNI
+ HasAVX512 bool // Virtual feature: F+CD+BW+DQ+VL
+ HasAVX512F bool
+ HasAVX512CD bool
+ HasAVX512BW bool
+ HasAVX512DQ bool
+ HasAVX512VL bool
+ HasBMI1 bool
+ HasBMI2 bool
+ HasERMS bool
+ HasFSRM bool
+ HasFMA bool
+ HasGFNI bool
+ HasOSXSAVE bool
+ HasPCLMULQDQ bool
+ HasPOPCNT bool
+ HasRDTSCP bool
+ HasSHA bool
+ HasSSE3 bool
+ HasSSSE3 bool
+ HasSSE41 bool
+ HasSSE42 bool
+ _ CacheLinePad
}
// The booleans in ARM contain the correspondingly named cpu feature bit.
cpuid_SSE3 = 1 << 0
cpuid_PCLMULQDQ = 1 << 1
cpuid_SSSE3 = 1 << 9
+ cpuid_GFNI = 1 << 8
cpuid_FMA = 1 << 12
cpuid_SSE41 = 1 << 19
cpuid_SSE42 = 1 << 20
return
}
- _, ebx7, _, edx7 := cpuid(7, 0)
+ _, ebx7, ecx7, edx7 := cpuid(7, 0)
X86.HasBMI1 = isSet(ebx7, cpuid_BMI1)
X86.HasAVX2 = isSet(ebx7, cpuid_AVX2) && osSupportsAVX
X86.HasBMI2 = isSet(ebx7, cpuid_BMI2)
}
X86.HasFSRM = isSet(edx7, cpuid_FSRM)
+ X86.HasGFNI = isSet(ecx7, cpuid_GFNI)
var maxExtendedInformation uint32
maxExtendedInformation, _, _, _ = cpuid(0x80000000, 0)
// it. GOAMD64=v4 also implies exactly this set, and these are all
// included in AVX10.1.
X86.HasAVX512 = X86.HasAVX512F && X86.HasAVX512CD && X86.HasAVX512BW && X86.HasAVX512DQ && X86.HasAVX512VL
+ X86.HasAVX512GFNI = X86.HasAVX512 && X86.HasGFNI
}
}
import "internal/cpu"
+// HasAVX512GFNI checks AVX512 CPU feature F+CD+BW+DQ+VL+GFNI.
+func HasAVX512GFNI() bool {
+ return cpu.X86.HasAVX512GFNI
+}
+
// HasAVX512 checks AVX512 CPU feature F+CD+BW+DQ+VL.
func HasAVX512() bool {
return cpu.X86.HasAVX512
v.y = &y
sink = y
- if !simd.HasAVX512() {
+ if !simd.HasAVX512GFNI() {
t.Skip("Test requires HasAVX512, not available on this hardware")
return
}
}
func TestVectorConversion(t *testing.T) {
- if !simd.HasAVX512() {
+ if !simd.HasAVX512GFNI() {
t.Skip("Test requires HasAVX512, not available on this hardware")
return
}
}
func TestMaskConversion(t *testing.T) {
- if !simd.HasAVX512() {
+ if !simd.HasAVX512GFNI() {
t.Skip("Test requires HasAVX512, not available on this hardware")
return
}
}
func TestMaskedAdd(t *testing.T) {
- if !simd.HasAVX512() {
+ if !simd.HasAVX512GFNI() {
t.Skip("Test requires HasAVX512, not available on this hardware")
return
}