Skip to content

Commit c25276b

Browse files
committed
pfor: move ISA checks into turbopfor package (compile-time)
Also build with GOAMD64=v4, as 3 of our 6 SIMD kernels are AVX512 anyway. This only saves a few instructions, but is straight-forward enough. The effect is more pronounced on the go-stream implementation, where the per-value overhead is higher in general. pfordec % make bench-relative […] benchstat -filter '/impl:go .unit:(Mval/s)' baseline.txt bench.txt goos: linux goarch: amd64 pkg: github.com/Debian/dcs/internal/turbopfor/pfordec cpu: AMD Ryzen 9 9950X3D 16-Core Processor │ baseline.txt │ bench.txt │ │ Mval/s │ Mval/s vs base │ Decode/n=2048/vals=all-zero/impl=go 21.42k ± 2% 22.51k ± 2% +5.11% (p=0.002 n=6) Decode/n=2048/vals=all-constant/impl=go 21.65k ± 1% 21.87k ± 2% +1.02% (p=0.009 n=6) Decode/n=2048/vals=bitpacking-bw1/impl=go 30.20k ± 1% 19.26k ± 0% -36.24% (p=0.002 n=6) Decode/n=2048/vals=bitpacking-bw2/impl=go 33.84k ± 1% 34.80k ± 1% +2.84% (p=0.002 n=6) Decode/n=2048/vals=bitpacking-bw7/impl=go 32.34k ± 0% 33.20k ± 0% +2.66% (p=0.002 n=6) Decode/n=2048/vals=bitpacking-bw1-exc/impl=go 8.017k ± 0% 9.052k ± 1% +12.91% (p=0.002 n=6) Decode/n=2048/vals=bitpacking-bw2-exc/impl=go 9.060k ± 1% 9.168k ± 0% +1.20% (p=0.002 n=6) Decode/n=2048/vals=bitpacking-bw7-exc/impl=go 8.983k ± 1% 9.189k ± 1% +2.29% (p=0.002 n=6) Decode/n=2048/vals=bitpacking-vb-exc/impl=go 19.71k ± 1% 19.38k ± 0% -1.66% (p=0.002 n=6) Decode/n=2048/vals=sparse-exc/impl=go 7.135k ± 0% 7.159k ± 1% ~ (p=0.394 n=6) Decode/n=2048/vals=sparse-vb-exc/impl=go 12.80k ± 3% 12.71k ± 1% ~ (p=0.394 n=6) Decode/n=2048/vals=debian-mix/impl=go 11.87k ± 2% 12.16k ± 1% +2.52% (p=0.002 n=6) Decode/n=2039/vals=all-zero/impl=go 21.54k ± 0% 22.09k ± 1% +2.57% (p=0.002 n=6) Decode/n=2039/vals=all-constant/impl=go 21.58k ± 1% 21.57k ± 9% ~ (p=0.818 n=6) Decode/n=2039/vals=bitpacking-bw1/impl=go 23.43k ± 1% 16.68k ± 0% -28.80% (p=0.002 n=6) Decode/n=2039/vals=bitpacking-bw2/impl=go 25.81k ± 1% 26.03k ± 1% +0.84% (p=0.004 n=6) Decode/n=2039/vals=bitpacking-bw7/impl=go 25.37k ± 4% 25.29k ± 2% ~ (p=0.699 n=6) Decode/n=2039/vals=bitpacking-bw1-exc/impl=go 5.958k ± 0% 6.388k ± 0% +7.23% (p=0.002 n=6) Decode/n=2039/vals=bitpacking-bw2-exc/impl=go 6.558k ± 0% 6.584k ± 1% +0.40% (p=0.022 n=6) Decode/n=2039/vals=bitpacking-bw7-exc/impl=go 6.467k ± 0% 6.535k ± 0% +1.06% (p=0.002 n=6) Decode/n=2039/vals=bitpacking-vb-exc/impl=go 16.38k ± 1% 16.41k ± 1% ~ (p=0.732 n=6) Decode/n=2039/vals=sparse-exc/impl=go 5.944k ± 0% 5.921k ± 1% ~ (p=0.307 n=6) Decode/n=2039/vals=sparse-vb-exc/impl=go 12.27k ± 5% 12.88k ± 0% +4.99% (p=0.002 n=6) Decode/n=2039/vals=debian-mix/impl=go 7.632k ± 2% 7.840k ± 1% +2.73% (p=0.002 n=6) Decode/n=160/vals=all-zero/impl=go 19.66k ± 1% 18.16k ± 16% -7.63% (p=0.002 n=6) Decode/n=160/vals=all-constant/impl=go 14.89k ± 3% 14.51k ± 2% -2.54% (p=0.041 n=6) Decode/n=160/vals=bitpacking-bw1/impl=go 6.840k ± 1% 6.902k ± 1% +0.91% (p=0.002 n=6) Decode/n=160/vals=bitpacking-bw2/impl=go 6.922k ± 1% 6.995k ± 0% ~ (p=0.132 n=6) Decode/n=160/vals=bitpacking-bw7/impl=go 6.961k ± 3% 7.168k ± 1% +2.97% (p=0.026 n=6) Decode/n=160/vals=bitpacking-bw1-exc/impl=go 2.168k ± 3% 2.218k ± 2% ~ (p=0.065 n=6) Decode/n=160/vals=bitpacking-bw2-exc/impl=go 2.228k ± 1% 2.230k ± 1% ~ (p=0.738 n=6) Decode/n=160/vals=bitpacking-bw7-exc/impl=go 2.167k ± 1% 2.182k ± 0% +0.69% (p=0.041 n=6) Decode/n=160/vals=bitpacking-vb-exc/impl=go 6.605k ± 4% 6.612k ± 0% ~ (p=1.000 n=6) Decode/n=160/vals=sparse-exc/impl=go 2.554k ± 1% 2.576k ± 1% +0.88% (p=0.002 n=6) Decode/n=160/vals=sparse-vb-exc/impl=go 11.05k ± 8% 12.18k ± 6% +10.24% (p=0.015 n=6) Decode/n=160/vals=debian-mix/impl=go 2.231k ± 2% 2.228k ± 1% ~ (p=0.786 n=6) geomean 10.11k 10.04k -0.68% […] benchstat -filter '/impl:go-stream .unit:(Mval/s)' baseline.txt bench.txt goos: linux goarch: amd64 pkg: github.com/Debian/dcs/internal/turbopfor/pfordec cpu: AMD Ryzen 9 9950X3D 16-Core Processor │ baseline.txt │ bench.txt │ │ Mval/s │ Mval/s vs base │ Decode/n=2048/vals=all-zero/impl=go-stream 20.21k ± 1% 20.41k ± 1% ~ (p=0.093 n=6) Decode/n=2048/vals=all-constant/impl=go-stream 20.35k ± 2% 20.68k ± 2% +1.62% (p=0.041 n=6) Decode/n=2048/vals=bitpacking-bw1/impl=go-stream 24.71k ± 0% 24.84k ± 1% +0.55% (p=0.002 n=6) Decode/n=2048/vals=bitpacking-bw2/impl=go-stream 30.56k ± 0% 30.72k ± 0% +0.52% (p=0.015 n=6) Decode/n=2048/vals=bitpacking-bw7/impl=go-stream 30.48k ± 1% 30.73k ± 0% +0.80% (p=0.002 n=6) Decode/n=2048/vals=bitpacking-bw1-exc/impl=go-stream 8.728k ± 0% 8.891k ± 0% +1.87% (p=0.002 n=6) Decode/n=2048/vals=bitpacking-bw2-exc/impl=go-stream 8.861k ± 0% 8.919k ± 1% +0.65% (p=0.019 n=6) Decode/n=2048/vals=bitpacking-bw7-exc/impl=go-stream 8.816k ± 1% 9.023k ± 0% +2.35% (p=0.002 n=6) Decode/n=2048/vals=bitpacking-vb-exc/impl=go-stream 18.69k ± 0% 18.85k ± 0% +0.87% (p=0.002 n=6) Decode/n=2048/vals=sparse-exc/impl=go-stream 7.006k ± 1% 7.061k ± 1% +0.79% (p=0.043 n=6) Decode/n=2048/vals=sparse-vb-exc/impl=go-stream 12.13k ± 3% 12.31k ± 0% ~ (p=0.065 n=6) Decode/n=2048/vals=debian-mix/impl=go-stream 11.53k ± 2% 11.68k ± 0% +1.29% (p=0.015 n=6) Decode/n=2039/vals=all-zero/impl=go-stream 20.22k ± 0% 20.19k ± 2% ~ (p=0.485 n=6) Decode/n=2039/vals=all-constant/impl=go-stream 20.23k ± 1% 20.40k ± 4% ~ (p=0.240 n=6) Decode/n=2039/vals=bitpacking-bw1/impl=go-stream 20.11k ± 0% 20.13k ± 0% ~ (p=0.132 n=6) Decode/n=2039/vals=bitpacking-bw2/impl=go-stream 24.16k ± 0% 24.18k ± 0% +0.10% (p=0.006 n=6) Decode/n=2039/vals=bitpacking-bw7/impl=go-stream 23.84k ± 0% 23.94k ± 0% +0.43% (p=0.002 n=6) Decode/n=2039/vals=bitpacking-bw1-exc/impl=go-stream 6.285k ± 1% 6.332k ± 1% +0.74% (p=0.002 n=6) Decode/n=2039/vals=bitpacking-bw2-exc/impl=go-stream 6.391k ± 0% 6.431k ± 1% +0.63% (p=0.002 n=6) Decode/n=2039/vals=bitpacking-bw7-exc/impl=go-stream 6.317k ± 0% 6.425k ± 0% +1.70% (p=0.002 n=6) Decode/n=2039/vals=bitpacking-vb-exc/impl=go-stream 15.60k ± 1% 15.66k ± 0% ~ (p=0.331 n=6) Decode/n=2039/vals=sparse-exc/impl=go-stream 5.832k ± 0% 5.820k ± 2% ~ (p=1.000 n=6) Decode/n=2039/vals=sparse-vb-exc/impl=go-stream 11.98k ± 2% 12.39k ± 1% +3.40% (p=0.002 n=6) Decode/n=2039/vals=debian-mix/impl=go-stream 7.436k ± 1% 7.615k ± 1% +2.41% (p=0.002 n=6) Decode/n=160/vals=all-zero/impl=go-stream 17.25k ± 5% 17.53k ± 3% +1.62% (p=0.039 n=6) Decode/n=160/vals=all-constant/impl=go-stream 12.61k ± 1% 12.21k ± 1% -3.16% (p=0.002 n=6) Decode/n=160/vals=bitpacking-bw1/impl=go-stream 6.781k ± 1% 6.798k ± 0% +0.24% (p=0.002 n=6) Decode/n=160/vals=bitpacking-bw2/impl=go-stream 7.146k ± 3% 7.184k ± 1% ~ (p=0.240 n=6) Decode/n=160/vals=bitpacking-bw7/impl=go-stream 7.510k ± 3% 7.609k ± 1% +1.33% (p=0.011 n=6) Decode/n=160/vals=bitpacking-bw1-exc/impl=go-stream 2.197k ± 1% 2.171k ± 1% ~ (p=0.061 n=6) Decode/n=160/vals=bitpacking-bw2-exc/impl=go-stream 2.164k ± 2% 2.156k ± 1% ~ (p=0.310 n=6) Decode/n=160/vals=bitpacking-bw7-exc/impl=go-stream 2.150k ± 1% 2.168k ± 1% +0.88% (p=0.019 n=6) Decode/n=160/vals=bitpacking-vb-exc/impl=go-stream 6.646k ± 1% 6.644k ± 1% ~ (p=0.909 n=6) Decode/n=160/vals=sparse-exc/impl=go-stream 2.530k ± 1% 2.549k ± 1% +0.75% (p=0.015 n=6) Decode/n=160/vals=sparse-vb-exc/impl=go-stream 10.39k ± 6% 11.19k ± 4% +7.69% (p=0.015 n=6) Decode/n=160/vals=debian-mix/impl=go-stream 2.181k ± 1% 2.163k ± 1% -0.85% (p=0.006 n=6) geomean 9.716k 9.800k +0.87% pforenc % make bench-relative […] benchstat -filter '/impl:go .unit:(Mval/s)' baseline.txt bench.txt goos: linux goarch: amd64 pkg: github.com/Debian/dcs/internal/turbopfor/pforenc cpu: AMD Ryzen 9 9950X3D 16-Core Processor │ baseline.txt │ bench.txt │ │ Mval/s │ Mval/s vs base │ Encode/n=2048/vals=all-zero/impl=go 19.21k ± 1% 19.17k ± 6% ~ (p=0.310 n=6) Encode/n=2048/vals=all-constant/impl=go 19.25k ± 1% 19.06k ± 6% ~ (p=0.310 n=6) Encode/n=2048/vals=bitpacking-bw1/impl=go 6.649k ± 0% 7.283k ± 3% +9.53% (p=0.002 n=6) Encode/n=2048/vals=bitpacking-bw2/impl=go 6.424k ± 0% 6.975k ± 2% +8.58% (p=0.002 n=6) Encode/n=2048/vals=bitpacking-bw7/impl=go 5.253k ± 0% 5.559k ± 0% +5.84% (p=0.002 n=6) Encode/n=2048/vals=bitpacking-bw1-exc/impl=go 2.055k ± 10% 2.151k ± 8% +4.67% (p=0.039 n=6) Encode/n=2048/vals=bitpacking-bw2-exc/impl=go 2.083k ± 1% 2.086k ± 3% ~ (p=0.149 n=6) Encode/n=2048/vals=bitpacking-bw7-exc/impl=go 2.232k ± 1% 2.301k ± 1% +3.09% (p=0.002 n=6) Encode/n=2048/vals=bitpacking-vb-exc/impl=go 1.696k ± 3% 1.728k ± 2% +1.86% (p=0.002 n=6) Encode/n=2048/vals=sparse-exc/impl=go 2.997k ± 1% 3.138k ± 1% +4.70% (p=0.002 n=6) Encode/n=2048/vals=sparse-vb-exc/impl=go 1.825k ± 1% 1.868k ± 1% +2.33% (p=0.002 n=6) Encode/n=2048/vals=debian-mix/impl=go 2.150k ± 2% 2.245k ± 1% +4.42% (p=0.002 n=6) Encode/n=2039/vals=all-zero/impl=go 18.80k ± 2% 18.70k ± 1% ~ (p=0.699 n=6) Encode/n=2039/vals=all-constant/impl=go 18.48k ± 4% 18.72k ± 1% ~ (p=0.290 n=6) Encode/n=2039/vals=bitpacking-bw1/impl=go 6.014k ± 0% 6.474k ± 2% +7.64% (p=0.002 n=6) Encode/n=2039/vals=bitpacking-bw2/impl=go 5.739k ± 10% 6.125k ± 0% +6.73% (p=0.002 n=6) Encode/n=2039/vals=bitpacking-bw7/impl=go 4.668k ± 1% 4.931k ± 2% +5.63% (p=0.002 n=6) Encode/n=2039/vals=bitpacking-bw1-exc/impl=go 1.907k ± 1% 1.986k ± 0% +4.14% (p=0.002 n=6) Encode/n=2039/vals=bitpacking-bw2-exc/impl=go 1.867k ± 3% 1.974k ± 3% +5.70% (p=0.004 n=6) Encode/n=2039/vals=bitpacking-bw7-exc/impl=go 1.932k ± 7% 1.995k ± 0% ~ (p=0.084 n=6) Encode/n=2039/vals=bitpacking-vb-exc/impl=go 1.563k ± 3% 1.579k ± 3% ~ (p=0.143 n=6) Encode/n=2039/vals=sparse-exc/impl=go 2.974k ± 1% 3.135k ± 0% +5.41% (p=0.002 n=6) Encode/n=2039/vals=sparse-vb-exc/impl=go 1.843k ± 4% 1.944k ± 0% +5.48% (p=0.002 n=6) Encode/n=2039/vals=debian-mix/impl=go 1.952k ± 1% 2.050k ± 1% +4.97% (p=0.002 n=6) Encode/n=160/vals=all-zero/impl=go 15.93k ± 6% 15.65k ± 5% ~ (p=0.818 n=6) Encode/n=160/vals=all-constant/impl=go 15.56k ± 5% 15.54k ± 4% ~ (p=1.000 n=6) Encode/n=160/vals=bitpacking-bw1/impl=go 3.454k ± 0% 3.464k ± 1% ~ (p=0.247 n=6) Encode/n=160/vals=bitpacking-bw2/impl=go 3.295k ± 0% 3.296k ± 2% ~ (p=0.558 n=6) Encode/n=160/vals=bitpacking-bw7/impl=go 2.736k ± 0% 2.742k ± 0% ~ (p=0.078 n=6) Encode/n=160/vals=bitpacking-bw1-exc/impl=go 1.207k ± 0% 1.213k ± 1% ~ (p=0.199 n=6) Encode/n=160/vals=bitpacking-bw2-exc/impl=go 1.208k ± 3% 1.177k ± 0% -2.57% (p=0.019 n=6) Encode/n=160/vals=bitpacking-bw7-exc/impl=go 1.260k ± 1% 1.263k ± 1% ~ (p=0.102 n=6) Encode/n=160/vals=bitpacking-vb-exc/impl=go 1.067k ± 1% 1.034k ± 0% -3.14% (p=0.002 n=6) Encode/n=160/vals=sparse-exc/impl=go 2.627k ± 6% 2.635k ± 0% ~ (p=0.056 n=6) Encode/n=160/vals=sparse-vb-exc/impl=go 1.874k ± 5% 1.849k ± 0% ~ (p=0.368 n=6) Encode/n=160/vals=debian-mix/impl=go 1.202k ± 0% 1.161k ± 0% -3.45% (p=0.002 n=6) geomean 3.363k 3.439k +2.28% […] benchstat -filter '/impl:go-stream .unit:(Mval/s)' baseline.txt bench.txt goos: linux goarch: amd64 pkg: github.com/Debian/dcs/internal/turbopfor/pforenc cpu: AMD Ryzen 9 9950X3D 16-Core Processor │ baseline.txt │ bench.txt │ │ Mval/s │ Mval/s vs base │ Encode/n=2048/vals=all-zero/impl=go-stream 2.208k ± 6% 2.193k ± 1% ~ (p=0.394 n=6) Encode/n=2048/vals=all-constant/impl=go-stream 2.122k ± 5% 2.056k ± 7% ~ (p=0.180 n=6) Encode/n=2048/vals=bitpacking-bw1/impl=go-stream 1.776k ± 0% 1.827k ± 1% +2.84% (p=0.002 n=6) Encode/n=2048/vals=bitpacking-bw2/impl=go-stream 1.758k ± 0% 1.821k ± 2% +3.53% (p=0.002 n=6) Encode/n=2048/vals=bitpacking-bw7/impl=go-stream 1.651k ± 0% 1.723k ± 1% +4.36% (p=0.002 n=6) Encode/n=2048/vals=bitpacking-bw1-exc/impl=go-stream 1.069k ± 9% 1.149k ± 2% +7.39% (p=0.002 n=6) Encode/n=2048/vals=bitpacking-bw2-exc/impl=go-stream 1.120k ± 1% 1.165k ± 2% +4.06% (p=0.002 n=6) Encode/n=2048/vals=bitpacking-bw7-exc/impl=go-stream 1.163k ± 4% 1.131k ± 19% ~ (p=0.167 n=6) Encode/n=2048/vals=bitpacking-vb-exc/impl=go-stream 979.5 ± 4% 979.3 ± 1% ~ (p=1.000 n=6) Encode/n=2048/vals=sparse-exc/impl=go-stream 1.347k ± 0% 1.385k ± 0% +2.78% (p=0.002 n=6) Encode/n=2048/vals=sparse-vb-exc/impl=go-stream 1.040k ± 5% 1.060k ± 4% +1.88% (p=0.037 n=6) Encode/n=2048/vals=debian-mix/impl=go-stream 1.138k ± 1% 1.179k ± 2% +3.60% (p=0.002 n=6) Encode/n=2039/vals=all-zero/impl=go-stream 2.223k ± 12% 2.289k ± 0% +3.01% (p=0.026 n=6) Encode/n=2039/vals=all-constant/impl=go-stream 2.068k ± 8% 2.273k ± 1% +9.91% (p=0.002 n=6) Encode/n=2039/vals=bitpacking-bw1/impl=go-stream 1.736k ± 0% 1.843k ± 1% +6.19% (p=0.002 n=6) Encode/n=2039/vals=bitpacking-bw2/impl=go-stream 1.714k ± 4% 1.823k ± 0% +6.36% (p=0.002 n=6) Encode/n=2039/vals=bitpacking-bw7/impl=go-stream 1.597k ± 1% 1.703k ± 4% +6.60% (p=0.002 n=6) Encode/n=2039/vals=bitpacking-bw1-exc/impl=go-stream 1.071k ± 1% 1.105k ± 2% +3.22% (p=0.002 n=6) Encode/n=2039/vals=bitpacking-bw2-exc/impl=go-stream 1.079k ± 4% 1.121k ± 1% +3.89% (p=0.002 n=6) Encode/n=2039/vals=bitpacking-bw7-exc/impl=go-stream 1.115k ± 0% 1.147k ± 5% ~ (p=0.058 n=6) Encode/n=2039/vals=bitpacking-vb-exc/impl=go-stream 970.1 ± 3% 993.3 ± 5% ~ (p=0.394 n=6) Encode/n=2039/vals=sparse-exc/impl=go-stream 1.353k ± 4% 1.383k ± 3% +2.18% (p=0.024 n=6) Encode/n=2039/vals=sparse-vb-exc/impl=go-stream 1.077k ± 4% 1.124k ± 3% +4.32% (p=0.002 n=6) Encode/n=2039/vals=debian-mix/impl=go-stream 1.067k ± 3% 1.065k ± 2% ~ (p=0.732 n=6) Encode/n=160/vals=all-zero/impl=go-stream 2.046k ± 1% 1.825k ± 1% -10.76% (p=0.002 n=6) Encode/n=160/vals=all-constant/impl=go-stream 2.038k ± 2% 1.817k ± 1% -10.84% (p=0.002 n=6) Encode/n=160/vals=bitpacking-bw1/impl=go-stream 1.419k ± 0% 1.330k ± 3% -6.27% (p=0.002 n=6) Encode/n=160/vals=bitpacking-bw2/impl=go-stream 1.384k ± 0% 1.269k ± 3% -8.31% (p=0.002 n=6) Encode/n=160/vals=bitpacking-bw7/impl=go-stream 1.266k ± 0% 1.155k ± 1% -8.73% (p=0.002 n=6) Encode/n=160/vals=bitpacking-bw1-exc/impl=go-stream 798.7 ± 1% 801.8 ± 0% ~ (p=0.065 n=6) Encode/n=160/vals=bitpacking-bw2-exc/impl=go-stream 797.0 ± 2% 787.2 ± 2% ~ (p=0.554 n=6) Encode/n=160/vals=bitpacking-bw7-exc/impl=go-stream 821.3 ± 2% 825.1 ± 0% ~ (p=0.065 n=6) Encode/n=160/vals=bitpacking-vb-exc/impl=go-stream 751.3 ± 2% 721.0 ± 3% -4.03% (p=0.002 n=6) Encode/n=160/vals=sparse-exc/impl=go-stream 1.296k ± 3% 1.235k ± 3% -4.71% (p=0.002 n=6) Encode/n=160/vals=sparse-vb-exc/impl=go-stream 1.080k ± 3% 1.000k ± 4% -7.41% (p=0.002 n=6) Encode/n=160/vals=debian-mix/impl=go-stream 797.3 ± 1% 772.1 ± 4% ~ (p=0.394 n=6) geomean 1.292k 1.294k +0.15%
1 parent d60b6d4 commit c25276b

13 files changed

Lines changed: 57 additions & 17 deletions

internal/turbopfor/cpu_amd64.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//go:build goexperiment.simd && amd64 && !amd64.v3
2+
3+
package turbopfor
4+
5+
import "simd/archsimd"
6+
7+
// Compiled with GOAMD64=v1 or =v2,
8+
// need to use runtime detection to find supported ISAs
9+
10+
var HasAVX2 = archsimd.X86.AVX2()
11+
12+
var HasAVX512 = archsimd.X86.AVX512()

internal/turbopfor/cpu_amd64v3.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//go:build goexperiment.simd && amd64 && amd64.v3 && !amd64.v4
2+
3+
package turbopfor
4+
5+
import "simd/archsimd"
6+
7+
const HasAVX2 = true
8+
9+
var HasAVX512 = archsimd.X86.AVX512()

internal/turbopfor/cpu_amd64v4.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//go:build goexperiment.simd && amd64 && amd64.v4
2+
3+
package turbopfor
4+
5+
const HasAVX2 = true
6+
7+
const HasAVX512 = true

internal/turbopfor/cpu_nosimd.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//go:build !goexperiment.simd || !amd64
2+
3+
package turbopfor
4+
5+
const HasAVX2 = false
6+
7+
const HasAVX512 = false

internal/turbopfor/pfordec/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Required for the Go compiler to intrinsify LZCNT, for example.
2-
export GOAMD64=v3
2+
export GOAMD64=v4
33
# Required for SIMD support with Go 1.27.
44
# Always set (even before adding SIMD code) so the baseline is stable.
55
export GOEXPERIMENT=simd

internal/turbopfor/pfordec/bitunpack256v_amd64.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
package pfordec
44

5-
import "simd/archsimd"
5+
import (
6+
"simd/archsimd"
7+
8+
"github.com/Debian/dcs/internal/turbopfor"
9+
)
610

711
func bitunpack256v32(fullinput []byte, fulloutput []uint32, nbits int) (read int) {
8-
if !hasAVX2 {
12+
if !turbopfor.HasAVX2 {
913
return bitunpack256v32Scalar(fullinput, fulloutput, nbits)
1014
}
1115
output := (*[256]uint32)(fulloutput[:256])

internal/turbopfor/pfordec/bitunpack256vex_amd64.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ package pfordec
55
import (
66
"math/bits"
77
"simd/archsimd"
8+
9+
"github.com/Debian/dcs/internal/turbopfor"
810
)
911

1012
// bitunpack256v32Ex is like bitunpack256v32, but with exception decoding fused
1113
// into the same loop (instead of a separate pass).
1214
func bitunpack256v32Ex(input []byte, fulloutput []uint32, nbits int, exmap *[32]byte, exceptions *[256]uint32) (read int) {
13-
if !hasAVX512 {
15+
if !turbopfor.HasAVX512 {
1416
return bitunpack256v32ExScalar(input, fulloutput, nbits, exmap, exceptions)
1517
}
1618
output := (*[256]uint32)(fulloutput[:256])

internal/turbopfor/pfordec/bitunpack_amd64.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ package pfordec
44

55
import (
66
"simd/archsimd"
7-
)
87

9-
var hasAVX512 = archsimd.X86.AVX512()
8+
"github.com/Debian/dcs/internal/turbopfor"
9+
)
1010

1111
// seqUnpackConsts are the per-lane constants of bitunpackSIMD for one
1212
// bit width. This allows keeping the dispatch unit busy with vector
@@ -32,7 +32,7 @@ var precomputed = func() (t [33]seqUnpackConsts) {
3232
}()
3333

3434
func bitunpack(input []byte, output []uint32, bitWidth int) (read int) {
35-
if !hasAVX2 {
35+
if !turbopfor.HasAVX2 {
3636
return bitunpackScalar(input, output, bitWidth)
3737
}
3838
if bitWidth == 0 {

internal/turbopfor/pfordec/constant_amd64.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
package pfordec
44

5-
import "simd/archsimd"
5+
import (
6+
"simd/archsimd"
67

7-
var hasAVX2 = archsimd.X86.AVX2()
8+
"github.com/Debian/dcs/internal/turbopfor"
9+
)
810

911
func fillConstant(output []uint32, val uint32) {
10-
if !hasAVX2 {
12+
if !turbopfor.HasAVX2 {
1113
fillConstantScalar(output, val)
1214
return
1315
}
-322 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)