Add #[simd] macro - #347
Open
Shnatsel wants to merge 7 commits into
Open
Conversation
…jects exactly one function boundary
…h the documented use case for vectorize(). Does not affect usage in dispatch!() which dispatches from non-target-feature context. The function itself was already trivial and under -O3 the optimizer would recognize it as trivial and inline it anyway, so adding a function boundary there didn't really work as intended, except under -Os.
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.
My attempt at #338
I am not well-versed in proc macros. While the design of what the macro should expand into is mine, the implementation of the macro and thinking through various edge cases and handling them was largely delegated to Codex (GPT-5.6 Sol Ultra).
Codex summary of the changes
Implemented the standalone
#[simd]proc macro.Key pieces:
fearless_simd_macros0.1.0 with Syn 3.0.4 and no core dependency: implementation, documentation.token.vectorize(#[inline(always)] || { ... }), with no generated outer inline attribute.vectorizehelpers and removed the stale outlined-boundary documentation.Verification passed:
-D warnings.x86_64-unknown-noneno-std build.cargo-rdmeconsistency.git diff --check.Existing unrelated untracked workspace files were left untouched.
Before implementing the macro I investigated
vectorize()and found that it already gets inlined most of the time anyway. It doesn't work well as an inlining barrier, since the function that isn't annotated#[inline]is trival enough for the optimizer to always inline it anyway, even with a large closure body. So I reverted a separatevectorize_inline()which is recorded in commit history, and inlining can instead be controlled with annotation on the function callingvectorize(); the docs on it already show that usage in the example, the doc comment on vectorize() can probably be improved.The proc macro crate is separate from fearless_simd so it doesn't fall under the v1.0 guarantees. I expect to publish it in lockstep with v1.0, although we might ship pre-releases just to make sure it all works. The README points to git but should work with most versions no problem, just wouldn't have as much inlining annotations in
vectorize().