-
Notifications
You must be signed in to change notification settings - Fork 21
Add methods for storing vectors back to memory #181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
(Will add changeling entry upon approval.) |
valadaptive
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good! Just a few minor code style nits.
fearless_simd_gen/src/ops.rs
Outdated
| /// `[f32; 4]` for `f32x4<S>`) or a reference to it. | ||
| AsArray { kind: RefKind }, | ||
| /// Takes a vector and a mutable reference to an array, and stores the vector elements into the array. | ||
| ToArray, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should be renamed StoreArray?
|
Note that storing to fixed-size slices involves a massive footgun: https://github.com/okaneco/safe_unaligned_simd?tab=readme-ov-file#a-note-on-creating-mutable-array-references-from-slices This isn't a problem for loads, only for stores. I've been pulling my hair for an hour debugging something that absolutely should work but didn't because of this footgun, and that's how it came to be documented in that repo's README. The best way to avoid it that I can think of is to make the output slice a |
If you use the The only way to fall victim to this footgun in fearless_simd is if you use the |
|
I didn't realize that was an option. If there's already a I think they should either be removed, or at the very least footgun should be mentioned in their doc comment. |
| fn from_slice(simd: S, slice: &[Self::Element]) -> Self; | ||
| #[doc = r" Store a SIMD vector into a slice."] | ||
| #[doc = r""] | ||
| #[doc = r" The slice must be the proper width."] |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
I think at least internally we still need the methods... And making it private would be a bit of a pain I think. |
Following up on #181 (comment)
|
Well, if they can't be made |
As per title, by having this, we don't have to store them back using
copy_from_slice(which may or may not optimize into vector store instructions) but can use methods that use the corresponding intrinsics under the hood.