upgrade to cpuid/v2

This commit is contained in:
lukechampine 2021-09-06 12:38:15 -04:00
parent d373079f35
commit 09d3897aaa
4 changed files with 9 additions and 11 deletions

6
cpu.go
View File

@ -2,9 +2,9 @@
package blake3 package blake3
import "github.com/klauspost/cpuid" import "github.com/klauspost/cpuid/v2"
var ( var (
haveAVX2 = cpuid.CPU.AVX2() haveAVX2 = cpuid.CPU.Supports(cpuid.AVX2)
haveAVX512 = cpuid.CPU.AVX512F() haveAVX512 = cpuid.CPU.Supports(cpuid.AVX512F)
) )

View File

@ -3,7 +3,7 @@ package blake3
import ( import (
"syscall" "syscall"
"github.com/klauspost/cpuid" "github.com/klauspost/cpuid/v2"
) )
var ( var (
@ -12,8 +12,8 @@ var (
) )
func init() { func init() {
haveAVX2 = cpuid.CPU.AVX2() haveAVX2 = cpuid.CPU.Supports(cpuid.AVX2)
haveAVX512 = cpuid.CPU.AVX512F() haveAVX512 = cpuid.CPU.Supports(cpuid.AVX512F)
if !haveAVX512 { if !haveAVX512 {
// On some Macs, AVX512 detection is buggy, so fallback to sysctl // On some Macs, AVX512 detection is buggy, so fallback to sysctl
b, _ := syscall.Sysctl("hw.optional.avx512f") b, _ := syscall.Sysctl("hw.optional.avx512f")

4
go.mod
View File

@ -2,6 +2,4 @@ module lukechampine.com/blake3
go 1.13 go 1.13
require ( require github.com/klauspost/cpuid/v2 v2.0.9
github.com/klauspost/cpuid v1.3.1
)

4
go.sum
View File

@ -1,2 +1,2 @@
github.com/klauspost/cpuid v1.3.1 h1:5JNjFYYQrZeKRJ0734q51WCEEn2huer72Dc7K+R/b6s= github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
github.com/klauspost/cpuid v1.3.1/go.mod h1:bYW4mA6ZgKPob1/Dlai2LviZJO7KGI3uoWLd42rAQw4= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=