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

Stabilize Wasm relaxed SIMD #117468

Merged
merged 2 commits into from
Aug 5, 2024
Merged

Stabilize Wasm relaxed SIMD #117468

merged 2 commits into from
Aug 5, 2024

Conversation

daxpedda
Copy link
Contributor

@daxpedda daxpedda commented Oct 31, 2023

This PR stabilizes Wasm relaxed SIMD which has already reached phase 4.

Tracking issue: #111196
Implementation PR: rust-lang/stdarch#1393
Documentation: rust-lang/reference#1421
Stdarch: rust-lang/stdarch#1494

Closes #111196.

@rustbot
Copy link
Collaborator

rustbot commented Oct 31, 2023

r? @wesleywiser

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

@rustbot
Copy link
Collaborator

rustbot commented Oct 31, 2023

⚠️ Warning ⚠️

  • These commits modify submodules.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 31, 2023
@daxpedda
Copy link
Contributor Author

Cc @alexcrichton.

@rust-log-analyzer

This comment has been minimized.

@daxpedda
Copy link
Contributor Author

daxpedda commented Oct 31, 2023

This won't currently compile until rust-lang/stdarch#1494 is merged and updated, so for now this is waiting for the FCP first.

@rust-log-analyzer

This comment has been minimized.

@wesleywiser wesleywiser added the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Nov 1, 2023
@alexcrichton
Copy link
Member

Personally I'd say this is good to go (modulo CI of course), and it's something I forgot to do after the last CG meeting, thanks @daxpedda!

For others this PR has relevant discussion namely some of the background laid you in this comment. The relaxed-simd proposal is a bit different where there's actual instructions to expose with new intrinsics, but this is following in the footsteps of the simd128 proposal and its intrinsics so AFAIK there's no new precedents set here or anything like that, mostly just following preexisting processes.

@daxpedda
Copy link
Contributor Author

daxpedda commented Nov 2, 2023

@wesleywiser AFAIU this should probably not be marked as blocked.

It's true that merging is blocked on rust-lang/stdarch#1494, but the FCP is required for rust-lang/stdarch#1494 to be merged in the first place.
It could be argued that this is blocked on #117372, which in turn is blocked by tkaitchuck/aHash#183, but that should probably not block an FCP.

So I would like to request an FCP for stabilizing relaxed SIMD!
Let me know if I misunderstood something.

@Amanieu Amanieu added T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Nov 2, 2023
@Amanieu
Copy link
Member

Amanieu commented Nov 2, 2023

This cover the relaxed-simd target feature (lang team) and the related intrinsics in stdarch (libs-api team).

@rfcbot fcp merge

@rfcbot
Copy link

rfcbot commented Nov 2, 2023

Team member @Amanieu has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns.
See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Nov 2, 2023
@RalfJung
Copy link
Member

RalfJung commented Nov 2, 2023

Repeating what I posed on the tracking issue:

I am confused by the spec here. Quoting from https://github.com/WebAssembly/relaxed-simd/blob/main/proposals/relaxed-simd/Overview.md:

The same instruction at (1) and (2), when given the same inputs, can return two different results.

Okay, so that's normal non-determinism then. Wasm already has that for NaNs when there are non-canonical inputs, which is strangely not acknowledged here (has that changed?), but sure, makes sense.

Some operators are host-dependent, because the set of possible results may depend on properties of the host environment (such as hardware). Technically, each such operator produces a fixed-size list of sets of allowed values. For each execution of the operator in the same environment, only values from the set at the same position in the list are returned, i.e., each environment globally chooses a fixed projection for each operator.

This describes something else! IIUC, it says that the operation, when executed twice in the same environment, must produce the same result. In other words, the non-determinism is fixed once at program startup, and the example givejn just above actually cannot happen within a single program/module execution. This is closer to what we usually call implementation-specific behavior than to full non-determinism.

Can someone explain this seeming contradiction?

@alexcrichton
Copy link
Member

To the best of my knowledge I believe that the contradiction is explained by the fact that the proposal has a long history and changed at one point. I believe your first quoted sentence is the original semantics when the proposal was first drafted and the second quote you listed is the desired semantics.

For example this was the commit that introduced the first quote and it refers to an fpenv idea which was later removed. While I can't speak with complete certainty I'm pretty confident you've discovered a mistake in the overview. This could be confirmed with the rendered specification but that is a broken link at this time. I'm not great at reading the raw spec myself.

@RalfJung
Copy link
Member

RalfJung commented Nov 4, 2023

Okay, I've opened WebAssembly/relaxed-simd#153 to hopefully get clarification from the authors.

For Rust, we should probably conservatively treat these as being non-deterministic at each operation. I don't think that should cause any issues? These are just LLVM intrinsics implemented via certain wasm instructions, right?

@daxpedda
Copy link
Contributor Author

daxpedda commented Nov 4, 2023

I don't think that should cause any issues?

No, we do nothing with the output (the part that might not be deterministic).

These are just LLVM intrinsics implemented via certain wasm instructions that, right?

Indeed.

@bors
Copy link
Contributor

bors commented Nov 15, 2023

☔ The latest upstream changes (presumably #117915) made this pull request unmergeable. Please resolve the merge conflicts.

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Jul 31, 2024

📌 Commit 61d95e2 has been approved by alexcrichton

It is now in the queue for this repository.

@bors bors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 31, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 31, 2024
Rollup of 7 pull requests

Successful merges:

 - rust-lang#117468 (Stabilize Wasm relaxed SIMD)
 - rust-lang#123813 (Add `REDUNDANT_IMPORTS` lint for new redundant import detection)
 - rust-lang#127060 (Migrate `symbol-visibility` `run-make` test to rmake)
 - rust-lang#127159 (match lowering: Hide `Candidate` from outside the lowering algorithm)
 - rust-lang#128296 (Update target-spec metadata for loongarch64 targets)
 - rust-lang#128416 (android: Remove libstd hacks for unsupported Android APIs)
 - rust-lang#128431 (Add myself as VxWorks target maintainer for reference)

r? `@ghost`
`@rustbot` modify labels: rollup
@tgross35
Copy link
Contributor

tgross35 commented Jul 31, 2024

It looks like this may have caused the failure here #128454 (comment). Is it possible to update the stdarch submodule separately from stabilizing the wasm feature? That might be better in its own PR (and at least its own commit, for better history).

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 31, 2024
@daxpedda
Copy link
Contributor Author

Sure!
Will do that as soon as I figure out what the problem is exactly.

@daxpedda
Copy link
Contributor Author

@Amanieu these errors look like AVX512 work related to the Stdarch update, would you know whats causing this or who to ping?

@tgross35
Copy link
Contributor

It could also just be the RFL job having something wrong with target features, I brought it up on Zulip too.

@daxpedda
Copy link
Contributor Author

daxpedda commented Aug 1, 2024

Stdarch update is happening in #128466, which this PR will be rebased on after its merged.

@tgross35
Copy link
Contributor

tgross35 commented Aug 4, 2024

#128466 (comment) merged so this should be ready for a rebase.

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Aug 4, 2024

📌 Commit 80b74d3 has been approved by alexcrichton

It is now in the queue for this repository.

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 4, 2024
@bors
Copy link
Contributor

bors commented Aug 5, 2024

⌛ Testing commit 80b74d3 with merge 9179d9b...

@bors
Copy link
Contributor

bors commented Aug 5, 2024

☀️ Test successful - checks-actions
Approved by: alexcrichton
Pushing 9179d9b to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 5, 2024
@bors bors merged commit 9179d9b into rust-lang:master Aug 5, 2024
7 checks passed
@rustbot rustbot added this to the 1.82.0 milestone Aug 5, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (9179d9b): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (primary 7.4%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
7.4% [7.4%, 7.4%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 7.4% [7.4%, 7.4%] 1

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 757.802s -> 757.898s (0.01%)
Artifact size: 336.77 MiB -> 336.81 MiB (0.01%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tracking Issue for WebAssembly relaxed SIMD intrinsics