simd: add some inner-product benchmarks
Some hand-unrolling of important methods
was tried, and shown to improve results.
Results from
```
export GOEXPERIMENT=simd
for R in {1..25} ; do
go test -bench=B -run=none -count=1 -ldflags=-randlayout=$R . | tee -a arm64-128.log
GODEBUG=simd=0 go test -bench=B -run=none -count=1 -ldflags=-randlayout=$R . | tee -a arm64-0.log
GOARCH=amd64 go test -bench=B -run=none -count=1 -ldflags=-randlayout=$R . | tee -a amd64-128.log
GOARCH=amd64 GODEBUG=simd=+256 go test -bench=B -run=none -count=1 -ldflags=-randlayout=$R . | tee -a amd64-256.log
GOARCH=amd64 GODEBUG=simd=0 go test -bench=B -run=none -count=1 -ldflags=-randlayout=$R . | tee -a amd64-0.log
GOARCH=wasm GOOS=wasip1 go test -bench=B -run=none -count=1 -ldflags=-randlayout=$R . | tee -a wasm-128.log
GOARCH=wasm GOOS=wasip1 GODEBUG=simd=0 go test -bench=B -run=none -count=1 -ldflags=-randlayout=$R . | tee -a wasm-0.log
echo done with $R
done
```
run on a quiet-ish Apple laptop
then cleaned with
```
for i in *.log ; do sed -e '1,$s/-10//' -i "" $i; done
```
```
benchstat -ignore goarch,cpu,goos arm64*log amd64*log wasm*log
pkg: simd
│ arm64-0.log │ arm64-128.log │ amd64-0.log │ amd64-128.log │ amd64-256.log │ wasm-0.log │ wasm-128.log │
│ sec/op │ sec/op vs base │ sec/op vs base │ sec/op vs base │ sec/op vs base │ sec/op vs base │ sec/op vs base │
IPFMA 465.99µ ± 1% 68.17µ ± 0% -85.37% (p=0.000 n=25) 567.46µ ± 3% +21.78% (p=0.000 n=25) 126.51µ ± 0% -72.85% (p=0.000 n=25) 166.29µ ± 0% -64.31% (p=0.000 n=25) 2839.92µ ± 1% +509.44% (p=0.000 n=25) 156.27µ ± 0% -66.47% (p=0.000 n=25)
IP 533.06µ ± 2% 47.64µ ± 0% -91.06% (p=0.000 n=25) 645.00µ ± 0% +21.00% (p=0.000 n=25) 50.16µ ± 0% -90.59% (p=0.000 n=25) 49.39µ ± 0% -90.73% (p=0.000 n=25) 3702.28µ ± 1% +594.53% (p=0.000 n=25) 156.15µ ± 0% -70.71% (p=0.000 n=25)
IPUnroll 521.14µ ± 1% 27.92µ ± 0% -94.64% (p=0.000 n=25) 634.97µ ± 3% +21.84% (p=0.000 n=25) 37.38µ ± 1% -92.83% (p=0.000 n=25) 38.85µ ± 0% -92.54% (p=0.000 n=25) 4543.60µ ± 1% +771.86% (p=0.000 n=25) 97.75µ ± 0% -81.24% (p=0.000 n=25)
IPUnrollMore 531.67µ ± 2% 27.92µ ± 0% -94.75% (p=0.000 n=25) 634.78µ ± 2% +19.40% (p=0.000 n=25) 37.29µ ± 0% -92.99% (p=0.000 n=25) 42.76µ ± 0% -91.96% (p=0.000 n=25) 4679.65µ ± 1% +780.19% (p=0.000 n=25) 96.80µ ± 0% -81.79% (p=0.000 n=25)
IPnosimd0 722.6µ ± 1% 738.3µ ± 1% +2.18% (p=0.000 n=25) 930.1µ ± 1% +28.73% (p=0.000 n=25) 938.6µ ± 1% +29.89% (p=0.000 n=25) 931.8µ ± 1% +28.95% (p=0.000 n=25) 525.2µ ± 0% -27.32% (p=0.000 n=25) 525.2µ ± 0% -27.32% (p=0.000 n=25)
IPnosimd1 522.1µ ± 1% 526.0µ ± 1% +0.76% (p=0.011 n=25) 1049.7µ ± 1% +101.05% (p=0.000 n=25) 1049.5µ ± 1% +101.02% (p=0.000 n=25) 1049.8µ ± 1% +101.07% (p=0.000 n=25) 744.4µ ± 0% +42.58% (p=0.000 n=25) 744.7µ ± 0% +42.64% (p=0.000 n=25)
IPnosimdA 640.2µ ± 0% 643.0µ ± 1% ~ (p=0.088 n=25) 968.7µ ± 1% +51.31% (p=0.000 n=25) 964.3µ ± 1% +50.63% (p=0.000 n=25) 966.5µ ± 1% +50.97% (p=0.000 n=25) 541.7µ ± 0% -15.38% (p=0.000 n=25) 542.0µ ± 0% -15.34% (p=0.000 n=25)
IPnosimdAnotBloop 278.6µ ± 0% 280.1µ ± 0% +0.57% (p=0.022 n=25) 241.4µ ± 0% -13.34% (p=0.000 n=25) 241.4µ ± 0% -13.33% (p=0.000 n=25) 241.4µ ± 0% -13.35% (p=0.000 n=25) 392.2µ ± 0% +40.78% (p=0.000 n=25) 392.1µ ± 0% +40.78% (p=0.000 n=25)
geomean 510.7µ 143.2µ -71.96% 654.5µ +28.15% 194.3µ -61.96% 205.0µ -59.87% 1.441m +182.09% 257.3µ -49.63%
```
Change-Id: I09b912a3b68431972eeb91200f77a3dd95327d91
Reviewed-on: https://go-review.googlesource.com/c/go/+/787561
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
Gopher image by Renee French, licensed under Creative Commons 4.0 Attribution license.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
Official binary distributions are available at https://go.dev/dl/.
After downloading a binary release, visit https://go.dev/doc/install for installation instructions.
If a binary distribution is not available for your combination of operating system and architecture, visit https://go.dev/doc/install/source for source installation instructions.
Go is the work of thousands of contributors. We appreciate your help!
To contribute, please read the contribution guidelines at https://go.dev/doc/contribute.
Note that the Go project uses the issue tracker for bug reports and proposals only. See https://go.dev/wiki/Questions for a list of places to ask questions about the Go language.