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

remove platform-intrinsics ABI; make SIMD intrinsics be regular intrinsics #121516

Merged
merged 2 commits into from
Feb 27, 2024

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Feb 23, 2024

@Amanieu @workingjubilee I don't think there is any reason these need to be "special"? The original RFC indicated eventually making them stable, but I think that is no longer the plan, so seems to me like we can clean this up a bit.

Blocked on rust-lang/stdarch#1538, #121542.

@rustbot
Copy link
Collaborator

rustbot commented Feb 23, 2024

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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 Feb 23, 2024
@rustbot
Copy link
Collaborator

rustbot commented Feb 23, 2024

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

This PR changes Stable MIR

cc @oli-obk, @celinval, @spastorino, @ouz-a

Some changes occurred to the platform-builtins intrinsics. Make sure the
LLVM backend as well as portable-simd gets adapted for the changes.

cc @antoyo, @GuillaumeGomez, @bjorn3, @calebzulawski, @programmerjake

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

These commits modify compiler targets.
(See the Target Tier Policy.)

// that's how we connect up to LLVM and it's unstable
// anyway, we control all calls to it in libstd.
Abi::Vector { .. }
if abi != SpecAbi::PlatformIntrinsic
&& cx.tcx.sess.target.simd_types_indirect =>
if abi != SpecAbi::RustIntrinsic && cx.tcx.sess.target.simd_types_indirect =>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means we're no longer applying the make-simd-indirect ABI adjustment to our non-SIMD intrinsics. But those aren't actual function calls anyway so I think that's fine?

@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Feb 23, 2024

The Miri subtree was changed

cc @rust-lang/miri

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@oli-obk oli-obk assigned oli-obk and unassigned Mark-Simulacrum Feb 23, 2024
@workingjubilee
Copy link
Member

error[E0703]: invalid ABI: found intrinsic
--> library/core/src/intrinsics/simd.rs:594:8
|
|
594 | extern "intrinsic" {
| ^^^^^^^^^^^ invalid ABI

error[E0044]: foreign items may not have type parameters

well, these seem like non-starters.
did you mean extern "rust-intrinsic"?

@RalfJung
Copy link
Member Author

did you mean extern "rust-intrinsic"?

🤦

@rustbot
Copy link
Collaborator

rustbot commented Feb 23, 2024

This PR changes MIR

cc @oli-obk, @RalfJung, @JakobDegen, @davidtwco, @celinval, @vakaras

@rust-log-analyzer

This comment has been minimized.

@workingjubilee
Copy link
Member

workingjubilee commented Feb 23, 2024

This seems fine to me. There was indeed once a plan to stabilize these as a surface interface, but it was during a point in time when it was thought that e.g. add-with-carry would require these. The overwhelming tendency has been against that over time, and making things at least surface as more "normal" library abstractions. SIMD intrinsics do have a distinctive "expected UX" (and by "UX", I mean "they should codegen a certain way"), but so do most rust-intrinsics, which generally serve some codegen purpose and each require at least some special handling.

In each case we may address these needs by handling these symbols individually, or by adding an attribute which covers their need.

@Amanieu
Copy link
Member

Amanieu commented Feb 24, 2024

LGTM. It's clear the design for SIMD has moved away from these intrinsics towards std::{arch,simd} instead.

extern "platform-intrinsic" {
fn simd_fmin<T>(x: T, y: T) -> T;
fn simd_fmax<T>(x: T, y: T) -> T;
}
use std::intrinsics::simd::*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming the reason only some of these got converted to imports in tests is that it's annoying to do with a search and replace?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I changed this one since @bjorn3 mentioned it but most of the diff in tests/ui is search-and-replace. it'd be tedious to convert them all and it's orthogonal to what this PR is trying to achieve.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yea, that's fine, just wanted to make sure I wasn't missing anything

@RalfJung RalfJung force-pushed the platform-intrinsics-begone branch 2 times, most recently from 7415e4c to 65d0dbe Compare February 24, 2024 12:10
@rust-log-analyzer

This comment has been minimized.

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Feb 24, 2024
@oli-obk
Copy link
Contributor

oli-obk commented Feb 24, 2024

@bors r-

I guess we're waiting for the submodule sync PR first

r=me with that done

@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 Feb 24, 2024
@RalfJung RalfJung added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 24, 2024
@bors
Copy link
Contributor

bors commented Feb 24, 2024

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

@RalfJung
Copy link
Member Author

@bors r=oli-obk

@bors
Copy link
Contributor

bors commented Feb 25, 2024

📌 Commit c1d0e48 has been approved by oli-obk

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-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. labels Feb 25, 2024
@bors
Copy link
Contributor

bors commented Feb 26, 2024

⌛ Testing commit c1d0e48 with merge 5c786a7...

@bors
Copy link
Contributor

bors commented Feb 27, 2024

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing 5c786a7 to master...

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5c786a7): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

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

Max RSS (memory usage)

Results

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)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-4.2% [-4.2%, -4.2%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -4.2% [-4.2%, -4.2%] 1

Cycles

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

Binary size

Results

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)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.0% [-0.0%, -0.0%] 4
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.0% [-0.0%, -0.0%] 4

Bootstrap: 651.881s -> 650.825s (-0.16%)
Artifact size: 311.16 MiB -> 311.12 MiB (-0.01%)

@RalfJung RalfJung deleted the platform-intrinsics-begone branch February 28, 2024 06:30
adpaco-aws added a commit to model-checking/kani that referenced this pull request Mar 4, 2024
Upgrades the Rust toolchain to `nightly-2024-03-01`. The Rust compiler
PRs that triggered changes in this upgrades are:
 * rust-lang/rust#121516
 * rust-lang/rust#121598
 * rust-lang/rust#121489
 * rust-lang/rust#121783
bjorn3 pushed a commit to bjorn3/rust that referenced this pull request Mar 8, 2024
… r=oli-obk

remove platform-intrinsics ABI; make SIMD intrinsics be regular intrinsics

`@Amanieu` `@workingjubilee` I don't think there is any reason these need to be "special"? The [original RFC](https://rust-lang.github.io/rfcs/1199-simd-infrastructure.html) indicated eventually making them stable, but I think that is no longer the plan, so seems to me like we can clean this up a bit.

Blocked on rust-lang/stdarch#1538, rust-lang#121542.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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-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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants