aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorAchille Roussel <achille.roussel@gmail.com>2023-10-18 19:21:55 +0000
committerGopher Robot <gobot@golang.org>2023-11-15 18:30:03 +0000
commit8f262a2843a6f3ef32e938ce39c0ffeb84f04a42 (patch)
treeca40845996cae5efdd651a33d1bb60fe7a620e9f /src/runtime
parent6ef98ac87c8a4185c0bace496d84cb3b68f069e3 (diff)
downloadgo-8f262a2843a6f3ef32e938ce39c0ffeb84f04a42.tar.xz
internal/cpu: detect support of AVX512
Extracts changes from that were submitted in other CLs to enable AVX512 detection, notably: - https://go-review.googlesource.com/c/go/+/271521 - https://go-review.googlesource.com/c/go/+/379394 - https://go-review.googlesource.com/c/go/+/502476 This change adds properties to the cpu.X86 fields to enable runtime detection of AVX512, and the hasAVX512F, hasAVX512BW, and hasAVX512VL macros to support bypassing runtime checks in assembly code when GOAMD64=v4 is set. Change-Id: Ia7c3f22f1e66bf1de575aba522cb0d0a55ce791f Reviewed-on: https://go-review.googlesource.com/c/go/+/536257 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Martin Möhrmann <martin@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Martin Möhrmann <martin@golang.org> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Martin Möhrmann <moehrmann@google.com> Commit-Queue: Martin Möhrmann <martin@golang.org> Reviewed-by: Martin Möhrmann <moehrmann@google.com>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/asm_amd64.h3
-rw-r--r--src/runtime/asm_amd64.s12
2 files changed, 9 insertions, 6 deletions
diff --git a/src/runtime/asm_amd64.h b/src/runtime/asm_amd64.h
index f7a8896db6..b263ade802 100644
--- a/src/runtime/asm_amd64.h
+++ b/src/runtime/asm_amd64.h
@@ -20,6 +20,9 @@
#ifdef GOAMD64_v4
#define hasAVX
#define hasAVX2
+#define hasAVX512F
+#define hasAVX512BW
+#define hasAVX512VL
#define hasPOPCNT
#define hasSSE42
#endif
diff --git a/src/runtime/asm_amd64.s b/src/runtime/asm_amd64.s
index ab845fbd8a..1abf4075e0 100644
--- a/src/runtime/asm_amd64.s
+++ b/src/runtime/asm_amd64.s
@@ -144,12 +144,12 @@ GLOBL bad_cpu_msg<>(SB), RODATA, $84
#define commpage64_base_address 0x00007fffffe00000
#define commpage64_cpu_capabilities64 (commpage64_base_address+0x010)
#define commpage64_version (commpage64_base_address+0x01E)
-#define hasAVX512F 0x0000004000000000
-#define hasAVX512CD 0x0000008000000000
-#define hasAVX512DQ 0x0000010000000000
-#define hasAVX512BW 0x0000020000000000
-#define hasAVX512VL 0x0000100000000000
-#define NEED_DARWIN_SUPPORT (hasAVX512F | hasAVX512DQ | hasAVX512CD | hasAVX512BW | hasAVX512VL)
+#define AVX512F 0x0000004000000000
+#define AVX512CD 0x0000008000000000
+#define AVX512DQ 0x0000010000000000
+#define AVX512BW 0x0000020000000000
+#define AVX512VL 0x0000100000000000
+#define NEED_DARWIN_SUPPORT (AVX512F | AVX512DQ | AVX512CD | AVX512BW | AVX512VL)
#else
#define NEED_OS_SUPPORT_AX V4_OS_SUPPORT_AX
#endif