-
Notifications
You must be signed in to change notification settings - Fork 86
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
Scatter into &mut [MaybeUninit<scalar>]
s instead of &mut [scalar]
#205
Comments
This is a reasonable request but I can already see the "scatter should allow Hrm... Is this a safe function? It seems it has to be, as it fulfills the relevant validity invariant for an ambiguously-typed memory location, so we aren't accessing an invalid value, we're describing a valid value, and that is safe unless done through Open to ideas. Maybe a |
We discussed this elsewhere, but to update this issue: IMO we should support this for |
To elaborate a little, my current understanding: unsafe { u.as_mut_ptr().write(v); } which requires the union to be Allowing it with anything that doesn't fulfill that requires us to either make the function *u = Union::new(val); which either is borderline impossible or ruins the point of a Now, to my mind, the only question is if we should even have the |
probably |
I'm confused where this discussion is going... You can just use |
Uhh, EDIT: I don't think this is actually a good idea though, having reviewed my own code. |
Yeah, I meant internally. It seemed to me like you were suggesting it's unsound to scatter to MaybeUninit. Might be worth seeing what happens with the function signatures when we have vectors of pointers since that will probably change things up anyway. |
Seconding this vote. For the lowest level APIs unsafe APIs like this, using pointers is both more flexible and less error prone. Not just cases like this, but |
I'm hoping this will end up being the second (or third) lowest level API -- lowest level should be: impl<T, const N: usize> Simd<*mut T, N> {
// basically 1:1 with llvm intrinsic
pub unsafe fn scatter_with_align<const ALIGN: usize>(self, values: Simd<T, N>, mask: Mask<T, N>) { ... }
} |
With #315 merged, |
Title. The current API only allows
scatter
ing to initialized buffers, but it shouldn't matter whether the buffer is actually initialized.The text was updated successfully, but these errors were encountered: