You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf: enable POPCNT in the BMI2, AVX2 and AVX-512 kernels - #10456
#[target_feature(enable = "bmi2")], "avx2" and "avx512f,..." do not imply POPCNT, so count_ones() inside these kernels compiles to a SWAR sequence (with imul for narrow masks) in any build without target-cpu. The bench runners use target-cpu=native, so they won't show a difference.
Changes
Add popcnt to the target features and to the runtime detection of the intersect_by_rank BMI2 kernels and the x86 simd_compress kernels. No other #[target_feature] function in the tree counts bits without it (the fearless_simd levels already enable POPCNT).
Default build, Zen 5, divan medians:
bench
before
after
intersect_by_rank 100k random
3.17 µs
1.93 µs
1.64x
random_rotating 0.5/0.5
9.71 µs
5.67 µs
1.71x
very_sparse_mask_cached 10%/1%
1.91 µs
0.81 µs
2.36x
filter_fixed_widthrandom_i16 0.8
1.60 µs
1.06 µs
1.51x
filter_fixed_widthrandom_i32 0.5
1.49 µs
1.03 µs
1.45x
filter_fixed_widthrandom_i64 0.5
1.13 µs
0.99 µs
1.14x
filter_fixed_widthrandom_i128 0.5 (no kernel)
1.45 µs
1.42 µs
1.02x
The filter numbers are the AVX-512 kernels; the AVX2 ones should show up in the CodSpeed simulation shard, where AFAIK valgrind has no AVX-512.
Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.
For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.
⚠️10 benchmarks spent significant time in system calls
System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.
Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#[target_feature(enable = "bmi2")],"avx2"and"avx512f,..."do not imply POPCNT, socount_ones()inside these kernels compiles to a SWAR sequence (withimulfor narrow masks) in any build withouttarget-cpu. The bench runners usetarget-cpu=native, so they won't show a difference.Changes
Add
popcntto the target features and to the runtime detection of theintersect_by_rankBMI2 kernels and the x86simd_compresskernels. No other#[target_feature]function in the tree counts bits without it (thefearless_simdlevels already enable POPCNT).Default build, Zen 5, divan medians:
intersect_by_rank100k randomrandom_rotating0.5/0.5very_sparse_mask_cached10%/1%filter_fixed_widthrandom_i160.8filter_fixed_widthrandom_i320.5filter_fixed_widthrandom_i640.5filter_fixed_widthrandom_i1280.5 (no kernel)The filter numbers are the AVX-512 kernels; the AVX2 ones should show up in the CodSpeed simulation shard, where AFAIK valgrind has no AVX-512.