Skip to content
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

Closed
pcwalton opened this issue Sep 14, 2012 · 6 comments
Closed

Add a SIMD vector type #3499

pcwalton opened this issue Sep 14, 2012 · 6 comments
Labels
A-codegen Area: Code generation A-typesystem Area: The type system

Comments

@pcwalton
Copy link
Contributor

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.

@eholk
Copy link
Contributor

eholk commented Sep 17, 2012

I kind of like the idea of auto-promoting tuples. What about generating SIMD code for fixed length vectors?

@graydon
Copy link
Contributor

graydon commented Sep 17, 2012

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.

@eholk
Copy link
Contributor

eholk commented Sep 20, 2012

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.

@dherman
Copy link
Contributor

dherman commented Apr 8, 2013

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.

@sanxiyn sanxiyn mentioned this issue Apr 11, 2013
@dobkeratops
Copy link

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?
also simd sometimes behaves differently in the processors pipeline, as an extreme example the powerpc in 360/ps3 had awful issues getting data or even condition codes for branching back from SIMD pipeline into the regular one.(i know they're on the way out) there were cases where scalar code was faster. SIMD might be better as a deliberate decision. I think x86 doesn't suffer from this sort of thing though.

bors added a commit that referenced this issue May 8, 2013
At the moment this only includes type checking and there is no code generation support yet. I wanted to get the design reviewed first.

From discussion with @graydon at #5841, re-implemented as `#[simd]` attribute on structs.

Progressing towards #3499.
@emberian
Copy link
Member

emberian commented Jul 7, 2013

Still relevant, being worked on by @sanxiyn last I knew

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation A-typesystem Area: The type system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants