cpu: add support for detecting AVX-512

The existing implementation hasn't AVX-512 detection support.
This patch extends cpu package with such a functionality.

Fixes golang/go#41288

Change-Id: Iaddd57c5ff6d73360b77886458b9210b6c446859
Reviewed-on: https://go-review.googlesource.com/c/sys/+/257937
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
This commit is contained in:
Anton Kuklin
2020-09-28 20:51:50 +00:00
committed by Tobias Klauser
parent 9d91bd6205
commit 006507a758
3 changed files with 100 additions and 22 deletions
+11
View File
@@ -30,6 +30,17 @@ func TestAVX2hasAVX(t *testing.T) {
}
}
func TestAVX512HasAVX2AndAVX(t *testing.T) {
if runtime.GOARCH == "amd64" {
if cpu.X86.HasAVX512 && !cpu.X86.HasAVX {
t.Fatal("HasAVX expected true, got false")
}
if cpu.X86.HasAVX512 && !cpu.X86.HasAVX2 {
t.Fatal("HasAVX2 expected true, got false")
}
}
}
func TestARM64minimalFeatures(t *testing.T) {
if runtime.GOARCH != "arm64" || (runtime.GOOS == "darwin" || runtime.GOOS == "ios") {
return