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

std: Add arch and simd modules #48513

Merged
merged 1 commit into from
Mar 3, 2018
Merged

std: Add arch and simd modules #48513

merged 1 commit into from
Mar 3, 2018

Conversation

alexcrichton
Copy link
Member

This commit imports the stdsimd crate into the standard library,
creating an arch and simd module inside of both libcore and libstd.
Both of these modules are unstable and will continue to be so until
RFC 2335 is stabilized.

As a brief recap, the modules are organized as so:

  • arch contains all current architectures with intrinsics, for example
    std::arch::x86, std::arch::x86_64, std::arch::arm, etc. These
    modules contain all of the intrinsics defined for the platform, like
    _mm_set1_epi8.
  • In the standard library, the arch module also exports a
    is_target_feature_detected macro which performs runtime detection to
    determine whether a target feature is available at runtime.
  • The simd module contains experimental versions of strongly-typed
    lane-aware SIMD primitives, to be fully fleshed out in a future RFC.

The main purpose of this commit is to start pulling in all these
intrinsics and such into the standard library on nightly and allow
testing and such. This'll help allow users to easily kick the tires and
see if intrinsics work as well as allow us to test out all the
infrastructure for moving the intrinsics into the standard library.

@rust-highfive
Copy link
Collaborator

r? @joshtriplett

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

#![feature(unboxed_closures)]
#![feature(untagged_unions)]
#![feature(unwind_attributes)]
#![feature(doc_spotlight)]
#![feature(rustc_const_unstable)]
#![feature(iterator_repeat_with)]
Copy link
Member

Choose a reason for hiding this comment

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

Minor nit, but shouldn't moving these three around into a different spot be in a separate commit?

@joshtriplett
Copy link
Member

One minor nit, which I don't feel particularly strongly about, and otherwise this LGTM.

@bors
Copy link
Contributor

bors commented Feb 25, 2018

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

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 25, 2018
@alexcrichton
Copy link
Member Author

cc @rust-lang/libs, @BurntSushi, @gnzlbg

@sfackler
Copy link
Member

Is the plan to always be importing stdsimd, or is this just temporary and it'll get inlined into this repo at some point?

@alexcrichton
Copy link
Member Author

My thinking at least is that we'll forever be importing stdsimd as a submodule, that allows us to be way more creative with stdsimd's own CI and doesn't require us to hook it all up here as well

#[allow(missing_docs, missing_debug_implementations, dead_code)]
#[unstable(feature = "stdsimd", issue = "0")]
#[cfg(not(stage0))] // allow changes to how stdsimd works in stage0
mod coresimd;
Copy link
Member

Choose a reason for hiding this comment

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

Silly question: does this stage0 check preclude core/std from using anything from stdsimd?

Copy link
Member Author

Choose a reason for hiding this comment

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

It would during stage0, yeah, but I'd imagine that most usage would largely be an optimization in which case tagging it as #[cfg(not(stage0))] probably wouldn't be too bad.

Copy link
Member Author

Choose a reason for hiding this comment

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

Note that the alternative here is to manually add #[cfg(stage0)] tags and such to stdsimd itself rather than blanket defining it for this module, and I figured that for the time being it's easiest to take this route which is only defining it in stage1+

Copy link
Member

Choose a reason for hiding this comment

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

Oh, good point. Yeah, the stage1 compiler just being a bit slower in some corner cases than it could be probably isn't a big deal.

@gnzlbg
Copy link
Contributor

gnzlbg commented Feb 27, 2018

LGTM.

Pulling in the simd module was a bit unexpected, but at least this will tell us if this really does work on all targets supported by rustc.

@alexcrichton
Copy link
Member Author

@gnzlbg do you think the simd module should be left out for now?

@gnzlbg
Copy link
Contributor

gnzlbg commented Feb 27, 2018

Nah, it's unstable.

@alexcrichton alexcrichton force-pushed the simd branch 4 times, most recently from 5fb66e2 to 4abbf01 Compare February 27, 2018 20:50
@scottmcm
Copy link
Member

FWIW I'd like to use u8x{8, 16, 32} in core, so it'd be great to have simd.

@alexcrichton
Copy link
Member Author

@bors: r=JoshTriplett

@bors
Copy link
Contributor

bors commented Feb 28, 2018

📌 Commit 4abbf01 has been approved by JoshTriplett

@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 Feb 28, 2018
@gnzlbg
Copy link
Contributor

gnzlbg commented Feb 28, 2018

@scottmcm just be aware that the API will change a bit shortly and you'll be ok.

@kennytm
Copy link
Member

kennytm commented Mar 2, 2018

@bors r-

The bmi target feature has been renamed to bmi1 since #48565. Please rebase and update the stdsimd submodule.

[00:26:13] error: the feature named `bmi` is not valid for this target
[00:26:13]   --> libcore/../stdsimd/coresimd/x86/bmi.rs:18:18
[00:26:13]    |
[00:26:13] 18 | #[target_feature(enable = "bmi")]
[00:26:13]    |                  ^^^^^^^^^^^^^^
[00:26:13] 
[00:26:13] error: the feature named `bmi` is not valid for this target
[00:26:13]   --> libcore/../stdsimd/coresimd/x86/bmi.rs:30:18
[00:26:13]    |
[00:26:13] 30 | #[target_feature(enable = "bmi")]
[00:26:13]    |                  ^^^^^^^^^^^^^^
[00:26:13] 
[00:26:13] error: the feature named `bmi` is not valid for this target
[00:26:13]   --> libcore/../stdsimd/coresimd/x86/bmi.rs:38:18
[00:26:13]    |
[00:26:13] 38 | #[target_feature(enable = "bmi")]
[00:26:13]    |                  ^^^^^^^^^^^^^^
[00:26:13] 
[00:26:13] error: the feature named `bmi` is not valid for this target
[00:26:13]   --> libcore/../stdsimd/coresimd/x86/bmi.rs:46:18
[00:26:13]    |
[00:26:13] 46 | #[target_feature(enable = "bmi")]
[00:26:13]    |                  ^^^^^^^^^^^^^^
[00:26:13] 
[00:26:13] error: the feature named `bmi` is not valid for this target
[00:26:13]   --> libcore/../stdsimd/coresimd/x86/bmi.rs:54:18
[00:26:13]    |
[00:26:13] 54 | #[target_feature(enable = "bmi")]
[00:26:13]    |                  ^^^^^^^^^^^^^^
[00:26:13] 
[00:26:13] error: the feature named `bmi` is not valid for this target
[00:26:13]   --> libcore/../stdsimd/coresimd/x86/bmi.rs:64:18
[00:26:13]    |
[00:26:13] 64 | #[target_feature(enable = "bmi")]
[00:26:13]    |                  ^^^^^^^^^^^^^^
[00:26:13] 
[00:26:13] error: the feature named `bmi` is not valid for this target
[00:26:13]   --> libcore/../stdsimd/coresimd/x86/bmi.rs:74:18
[00:26:13]    |
[00:26:13] 74 | #[target_feature(enable = "bmi")]
[00:26:13]    |                  ^^^^^^^^^^^^^^
[00:26:13] 
[00:26:13] error: the feature named `bmi` is not valid for this target
[00:26:13]   --> libcore/../stdsimd/coresimd/x86/bmi.rs:84:18
[00:26:13]    |
[00:26:13] 84 | #[target_feature(enable = "bmi")]
[00:26:13]    |                  ^^^^^^^^^^^^^^
[00:26:13] 
[00:26:13] error: the feature named `bmi` is not valid for this target
[00:26:13]   --> libcore/../stdsimd/coresimd/x86_64/bmi.rs:18:18
[00:26:13]    |
[00:26:13] 18 | #[target_feature(enable = "bmi")]
[00:26:13]    |                  ^^^^^^^^^^^^^^
[00:26:13] 
[00:26:13] error: the feature named `bmi` is not valid for this target
[00:26:13]   --> libcore/../stdsimd/coresimd/x86_64/bmi.rs:31:18
[00:26:13]    |
[00:26:13] 31 | #[target_feature(enable = "bmi")]
[00:26:13]    |                  ^^^^^^^^^^^^^^
[00:26:13] 
[00:26:13] error: the feature named `bmi` is not valid for this target
[00:26:13]   --> libcore/../stdsimd/coresimd/x86_64/bmi.rs:40:18
[00:26:13]    |
[00:26:13] 40 | #[target_feature(enable = "bmi")]
[00:26:13]    |                  ^^^^^^^^^^^^^^
[00:26:13] 
[00:26:13] error: the feature named `bmi` is not valid for this target
[00:26:13]   --> libcore/../stdsimd/coresimd/x86_64/bmi.rs:48:18
[00:26:13]    |
[00:26:13] 48 | #[target_feature(enable = "bmi")]
[00:26:13]    |                  ^^^^^^^^^^^^^^
[00:26:13] 
[00:26:13] error: the feature named `bmi` is not valid for this target
[00:26:13]   --> libcore/../stdsimd/coresimd/x86_64/bmi.rs:57:18
[00:26:13]    |
[00:26:13] 57 | #[target_feature(enable = "bmi")]
[00:26:13]    |                  ^^^^^^^^^^^^^^
[00:26:13] 
[00:26:13] error: the feature named `bmi` is not valid for this target
[00:26:13]   --> libcore/../stdsimd/coresimd/x86_64/bmi.rs:68:18
[00:26:13]    |
[00:26:13] 68 | #[target_feature(enable = "bmi")]
[00:26:13]    |                  ^^^^^^^^^^^^^^
[00:26:13] 
[00:26:13] error: the feature named `bmi` is not valid for this target
[00:26:13]   --> libcore/../stdsimd/coresimd/x86_64/bmi.rs:79:18
[00:26:13]    |
[00:26:13] 79 | #[target_feature(enable = "bmi")]
[00:26:13]    |                  ^^^^^^^^^^^^^^
[00:26:13] 
[00:26:13] error: the feature named `bmi` is not valid for this target
[00:26:13]   --> libcore/../stdsimd/coresimd/x86_64/bmi.rs:89:18
[00:26:13]    |
[00:26:13] 89 | #[target_feature(enable = "bmi")]
[00:26:13]    |                  ^^^^^^^^^^^^^^
[00:26:13] 
[00:26:15]    Compiling rustc_tsan v0.0.0 (file:///checkout/src/librustc_tsan)
[00:26:15]    Compiling rustc_lsan v0.0.0 (file:///checkout/src/librustc_lsan)
[00:26:17]    Compiling rustc_msan v0.0.0 (file:///checkout/src/librustc_msan)
[00:26:17]    Compiling rustc_asan v0.0.0 (file:///checkout/src/librustc_asan)
[00:26:37] error: aborting due to 16 previous errors
[00:26:37] 
[00:26:37] error: Could not compile `core`.

@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 Mar 2, 2018
@alexcrichton
Copy link
Member Author

@bors: r=JoshTriplett

@bors
Copy link
Contributor

bors commented Mar 2, 2018

📌 Commit 4d63f81 has been approved by JoshTriplett

@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 Mar 2, 2018
Manishearth added a commit to Manishearth/rust that referenced this pull request Mar 2, 2018
@Manishearth
Copy link
Member

[00:48:53] error: function is never used: `set_bit`
[00:48:53]   --> libstd/../stdsimd/stdsimd/arch/detect/cache.rs:13:1
[00:48:53]    |
[00:48:53] 13 | pub const fn set_bit(x: u64, bit: u32) -> u64 {
[00:48:53]    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[00:48:53]    |
[00:48:53] note: lint level defined here
[00:48:53]   --> libstd/lib.rs:232:31
[00:48:53]    |
[00:48:53] 232| #![cfg_attr(not(stage0), deny(warnings))]
[00:48:53]    |                               ^^^^^^^^
[00:48:53]    = note: #[deny(dead_code)] implied by #[deny(warnings)]
[00:48:53] 
[00:48:53] error: method is never used: `set`
[00:48:53]   --> libstd/../stdsimd/stdsimd/arch/detect/cache.rs:48:5
[00:48:53]    |
[00:48:53] 48 |     pub fn set(&mut self, bit: u32) {
[00:48:53]    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[00:48:53] 
[00:48:53] error: aborting due to 2 previous errors

@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 Mar 2, 2018
@alexcrichton
Copy link
Member Author

@Manishearth thanks! W/ an r- mind throwing in a link to the error logs as well? In this case it's important that it's wasm, for example, and doesn't otherwise happen by default.

@gnzlbg
Copy link
Contributor

gnzlbg commented Mar 2, 2018

@Manishearth is there a way to view the result of all build bots?

This commit imports the `stdsimd` crate into the standard library,
creating an `arch` and `simd` module inside of both libcore and libstd.
Both of these modules are **unstable** and will continue to be so until
RFC 2335 is stabilized.

As a brief recap, the modules are organized as so:

* `arch` contains all current architectures with intrinsics, for example
  `std::arch::x86`, `std::arch::x86_64`, `std::arch::arm`, etc. These
  modules contain all of the intrinsics defined for the platform, like
  `_mm_set1_epi8`.
* In the standard library, the `arch` module also exports a
  `is_target_feature_detected` macro which performs runtime detection to
  determine whether a target feature is available at runtime.
* The `simd` module contains experimental versions of strongly-typed
  lane-aware SIMD primitives, to be fully fleshed out in a future RFC.

The main purpose of this commit is to start pulling in all these
intrinsics and such into the standard library on nightly and allow
testing and such. This'll help allow users to easily kick the tires and
see if intrinsics work as well as allow us to test out all the
infrastructure for moving the intrinsics into the standard library.
@alexcrichton
Copy link
Member Author

@bors: r=JoshTriplett

@bors
Copy link
Contributor

bors commented Mar 2, 2018

📌 Commit c72537f has been approved by JoshTriplett

@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 Mar 2, 2018
kennytm added a commit to kennytm/rust that referenced this pull request Mar 3, 2018
std: Add `arch` and `simd` modules

This commit imports the `stdsimd` crate into the standard library,
creating an `arch` and `simd` module inside of both libcore and libstd.
Both of these modules are **unstable** and will continue to be so until
RFC 2335 is stabilized.

As a brief recap, the modules are organized as so:

* `arch` contains all current architectures with intrinsics, for example
  `std::arch::x86`, `std::arch::x86_64`, `std::arch::arm`, etc. These
  modules contain all of the intrinsics defined for the platform, like
  `_mm_set1_epi8`.
* In the standard library, the `arch` module also exports a
  `is_target_feature_detected` macro which performs runtime detection to
  determine whether a target feature is available at runtime.
* The `simd` module contains experimental versions of strongly-typed
  lane-aware SIMD primitives, to be fully fleshed out in a future RFC.

The main purpose of this commit is to start pulling in all these
intrinsics and such into the standard library on nightly and allow
testing and such. This'll help allow users to easily kick the tires and
see if intrinsics work as well as allow us to test out all the
infrastructure for moving the intrinsics into the standard library.
bors added a commit that referenced this pull request Mar 3, 2018
Rollup of 8 pull requests

- Successful merges: #48283, #48466, #48569, #48629, #48637, #48680, #48513, #48664
- Failed merges:
@bors bors merged commit c72537f into rust-lang:master Mar 3, 2018
@alexcrichton alexcrichton deleted the simd branch March 3, 2018 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants