-
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
base: main
Are you sure you want to change the base?
Conversation
|
(Will add changeling entry upon approval.) |
| /// Store a SIMD vector into a slice. | ||
| /// | ||
| /// The slice must be the proper width. | ||
| fn store_slice(&self, slice: &mut [Self::Element]); |
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 we should rename to store_into_slice?
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.
I think store_slice is fine.
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.
| /// `[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?
| } else { | ||
| let blocks = (0..block_count).map(|n| { | ||
| let offset = n * num_scalars_per_block; | ||
| let block_idx = proc_macro2::Literal::usize_unsuffixed(n); |
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.
Is there a reason to use usize_unsuffixed here specifically? It definitely results in nicer generated code but we don't seem to use it in many other places.
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.
| /// Store a SIMD vector into a slice. | ||
| /// | ||
| /// The slice must be the proper width. | ||
| fn store_slice(&self, slice: &mut [Self::Element]); |
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.
I think store_slice is fine.

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.