-
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
pub use core::simd; #89167
pub use core::simd; #89167
Conversation
Add cross-links to Zulip, etc.
Feature/round
Document size/align of SIMD types
This reverts commit 3ad356d.
There are no platform intrinsics in the rustc for these functions yet, so this removes them as a distinct commit for later reversion.
This PR removes the direct linkage to LLVM for trunc and round intrinsics, while replacing that link with rustc's platform intrinsics for floor and ceil functions, namely simd_floor and simd_ceil. Tests that are no longer testable are removed. In doing so it resolves the riscv64gc compilation problems.
Deploy documentation to GitHub Pages
Feature/const generics
min_const_generics ride the train to stable
This comment has been minimized.
This comment has been minimized.
It looks like we pass thumbv6m-none-eabi and then... fail on thumbv7m-none-eabi? |
This enables programmers to use a safe alternative to the current `extern "platform-intrinsics"` API for writing portable SIMD code. This is `#![feature(portable_simd)]` as tracked in rust-lang#86656
These tests just verify some basic APIs of core::simd function, and guarantees that attempting to access the wrong things doesn't work. The majority of tests are stochastic, and so remain upstream, but a few deterministic tests arrive in the subtree as doc tests.
705190b
to
7c3d72d
Compare
This time the conversions available should match exactly with the types in std::arch. 🙈 |
📌 Commit 7c3d72d has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (032dfe4): comparison url. Summary: This change led to very large relevant regressions 😿 in compiler performance.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression |
Probably because v6m only has scalar operations while v7m has DSP instructions which provide SIMD support for |
That is not correct. Arm v6-M processors can potentially include DSP instructions. They were introduced as early as Arm v5TE (the Nintendo DS being a somewhat famous example).
That is also not the reason why the build failed. While I mused aloud at first, there is no reason to speculate at this stage in the game. The target definition rustc uses for My first attempt was to simply restrict all the The second try which resolved the problem required more rigorously examining the |
Not sure how ARM v6-M and ARM v5TE are related. v6-m definitely can not have the DSP extension. I was wrong about v7m being able to use DSP instructions, too: For some reason I thought it would be optional in that architecture but actually it's only in Cortex-M4 and up (which is v7-EM) and there it is a standard feature. LLVM can resolve SIMD types internally quite nicely, if the target doesn't support any operations on them it will simply turn them into scalar code and there're also some cases where it will use DSP (or other SIMD) instructions (if available) on scalar types if benefitial, e.g. on targets with the DSP instruction it can turn saturating operations on i8/u8/i16/u16 types into SIMD types ignoring remainder of the register. This is all a bit shaky though and I totally expect that using Glad you hear you managed to get it sorted out and thanks for working on this important topic. ❤️ |
A portable abstraction over SIMD has been a major pursuit in recent years for several programming languages. In Rust,
std::arch
offers explicit SIMD acceleration via compiler intrinsics, but it does so at the cost of having to individually maintain each and every single such API, and is almost completelyunsafe
to use.core::simd
offers safe abstractions that are resolved to the appropriate SIMD instructions by LLVM during compilation, including scalar instructions if that is all that is available.core::simd
is enabled by the#![portable_simd]
nightly feature tracked in #86656 and is introduced here by pulling in the https://github.com/rust-lang/portable-simd repository as a subtree. We built the repository out-of-tree to allow faster compilation and a stochastic test suite backed by the proptest crate to verify that different targets, features, and optimizations produce the same result, so that using this library does not introduce any surprises. As these tests are technically non-deterministic, and thus can introduce overly interesting Heisenbugs if included in the rustc CI, they are visible in the commit history of the subtree but do nothing here. Some tests are introduced via the documentation, but these use deterministic asserts.There are multiple unsolved problems with the library at the current moment, including a want for better documentation, technical issues with LLVM scalarizing and lowering to libm, room for improvement for the APIs, and so far I have not added the necessary plumbing for allowing the more experimental or libm-dependent APIs to be used. However, I thought it would be prudent to open this for review in its current condition, as it is both usable and it is likely I am going to learn something else needs to be fixed when bors tries this out.
The major types are
core::simd::Simd<T, N>
core::simd::Mask<T, N>
There is also the
LaneCount
struct, which, together with the SimdElement and SupportedLaneCount traits, limit the implementation's maximum support to vectors we know will actually compile and provide supporting logic for bitmasks. I'm hoping to simplify at least some of these out of the way as the compiler and library evolve.