mirror of
https://github.com/fumiama/blake2b-simd.git
synced 2026-06-12 22:40:54 +08:00
Fix benchmarks to report proper values. (#7)
``` $ go test -run=NONE -bench . PASS BenchmarkHash64-4 1000000 1036 ns/op 61.77 MB/s BenchmarkHash128-4 2000000 801 ns/op 159.67 MB/s BenchmarkHash1K-4 500000 2464 ns/op 415.53 MB/s BenchmarkHash8K-4 200000 11212 ns/op 730.60 MB/s BenchmarkHash32K-4 30000 40766 ns/op 803.80 MB/s BenchmarkHash128K-4 10000 163170 ns/op 803.28 MB/s ok github.com/minio/blake2b-simd 10.298s ```
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
//+build !noasm
|
||||
//+build !appengine
|
||||
|
||||
/*
|
||||
* Minio Cloud Storage, (C) 2016 Minio, Inc.
|
||||
*
|
||||
@@ -19,34 +16,13 @@
|
||||
|
||||
package blake2b
|
||||
|
||||
//go:noescape
|
||||
func blockAVXLoop(p []uint8, in, iv, t, f, shffle, out []uint64)
|
||||
|
||||
func compressAVX(d *digest, p []uint8) {
|
||||
|
||||
in := make([]uint64, 8, 8)
|
||||
out := make([]uint64, 8, 8)
|
||||
|
||||
shffle := make([]uint64, 2, 2)
|
||||
// vector for PSHUFB instruction
|
||||
shffle[0] = 0x0201000706050403
|
||||
shffle[1] = 0x0a09080f0e0d0c0b
|
||||
|
||||
in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7] = d.h[0], d.h[1], d.h[2], d.h[3], d.h[4], d.h[5], d.h[6], d.h[7]
|
||||
|
||||
blockAVXLoop(p, in, iv[:], d.t[:], d.f[:], shffle, out)
|
||||
|
||||
d.h[0], d.h[1], d.h[2], d.h[3], d.h[4], d.h[5], d.h[6], d.h[7] = out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7]
|
||||
}
|
||||
|
||||
func compress(d *digest, p []uint8) {
|
||||
// Verifies if AVX2 or AVX is available, use optimized code path.
|
||||
if avx2 {
|
||||
compressAVX2(d, p)
|
||||
return
|
||||
} else if avx {
|
||||
compressAVX(d, p)
|
||||
return
|
||||
} // else { fallback to generic approach.
|
||||
compressGeneric(d, p)
|
||||
} else {
|
||||
compressGeneric(d, p)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user