Repository navigation
Stable simd - #379
Stable simd#379Dr-Emann wants to merge 3 commits into
Conversation
11be30d to
253c2af
Compare
CI builds with `-C target-cpu=native`, and without `--target`, Cargo applies `RUSTFLAGS` to proc macros too. The cached `fearless_simd_macros` proc macro was built on a runner with more CPU features than later runners which restored it from the cache, so rustc crashed with SIGILL when it loaded the macro. Cached dependencies could fail the same way at test time. Add a hash of the target features `-C target-cpu=native` enables (from `rustc --print cfg`) to the cache key, so a cache is only restored on runners with the same target features. Unlike hashing all of /proc/cpuinfo's flags, runners with different CPU models but the same target features still share a cache.
The `simd` feature now builds on stable Rust. The vectorized array store operations (or, and, xor, sub) are ported to fearless_simd with the same algorithms: fearless_simd needs either `std` or `libm`, so `libm` is enabled for no_std builds; with `std` enabled, fearless_simd uses std instead. Adds tests comparing each vectorized op against its scalar version at the baseline and detected SIMD levels. CI now checks and tests `simd` on stable, including no_std.
`255 - mask` and `mask ^ 0xFF` both invert a u8 bitmask; `!mask` says so directly.
|
Measured this stack (#379 through #383, head fec473a) on a Zen 5 and read the generated x86 code, in case it helps review. Short version: it builds and passes tests on stable 1.98 and 1.99 with NumbersEPYC 9845,
Workloads dominated by run and bitmap containers (chains of What the binary does on Zen 5From
Two codegen observations
Authored by Claude (claude-fable-5-1) at Evan Schwartz's request. |
|
I reordered the bitonic merge call in xor to match or: passing the newly loaded vector as the second argument (which gets reversed) rather than the vector carried from the previous step, this both keeps the loop carried dependency chain shorter, and seems to also avoid pulling out individual lanes in the loop as well. |
This PR ports the experimental
simdfeature from nightly-onlycore::simdtofearless_simd.Most of the changes come from adapting the existing algorithms to the new API: vector types now carry a generic parameter that we have to carry through operations, helpers, and visitors.
The generics enable compiling implementations for multiple SIMD levels. With
std, runtime CPU detection selects the appropriate implementation on x86/x86-64, allowing a binary to use instructions beyond its compile-time target.no_stdbuilds continue to use compile-time target features.Also add tests comparing SIMD and scalar results, and updates CI to test SIMD on stable, with and without
std.Closes #373
Same as #378, but from a branch inside this repo so I can stack a little.
Open Questions
Should we enable simd by default?
Should we even have a simd feature (or, still have the feature, but have it do nothing, and always enable simd)?