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
import "github.com/klauspost/cpuid"
import "github.com/klauspost/cpuid/v2"
var (
haveAVX2 = cpuid.CPU.AVX2()
haveAVX512 = cpuid.CPU.AVX512F()
haveAVX2 = cpuid.CPU.Supports(cpuid.AVX2)
haveAVX512 = cpuid.CPU.Supports(cpuid.AVX512F)
)

View File

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

4
go.mod
View File

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

4
go.sum
View File

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