-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Sync portable-simd to remove autosplats #91484
Conversation
Update CONTRIBUTING.md for the fact that Travis is no longer used
Fix outdated workflow badge
Instead of implementing each "deref" pattern for every single scalar, we can use type parameters for Simd operating on &Self. We can use a macro, but keep it cleaner and more explicit.
Instead of implementing {Op}Assign traits for individual scalar type args to Simd<_, _>, use parametric impls that reassert the bounds of the binary op.
Resolves my comment in rust-lang#197, at least for now; rust-lang#187 is pending but since these are already here, just commented, it seemed to make sense to me to re-enable them anyway.
In order to assure type soundness, these "base" impls need to go directly on Simd<T, _> for every scalar type argument. A bit of cleanup of ops.rs is still warranted.
Unfortunately, splatting impls currently break several crates. Rust needs more time to review possible mitigations, so drop the impls for the `impl Add<T> for Simd<T, _>` pattern, for now.
Generic `core::ops` for `Simd<T, _>` In order to maintain type soundness, we need to be sure we only implement an operation for `Simd<T, _> where T: SimdElement`... and also valid for that operation in general. While we could do this purely parametrically, it is more sound to implement the operators directly for the base scalar type arguments and then use type parameters to extend the operators to the "higher order" operations. This implements that strategy and cleans up `simd::ops` into a few submodules: - assign.rs: `core::ops::*Assign` - deref.rs: `core::ops` impls which "deref" borrowed versions of the arguments - unary.rs: encloses the logic for unary operators on `Simd`, as unary ops are much simpler This is possible since everything need not be nested in a single maze of macros anymore. The result simplifies the logic and allows reasoning about what operators are valid based on the expressed trait bounds, and also reduces the size of the trait implementation output in rustdoc, for a huge win of 4 MB off the size of `struct.Simd.html`! This addresses a common user complaint, as the original was over 5.5 MB and capable of crashing browsers! This also carries a fix for a type-inference-related breakage, by removing the autosplatting (vector + scalar binop) impls, as unfortunately the presence of autosplatting was capable of busting type inference. We will likely need to see results from a Crater run before we can understand how to re-land autosplatting.
(rust-highfive has picked a reviewer for you, use r? to override) |
All of the minimized examples documented so far as of 2021-12-02 can be compiled by rustc with these changes to |
@bors r+ rollup=never I'll leave beta-accepted to T-compiler (?) discussion, but I suspect it probably makes sense to just backport this wholesale, or do a targeted backport that cfg's out the submodule entirely -- those two strategies feel like the best options to me at this point. |
📌 Commit eef4371 has been approved by |
☀️ Test successful - checks-actions |
I get these errors after this PR (most likely):
I didn't investigate further yet. |
Discussed today in T-compiler meeting on Zulip. Beta backport is deferred after investigation of this comment and the best strategy to adopt for backport (as laid out in this comment) |
Huh, that's... weird. What were you trying to build? Surely not just |
A regular rustc build - I'll be able to investigate further later today or tomorrow, if it's something incremental then it should go away after just a fresh rebuild. |
That explains it. Yes, I think this is triggered by your target having AVX512 and apparently the paths not being quite right on our end, now that I look at it... somehow missed in the million other things I had to adjust or reflag to make them work in the compiler, ugh. |
Discussed in T-compiler triage meeting.
|
Sync portable-simd to fix libcore build for AVX-512 enabled targets Fixes rust-lang#91484 (comment) cc `@workingjubilee`
Sync portable-simd to fix libcore build for AVX-512 enabled targets Fixes rust-lang#91484 (comment) cc `@workingjubilee`
Sync portable-simd to fix libcore build for AVX-512 enabled targets Fixes rust-lang#91484 (comment) cc ``@workingjubilee``
Discussed it in the libs-api meeting. Backporting either this PR or a complete removal both seems fine. Marked as accepted. The backporter can decide whatever is easiest for them. |
Stand-in for a backport of "Sync portable-simd to remove autosplats rust-lang#91484".
…ulacrum [beta] backports Backports these PRs: * Fix HashStable implementation on InferTy rust-lang#91892 * Revert setting a default for the MACOSX_DEPLOYMENT_TARGET env var for linking rust-lang#91870 * Make rustdoc headings black, and markdown blue rust-lang#91534 * Disable LLVM newPM by default rust-lang#91190 * Deduplicate projection sub-obligations rust-lang#90423 * Sync portable-simd to remove autosplats rust-lang#91484 by dropping portable_simd entirely (keeping the subtree, just from std/core) * Quote bat script command line rust-lang#92208 * Fix failing tests rust-lang#92201 (CI fix) r? `@Mark-Simulacrum`
This PR syncs portable-simd in up to rust-lang/portable-simd@a838552 in order to address the type inference breakages documented on nightly in #90904 by removing the vector + scalar binary operations (called "autosplats", "broadcasting", or "rank promotion", depending on who you ask) that allow
{scalar} + &'_ {scalar}
to fail in some cases, because it becomes possible the programmer may have meant{scalar} + &'_ {vector}
.A few quality-of-life improvements make their way in as well:
{i,u}8x64
to__m512i
is now available.#[must_use]
notes appear throughout the module.impl core::ops::{Op}<Simd> for Simd
that aren't{vector} + {vector}
(e.g.{vector} + &'_ {vector}
), leverage some generics andwhere
bounds now to make them easier to understand by reducing a dozen implementations into one (and make it possible for people to open the docs on less burly devices).None of these changes should affect a beta backport, only actual users of
core::simd
(and most aren't even visible in the programmatic sense), though I can extract an even more minimal changeset for beta if necessary. It seemed simpler to just keep moving forward.