Skip to content

rustc: Allow targets to specify SIMD args are by-val #55024

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

Merged
merged 1 commit into from
Oct 15, 2018

Conversation

alexcrichton
Copy link
Member

The upcoming SIMD support in the wasm target is unique from the other
platforms where it's either unconditionally available or not available,
there's no halfway where a subsection of the program can use it but no
other parts of the program can use it. In this world it's valid for wasm
SIMD args to always be passed by value and there's no need to pass them
by reference.

This commit adds a new custom target specification option
simd_types_indirect which defaults to true, but the wasm backend
disables this and sets it to false.

The upcoming SIMD support in the wasm target is unique from the other
platforms where it's either unconditionally available or not available,
there's no halfway where a subsection of the program can use it but no
other parts of the program can use it. In this world it's valid for wasm
SIMD args to always be passed by value and there's no need to pass them
by reference.

This commit adds a new custom target specification option
`simd_types_indirect` which defaults to `true`, but the wasm backend
disables this and sets it to `false`.
@rust-highfive
Copy link
Contributor

r? @estebank

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 13, 2018
@parched
Copy link
Contributor

parched commented Oct 14, 2018

where it's either unconditionally available or not available

Could you explain this a bit further (I'm not very familiar with the details of wasm)? What exactly determines whether it's available? Is this something inherent to wasm or just the LLVM wasm backend?

@Mark-Simulacrum
Copy link
Member

@bors try for perf

@bors
Copy link
Collaborator

bors commented Oct 14, 2018

⌛ Trying commit 9562b69 with merge a808de4...

bors added a commit that referenced this pull request Oct 14, 2018
rustc: Allow targets to specify SIMD args are by-val

The upcoming SIMD support in the wasm target is unique from the other
platforms where it's either unconditionally available or not available,
there's no halfway where a subsection of the program can use it but no
other parts of the program can use it. In this world it's valid for wasm
SIMD args to always be passed by value and there's no need to pass them
by reference.

This commit adds a new custom target specification option
`simd_types_indirect` which defaults to `true`, but the wasm backend
disables this and sets it to `false`.
@alexcrichton
Copy link
Member Author

@parched on x86/x86_64 we want the ability to compile some parts of the program that optionally use SIMD features that the CPU the executable is running on may not actually have. For example we want the ability to compile AVX2 functionality into a program, but if the CPU doesn't have the functionality then the program can still operate correctly.

That has weird implications on ABI which basically forces us to always pass vector types by reference (what we already do today).

For wasm, however, such a program is not possible. While the simd128 feature isn't stable in wasm your wasm engine either supports simd128 or not. It's impossible to have a wasm module where only some of it uses simd128 and the rest of it doesn't, and then have it run in an engine that doesn't have simd128 and the program just happens to not execute those pieces.

Because the same form of functionality isn't required for wasm (using a program with features on a platform that doesn't support those features), the ABI restrictions also aren't needed on wasm.

@Mark-Simulacrum this shouldn't affect any existing code, so I'm not sure what the perf run is for?

@parched
Copy link
Contributor

parched commented Oct 14, 2018

It's impossible to have a wasm module where only some of it uses simd128 and the rest of it doesn't, and then have it run in an engine that doesn't have simd128 and the program just happens to not execute those pieces.

Ok I think I understand. So are you saying that the wasm engine checks/compiles all the code regardless of whether it will actually be run. I.e., you could never have some runtime detection of whether the engine supports simd before executing some simd code?

@alexcrichton
Copy link
Member Author

@parched precisely!

@Mark-Simulacrum
Copy link
Member

Oh, I confused this with the other related PR, I believe.

@bors
Copy link
Collaborator

bors commented Oct 14, 2018

☀️ Test successful - status-travis
State: approved= try=True

@estebank
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Oct 14, 2018

📌 Commit 9562b69 has been approved by estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 14, 2018
@bors
Copy link
Collaborator

bors commented Oct 15, 2018

⌛ Testing commit 9562b69 with merge c40e2ac...

bors added a commit that referenced this pull request Oct 15, 2018
rustc: Allow targets to specify SIMD args are by-val

The upcoming SIMD support in the wasm target is unique from the other
platforms where it's either unconditionally available or not available,
there's no halfway where a subsection of the program can use it but no
other parts of the program can use it. In this world it's valid for wasm
SIMD args to always be passed by value and there's no need to pass them
by reference.

This commit adds a new custom target specification option
`simd_types_indirect` which defaults to `true`, but the wasm backend
disables this and sets it to `false`.
@bors
Copy link
Collaborator

bors commented Oct 15, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: estebank
Pushing c40e2ac to master...

@bors bors merged commit 9562b69 into rust-lang:master Oct 15, 2018
@alexcrichton alexcrichton deleted the wasm-simd-by-val branch October 21, 2018 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants