Conversation
…s instead of raw pointers
…uffers. Verify that there is enough capacity to hold the data before filling them to avoid buffer overflows. Treat them as MaybeUninit until they're filled to avoid exposining uninitialized memory.
…erations are now wrapped in safe abstractions that verify preconditions
Contributor
Author
|
For context, this is part of the work to migrate |
This was referenced Oct 30, 2025
Merged
okaneco
reviewed
Oct 31, 2025
okaneco
reviewed
Nov 5, 2025
okaneco
reviewed
Nov 8, 2025
Owner
|
Haven't made much benchmarks on my own, but this seems to work quite well. |
Owner
|
No relevant regressions on Zen3, Zen1 and Haswell. |
Contributor
Author
|
I've resolved the conflicts. CI passed. This should now be ready to go. |
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.
Since Rust 1.86 functions with
#[target_feature=...]annotations don't need to beunsafethemselves, and the same goes for intrinsics that don't operate on raw pointers. They are still unsafe to call from functions not annotated with a matching#[target_feature=...].This PR does 4 things:
unsafe fnbecause of AVX into regularfn(needs Rust 1.86+ released in April 2025)Vec::extend_from_slicein place of manual bookkeeping,unsafe set_len()and handwritten copy loopsunsafeinto a safe function that checks all necessary preconditionsPerformance is the same or slightly better than before according to
cargo benchon my Zen4 machine.I have added a test to verify correctness of the AVX2 implementation against the scalar one, and the results are bit-identical. I have also manually tested this for correctness using the integration into
image: image-rs/image#2636This is best reviewed commit by commit; the combined diff can be difficult to follow.