Skip to content

Commit

Permalink
tweak CPUID so AVX512 impl only runs on amd
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorropo committed Jun 18, 2024
1 parent 4dc0b91 commit 24dee90
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion xxhash_asm_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,20 @@ package xxhash

import "github.com/klauspost/cpuid/v2"

var useAvx512 = cpuid.CPU.Supports(cpuid.AVX, cpuid.AVX2, cpuid.AVX512DQ, cpuid.AVX512F, cpuid.AVX512VL, cpuid.BMI1)
var useAvx512 = cpuid.CPU.Supports(
cpuid.AVX,
cpuid.AVX2,
cpuid.AVX512DQ,
cpuid.AVX512F,
cpuid.AVX512VL,
cpuid.BMI1,

// Today, vectorized 64 bits integer multiples positively sucks on intel,
// with ILP a single scalar unit is multiple times faster.
// This means sometime we wont be using the AVX512 when under virtualization
// because vendor will be the hypervisor, but in my experience that is rare.
// Most virtualization setups defaults to reporting the vendorid of the host.
) && cpuid.CPU.IsVendor(cpuid.AMD)

// Sum64 computes the 64-bit xxHash digest of b with a zero seed.
func Sum64(b []byte) uint64 {
Expand Down

0 comments on commit 24dee90

Please sign in to comment.