aboutsummaryrefslogtreecommitdiff
path: root/src/internal/cpu/cpu.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2025-06-12 15:24:22 -0400
committerAustin Clements <austin@google.com>2025-06-13 07:16:03 -0700
commit9b9af3d6386d7564d71ff61468cea597bf0511bc (patch)
tree3e1a479af66d059658a8294a3b23b8bef5c5d303 /src/internal/cpu/cpu.go
parentdfa6c7426316fb81c5f29b260b2de7822680ffd3 (diff)
downloadgo-9b9af3d6386d7564d71ff61468cea597bf0511bc.tar.xz
[dev.simd] internal/cpu: add AVX-512-CD and DQ, and derived "basic AVX-512"
This adds detection for the CD and DQ sub-features of x86 AVX-512. Building on these, we also add a "derived" AVX-512 feature that bundles together the basic usable subset of subfeatures. Despite the F in AVX-512-F standing for "foundation", AVX-512-F+BW+DQ+VL together really form the basic usable subset of AVX-512 functionality. These have also all been supported together by almost every CPU, and are guaranteed by GOAMD64=v4, so there's little point in separating them out. Change-Id: I34356502bd1853ba2372e48db0b10d55cffe07a1 Reviewed-on: https://go-review.googlesource.com/c/go/+/680899 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/internal/cpu/cpu.go')
-rw-r--r--src/internal/cpu/cpu.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/internal/cpu/cpu.go b/src/internal/cpu/cpu.go
index 760dc0b469..a93eb54ddf 100644
--- a/src/internal/cpu/cpu.go
+++ b/src/internal/cpu/cpu.go
@@ -31,8 +31,11 @@ var X86 struct {
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
@@ -160,6 +163,10 @@ var RISCV64 struct {
//go:linkname S390X
//go:linkname RISCV64
+// doDerived, if non-nil, is called after processing GODEBUG to set "derived"
+// feature flags.
+var doDerived func()
+
// Initialize examines the processor and sets the relevant variables above.
// This is called by the runtime package early in program initialization,
// before normal init functions are run. env is set by runtime if the OS supports
@@ -167,6 +174,9 @@ var RISCV64 struct {
func Initialize(env string) {
doinit()
processOptions(env)
+ if doDerived != nil {
+ doDerived()
+ }
}
// options contains the cpu debug options that can be used in GODEBUG.