-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Add a SIMD vector type #3499
Comments
I kind of like the idea of auto-promoting tuples. What about generating SIMD code for fixed length vectors? |
Two sub questions: one is whether we'll generate simd moves etc. when moving vector-like structures around on simd-capable target archs; the other is whether we define vector-scalar and/or vector-vector operations, using simd as possible. I think "yes" on both. Both should be defined in terms of simple rust tuple types, both should just fall back to scalar modes when simd is not available on the target. Possibly best surfaced to (eg.) stdlib traits via per-target named intrinsics; depends how they surface in llvm. |
I was thinking about this some more, and we may not need much language support at all. If we expose LLVM's SIMD instructions through intrinsics, we could provide overloaded operators for things like int slices, float slices, etc., that use the appropriate SIMD instructions in their implementation. I'm not sure how well this plays with coherence though. If I remember right, LLVM's SIMD instructions are really flexible, but may not correspond to anything on the machine itself. For example, I think it's legal to write a 1000-wide vector add instruction. I'm not sure whether LLVM would just fail in this case, or if it would try to generate equivalent code given the available vector instructions. |
There's a lot of good prior work to look into on the https://github.com/mozilla/rust/wiki/Lib-simd wiki page. I've also just added a new paper that just came out from SPJ's group: Haskell Beats C Using Generalized Stream Fusion. |
one question about auto promoting tuple types is alignment, you want simd types to be aligned in memory, but is the same always true for tuples? |
Still relevant, being worked on by @sanxiyn last I knew |
We should be able to use the LLVM support for SIMD vector types. There are two possibilities: (a) an intrinsic type (lang item) which the compiler knows about; (b) auto-promote tuples of the appropriate type to SIMD.
The text was updated successfully, but these errors were encountered: