-
Notifications
You must be signed in to change notification settings - Fork 432
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
Generic over number of simd lanes with rand #1359
Comments
Due to the way SIMD works there are going to be inefficiencies with code generic over lanes. But yes, we should try to at least provide a slow generic version. |
Though I don't know if const generics can even be specialized like this. Which means we face a choice of poor optimization or poor generics. |
huh. I thought rust monomorphizes const generics. I can't imagine where the inefficiency is. Whatever it is might be partially responsible for the simd version of the function I wrote being significantly slower than the non-simd version.
That's what I was thinking, although its is a bit awkward to use right now - the only way I figured out how was by inspecting the source of |
|
I'm writing a function that is supposed to be generic over the number of simd lanes. Minimal example:
more code
Unfortunately I can't do this. The compiler gives
error[E0277]: the trait bound Simd<u32, LANES>: distributions::utils::WideningMultiply is not satisfied
on line 7 of this example. I tried adding that trait boundbut
WideningMultiply
ispub(crate)
so I can'tuse
it.Is there any way I can make this work? I realize SMID is experimental in rand and in rust. I have a workaround for now, which is to just declare a constant LANES outside the function, but then benchmarking with different number of lanes involves copy pasting or a macro.
The text was updated successfully, but these errors were encountered: