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 x86/x86_64 intrinsics #414

Merged
merged 1 commit into from
Apr 13, 2018
Merged

Conversation

alexcrichton
Copy link
Member

This commit stabilizes all intrinsics in the x86 and x86_64 modules, namely
allowing stabilization of the arch::x86 and arch::x86_64 module in libstd.
Stabilizations here were applied in an automated fashion using this
script
, and notably everything related to __m64 was omitted from this
round of stabilization

@@ -44,8 +49,11 @@ pub struct CpuidResult {
/// [wiki_cpuid]: https://en.wikipedia.org/wiki/CPUID
/// [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf
/// [amd64_ref]: http://support.amd.com/TechDocs/24594.pdf
///
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=__cpuid_count)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not an "official" Intel intrinsic, so this link returns empty. IIRC at least the cpuid intrinsics and the read/writeeflags intrinsics will suffer from this. There should be a list of these or their modules in the stdsimd-verify module.

@@ -334,6 +340,7 @@ pub use self::test::*;

#[doc(hidden)]
#[allow(non_camel_case_types)]
#[stable(feature = "simd_x86", since = "1.27.0")]
pub(crate) trait m128iExt: Sized {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't recall exactly what pub(crate) does so am just tripple checking this: these traits should not be exported by core right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct!

@@ -598,5 +606,3 @@ pub use self::aes::*;
mod rdrand;
pub use self::rdrand::*;

mod sha;
Copy link
Contributor

Choose a reason for hiding this comment

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

What happened here?

@@ -26,29 +26,38 @@ use stdsimd_test::assert_instr;
/// Perform an intermediate calculation for the next four SHA1 message values
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this module was removed from x86/mod.rs :/

@@ -33,9 +33,12 @@ extern "C" {
///
/// If `length == 0 && index > 0` or `lenght + index > 64` the result is
/// undefined.
///
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_extract_si64)
Copy link
Contributor

Choose a reason for hiding this comment

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

So these intrinsics are part of the AMD intrinsics, and are not in the intel IntrinsicsGuide. AMD only provides a pdf with the spec AFAICT so the correct place to point them at would be:

/// [AMD64 Architecture Programmer's Manual, Volume 3: General-Purpose and System Instructions](http://support.amd.com/TechDocs/24594.pdf) 

@@ -67,62 +71,80 @@ pub fn _bextr2_u64(a: u64, control: u64) -> u64 {
/// Clears all bits below the least significant zero bit of `x`.
///
/// If there is no zero bit in `x`, it returns zero.
///
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_blcfill_u32)
#[inline]
Copy link
Contributor

Choose a reason for hiding this comment

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

here the same as for sse4a applies, these are AMD only.

@@ -37,6 +38,7 @@ pub fn _bextr_u32(a: u32, start: u32, len: u32) -> u32 {
/// the least significant bits of the result.
#[inline]
#[target_feature(enable = "tbm")]
#[stable(feature = "simd_x86", since = "1.27.0")]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better to remove this in this comment. Not that we fix it some day and it suddenly becomes stable.

@@ -12,6 +12,7 @@ pub unsafe fn assert_eq_m64(a: __m64, b: __m64) {
}

#[target_feature(enable = "sse2")]
#[stable(feature = "simd_x86", since = "1.27.0")]
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think anything in this file should have this attribute.

@@ -14,10 +14,13 @@ use stdsimd_test::assert_instr;

Copy link
Contributor

Choose a reason for hiding this comment

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

OCD: I just realized that this file is still called bmi.rs, but this and the one in x86 should be renamed to bmi1.rs to match the target feature name.

@@ -38,5 +38,3 @@ pub use self::avx2::*;
mod bswap;
pub use self::bswap::*;

mod rdrand;
Copy link
Contributor

Choose a reason for hiding this comment

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

Here again, was this intended?

/// This macro only takes one argument which is a string literal of the feature
/// being tested for. The feature names supported are the lowercase versions of
/// the ones defined by Intel in [their documentation][docs].
///
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to list the whitelisted features here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe also mentions that these names are the same as those used by #[target_feature], and maybe it might be also worth mentioning twice that is_x86_feature_detected("avx,avx2") is not supported (even though it works for target feature.

Copy link
Member Author

Choose a reason for hiding this comment

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

Excellent ideas!

@gnzlbg
Copy link
Contributor

gnzlbg commented Apr 4, 2018

So the first pass looks good! There are a couple of places where the script needs manual intervention, once those are finished and test pass I'll go over this one more time in more detail.

@alexcrichton
Copy link
Member Author

Thanks for the close eye on review! I think I've addressed everything

@alexcrichton
Copy link
Member Author

Also FWIW we should hold off on merging this until the FCP has finished

@gnzlbg
Copy link
Contributor

gnzlbg commented Apr 6, 2018

Looks good!

This commit stabilizes all intrinsics in the `x86` and `x86_64` modules, namely
allowing stabilization of the `arch::x86` and `arch::x86_64` module in libstd.
Stabilizations here were applied in an automated fashion using [this
script][scr], and notably everything related to `__m64` was omitted from this
round of stabilization

[scr]: https://gist.github.com/alexcrichton/5b456d495d6fe1df46a158754565c7a5
@alexcrichton
Copy link
Member Author

Ok! I've merged this into a next-breaking branch and we'll update to that in the Rust repo. Once it's landed in nightly I'll circle back here to fix CI.

@alexcrichton
Copy link
Member Author

Er actually looks like it all pased! (except rustfmt)

@alexcrichton alexcrichton merged commit 2397665 into rust-lang:master Apr 13, 2018
@alexcrichton alexcrichton deleted the stabler branch April 13, 2018 14:32
@gnzlbg
Copy link
Contributor

gnzlbg commented Apr 13, 2018

Yay!! Congrats!

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Apr 16, 2018
This commit stabilizes the SIMD in Rust for the x86/x86_64 platforms. Notably
this commit is stabilizing:

* The `std::arch::{x86, x86_64}` modules and the intrinsics contained inside.
* The `is_x86_feature_detected!` macro in the standard library
* The `#[target_feature(enable = "...")]` attribute
* The `#[cfg(target_feature = "...")]` matcher

Stabilization of the module and intrinsics were primarily done in
rust-lang/stdarch#414 and the two attribute stabilizations are done in
this commit. The standard library is also tweaked a bit with the new way that
stdsimd is integrated.

Note that other architectures like `std::arch::arm` are not stabilized as part
of this commit, they will likely stabilize in the future after they've been
implemented and fleshed out. Similarly the `std::simd` module is also not being
stabilized in this commit, only `std::arch`. Finally, nothing related to `__m64`
is stabilized in this commit either (MMX), only SSE and up types and intrinsics
are stabilized.

Closes rust-lang#29717
Closes rust-lang#44839
Closes rust-lang#48556
bors added a commit to rust-lang/rust that referenced this pull request Apr 17, 2018
Stabilize x86/x86_64 SIMD

This commit stabilizes the SIMD in Rust for the x86/x86_64 platforms. Notably
this commit is stabilizing:

* The `std::arch::{x86, x86_64}` modules and the intrinsics contained inside.
* The `is_x86_feature_detected!` macro in the standard library
* The `#[target_feature(enable = "...")]` attribute
* The `#[cfg(target_feature = "...")]` matcher

Stabilization of the module and intrinsics were primarily done in
rust-lang/stdarch#414 and the two attribute stabilizations are done in
this commit. The standard library is also tweaked a bit with the new way that
stdsimd is integrated.

Note that other architectures like `std::arch::arm` are not stabilized as part
of this commit, they will likely stabilize in the future after they've been
implemented and fleshed out. Similarly the `std::simd` module is also not being
stabilized in this commit, only `std::arch`. Finally, nothing related to `__m64`
is stabilized in this commit either (MMX), only SSE and up types and intrinsics
are stabilized.

Closes #29717
Closes #44839
Closes #48556
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants