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

#[repr(simd)] on structs vs arrays, motivation #37

Closed
gnzlbg opened this issue Sep 21, 2017 · 4 comments
Closed

#[repr(simd)] on structs vs arrays, motivation #37

gnzlbg opened this issue Sep 21, 2017 · 4 comments

Comments

@gnzlbg
Copy link
Contributor

gnzlbg commented Sep 21, 2017

I have been trying to find the motivation for using repr(simd) on tuple structs instead of arrays for a while without any luck. Does anybody have some pointers?

I must be missing something because to make using it on arrays makes much more sense, mainly because:

  • we can use the recently merged type-level const RFC to create arbitrary sized simd vectors on stable (maybe preventing this was the aim of using tuple structs? if so, tuple structs will also fail here if we ever get variadics)
  • we can use [] to index into the elements of a simd vector, which is much nicer than using .0 (maybe it is because [] always does bounds checking which would be bad for simd where a compile-time solution would be preferable?)
@BurntSushi
Copy link
Member

I don't really have a dog in this fight. I defined them the way they are a year ago because that's how they were defined in the simd crate many years ago. :-) Any and all developments in Rust the language after that point had zero role in the design decision.

I haven't kept up with the type-level const RFC. I don't know it's implementation status. I think it would help if we could have some concrete code samples.

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Sep 22, 2017 via email

@alexcrichton
Copy link
Member

My guess is that it's just always been this way, I can't personally remember a time when we debated this and/or decided on structs.

Doing some digging through revealed what may be the first implementation of SIMD in rust using dedicated syntax (not merged) followed by what I think is the first merged PR for SIMD in Rust. This comment in particular may be of interest.

tl;dr; I don't think there's much to learn from the past here?

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Sep 26, 2017

I'm closing this. The comment you cited answered my questions.

@gnzlbg gnzlbg closed this as completed Sep 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants