From 1bea64505206431e86ace12f6e2584136dc1c617 Mon Sep 17 00:00:00 2001 From: Jorropo Date: Thu, 20 Jun 2024 16:08:16 +0200 Subject: [PATCH] gate avx512 behind go1.22 PCALIGN gives a ~12% performance improvement so we really want it, if you are using a previous version of go, too bad please upgrade. --- xxhash_asm_amd64.go | 4 ++-- xxhash_asm_amd64_old.go | 22 ++++++++++++++++++++++ xxhash_avx512_amd64.s | 3 ++- 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 xxhash_asm_amd64_old.go diff --git a/xxhash_asm_amd64.go b/xxhash_asm_amd64.go index d594363..1ff7c47 100644 --- a/xxhash_asm_amd64.go +++ b/xxhash_asm_amd64.go @@ -1,5 +1,5 @@ -//go:build amd64 && !appengine && gc && !purego -// +build amd64,!appengine,gc,!purego +//go:build amd64 && !appengine && gc && !purego && go1.22 +// +build amd64,!appengine,gc,!purego,go1.22 package xxhash diff --git a/xxhash_asm_amd64_old.go b/xxhash_asm_amd64_old.go new file mode 100644 index 0000000..3da4816 --- /dev/null +++ b/xxhash_asm_amd64_old.go @@ -0,0 +1,22 @@ +//go:build amd64 && !appengine && gc && !purego && !go1.22 +// +build amd64,!appengine,gc,!purego,!go1.22 + +// The avx512 impl relies on PCALIGN. + +package xxhash + +// Sum64 computes the 64-bit xxHash digest of b with a zero seed. +func Sum64(b []byte) uint64 { + return sum64Scalar(b) +} + +//go:noescape +func sum64Scalar(b []byte) uint64 + +// extra is a first block before b, it may be nil then skip it. +func writeBlocks(d *Digest, extra *[32]byte, b []byte) { + return writeBlocksScalar(d, extra, b) +} + +//go:noescape +func writeBlocksScalar(d *Digest, extra *[32]byte, b []byte) diff --git a/xxhash_avx512_amd64.s b/xxhash_avx512_amd64.s index b740c32..0bbb86b 100644 --- a/xxhash_avx512_amd64.s +++ b/xxhash_avx512_amd64.s @@ -1,7 +1,8 @@ -//go:build !appengine && gc && !purego +//go:build !appengine && gc && !purego && go1.22 // +build !appengine // +build gc // +build !purego +// +build go1.22 #include "textflag.h"