Repository navigation
Conversation
Introduce trait_default_op and the per-backend overrides_trait_default hook so the generator can emit derived operations once in the Simd trait instead of in every backend. This commit only adds the plumbing; generated output is unchanged.
Move operations that can be expressed in terms of other Simd methods out of every backend impl and into shared trait defaults: mask rotation, reversal, selection and bitwise ops, mask/integer conversions, byte-routed and/or/xor, compression/expansion, interleave/deinterleave, widening arithmetic, pairwise dot products, classification, clamp, count_zeros and 8-bit swap_bytes. Backends keep native implementations through overrides_trait_default where that is faster: AVX-512 mask/compact/classify paths, SSE2 count_zeros, native x86 select/neg/interleave/deinterleave, x86 widening, and Neon/Wasm native ops. Operations whose wide-vector split/combine default is already better stay on that path above 128 bits. Generated source shrinks by about 14.1k lines.
Move the common slice accessors, slice conversion helpers and splat body from every vector and mask impl into defaults on SimdBase and SimdMask. This removes four methods from each of the generated vector impls and two from each mask impl. The Array associated type now carries a TryFrom slice bound so the shared from_slice body can construct the lane array.
Collaborator
|
Just let me know if I should try it in vello! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Use trait defaults and override them where necessary instead of re-emitting the same implementation over and over.
On x86 this reduces the build time by 6% in the default configuration in both debug and release modes, measured on a hello world crate that depends on fearless_simd and nothing else, but doesn't actually use any of the functions. The total LoC count is reduced by 11%.
This isn't meant to be merged as is. It is a proof of concept to see if this direction is worth pursuing. This was mostly an exercise to take DeepSeek v4.1 Flash for a spin and see how it performs at agentic work. I haven't reviewed this in depth, and might never get around to reviewing this. This whole exercise plus generated assembly verification and fixing the issues it uncovered in the initial pass cost me $0.44 at official API rates.
This also needs to be measured on Vello benchmarks before landing because some runtime performance regressions might not show up on isolated testcases.