Auto merge of #57808 - gnzlbg:ustdsimd, r=gnzlbg
Update stdsimd This is the companion PR to https://github.com/rust-lang-nursery/stdsimd/pull/640 r? @alexcrichton
This commit is contained in:
commit
c1c3c4e95b
@ -221,11 +221,12 @@ pub mod alloc;
|
||||
mod tuple;
|
||||
mod unit;
|
||||
|
||||
// Pull in the `coresimd` crate directly into libcore. This is where all the
|
||||
// architecture-specific (and vendor-specific) intrinsics are defined. AKA
|
||||
// things like SIMD and such. Note that the actual source for all this lies in a
|
||||
// different repository, rust-lang-nursery/stdsimd. That's why the setup here is
|
||||
// a bit wonky.
|
||||
// Pull in the `core_arch` crate directly into libcore. The contents of
|
||||
// `core_arch` are in a different repository: rust-lang-nursery/stdsimd.
|
||||
//
|
||||
// `core_arch` depends on libcore, but the contents of this module are
|
||||
// set up in such a way that directly pulling it here works such that the
|
||||
// crate uses the this crate as its libcore.
|
||||
#[allow(unused_macros)]
|
||||
macro_rules! test_v16 { ($item:item) => {}; }
|
||||
#[allow(unused_macros)]
|
||||
@ -240,10 +241,10 @@ macro_rules! test_v256 { ($item:item) => {}; }
|
||||
macro_rules! test_v512 { ($item:item) => {}; }
|
||||
#[allow(unused_macros)]
|
||||
macro_rules! vector_impl { ($([$f:ident, $($args:tt)*]),*) => { $($f!($($args)*);)* } }
|
||||
#[path = "../stdsimd/coresimd/mod.rs"]
|
||||
#[path = "../stdsimd/crates/core_arch/src/mod.rs"]
|
||||
#[allow(missing_docs, missing_debug_implementations, dead_code, unused_imports)]
|
||||
#[unstable(feature = "stdsimd", issue = "48556")]
|
||||
mod coresimd;
|
||||
mod core_arch;
|
||||
|
||||
#[stable(feature = "simd_arch", since = "1.27.0")]
|
||||
pub use coresimd::arch;
|
||||
pub use core_arch::arch;
|
||||
|
@ -358,6 +358,9 @@ pub mod prelude;
|
||||
// Public module declarations and re-exports
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub use core::any;
|
||||
#[stable(feature = "simd_arch", since = "1.27.0")]
|
||||
#[doc(no_inline)]
|
||||
pub use core::arch;
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub use core::cell;
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -489,29 +492,22 @@ mod memchr;
|
||||
// compiler
|
||||
pub mod rt;
|
||||
|
||||
// Pull in the `stdsimd` crate directly into libstd. This is the same as
|
||||
// libcore's arch/simd modules where the source of truth here is in a different
|
||||
// repository, but we pull things in here manually to get it into libstd.
|
||||
// Pull in the `std_detect` crate directly into libstd. The contents of
|
||||
// `std_detect` are in a different repository: rust-lang-nursery/stdsimd.
|
||||
//
|
||||
// Note that the #[cfg] here is intended to do two things. First it allows us to
|
||||
// change the rustc implementation of intrinsics in stage0 by not compiling simd
|
||||
// intrinsics in stage0. Next it doesn't compile anything in test mode as
|
||||
// stdsimd has tons of its own tests which we don't want to run.
|
||||
#[path = "../stdsimd/stdsimd/mod.rs"]
|
||||
// `std_detect` depends on libstd, but the contents of this module are
|
||||
// set up in such a way that directly pulling it here works such that the
|
||||
// crate uses the this crate as its libstd.
|
||||
#[path = "../stdsimd/crates/std_detect/src/mod.rs"]
|
||||
#[allow(missing_debug_implementations, missing_docs, dead_code)]
|
||||
#[unstable(feature = "stdsimd", issue = "48556")]
|
||||
#[cfg(not(test))]
|
||||
mod stdsimd;
|
||||
mod std_detect;
|
||||
|
||||
// A "fake" module needed by the `stdsimd` module to compile, not actually
|
||||
// exported though.
|
||||
mod coresimd {
|
||||
pub use core::arch;
|
||||
}
|
||||
|
||||
#[stable(feature = "simd_arch", since = "1.27.0")]
|
||||
#[doc(hidden)]
|
||||
#[unstable(feature = "stdsimd", issue = "48556")]
|
||||
#[cfg(not(test))]
|
||||
pub use stdsimd::arch;
|
||||
pub use std_detect::detect;
|
||||
|
||||
// Include a number of private modules that exist solely to provide
|
||||
// the rustdoc documentation for primitive types. Using `include!`
|
||||
|
100
src/libstd/tests/run-time-detect.rs
Normal file
100
src/libstd/tests/run-time-detect.rs
Normal file
@ -0,0 +1,100 @@
|
||||
//! These tests just check that the macros are available in libstd.
|
||||
|
||||
#![cfg_attr(
|
||||
any(
|
||||
all(target_arch = "arm", any(target_os = "linux", target_os = "android")),
|
||||
all(target_arch = "aarch64", any(target_os = "linux", target_os = "android")),
|
||||
all(target_arch = "powerpc", target_os = "linux"),
|
||||
all(target_arch = "powerpc64", target_os = "linux"),
|
||||
),
|
||||
feature(stdsimd)
|
||||
)]
|
||||
|
||||
#[test]
|
||||
#[cfg(all(target_arch = "arm",
|
||||
any(target_os = "linux", target_os = "android")))]
|
||||
fn arm_linux() {
|
||||
println!("neon: {}", is_arm_feature_detected!("neon"));
|
||||
println!("pmull: {}", is_arm_feature_detected!("pmull"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(
|
||||
target_arch = "aarch64",
|
||||
any(target_os = "linux", target_os = "android")
|
||||
))]
|
||||
fn aarch64_linux() {
|
||||
println!("fp: {}", is_aarch64_feature_detected!("fp"));
|
||||
println!("fp16: {}", is_aarch64_feature_detected!("fp16"));
|
||||
println!("neon: {}", is_aarch64_feature_detected!("neon"));
|
||||
println!("asimd: {}", is_aarch64_feature_detected!("asimd"));
|
||||
println!("sve: {}", is_aarch64_feature_detected!("sve"));
|
||||
println!("crc: {}", is_aarch64_feature_detected!("crc"));
|
||||
println!("crypto: {}", is_aarch64_feature_detected!("crypto"));
|
||||
println!("lse: {}", is_aarch64_feature_detected!("lse"));
|
||||
println!("rdm: {}", is_aarch64_feature_detected!("rdm"));
|
||||
println!("rcpc: {}", is_aarch64_feature_detected!("rcpc"));
|
||||
println!("dotprod: {}", is_aarch64_feature_detected!("dotprod"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(target_arch = "powerpc", target_os = "linux"))]
|
||||
fn powerpc_linux() {
|
||||
println!("altivec: {}", is_powerpc_feature_detected!("altivec"));
|
||||
println!("vsx: {}", is_powerpc_feature_detected!("vsx"));
|
||||
println!("power8: {}", is_powerpc_feature_detected!("power8"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(target_arch = "powerpc64", target_os = "linux"))]
|
||||
fn powerpc64_linux() {
|
||||
println!("altivec: {}", is_powerpc64_feature_detected!("altivec"));
|
||||
println!("vsx: {}", is_powerpc64_feature_detected!("vsx"));
|
||||
println!("power8: {}", is_powerpc64_feature_detected!("power8"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
fn x86_all() {
|
||||
println!("aes: {:?}", is_x86_feature_detected!("aes"));
|
||||
println!("pcmulqdq: {:?}", is_x86_feature_detected!("pclmulqdq"));
|
||||
println!("rdrand: {:?}", is_x86_feature_detected!("rdrand"));
|
||||
println!("rdseed: {:?}", is_x86_feature_detected!("rdseed"));
|
||||
println!("tsc: {:?}", is_x86_feature_detected!("tsc"));
|
||||
println!("mmx: {:?}", is_x86_feature_detected!("mmx"));
|
||||
println!("sse: {:?}", is_x86_feature_detected!("sse"));
|
||||
println!("sse2: {:?}", is_x86_feature_detected!("sse2"));
|
||||
println!("sse3: {:?}", is_x86_feature_detected!("sse3"));
|
||||
println!("ssse3: {:?}", is_x86_feature_detected!("ssse3"));
|
||||
println!("sse4.1: {:?}", is_x86_feature_detected!("sse4.1"));
|
||||
println!("sse4.2: {:?}", is_x86_feature_detected!("sse4.2"));
|
||||
println!("sse4a: {:?}", is_x86_feature_detected!("sse4a"));
|
||||
println!("sha: {:?}", is_x86_feature_detected!("sha"));
|
||||
println!("avx: {:?}", is_x86_feature_detected!("avx"));
|
||||
println!("avx2: {:?}", is_x86_feature_detected!("avx2"));
|
||||
println!("avx512f {:?}", is_x86_feature_detected!("avx512f"));
|
||||
println!("avx512cd {:?}", is_x86_feature_detected!("avx512cd"));
|
||||
println!("avx512er {:?}", is_x86_feature_detected!("avx512er"));
|
||||
println!("avx512pf {:?}", is_x86_feature_detected!("avx512pf"));
|
||||
println!("avx512bw {:?}", is_x86_feature_detected!("avx512bw"));
|
||||
println!("avx512dq {:?}", is_x86_feature_detected!("avx512dq"));
|
||||
println!("avx512vl {:?}", is_x86_feature_detected!("avx512vl"));
|
||||
println!("avx512_ifma {:?}", is_x86_feature_detected!("avx512ifma"));
|
||||
println!("avx512_vbmi {:?}", is_x86_feature_detected!("avx512vbmi"));
|
||||
println!(
|
||||
"avx512_vpopcntdq {:?}",
|
||||
is_x86_feature_detected!("avx512vpopcntdq")
|
||||
);
|
||||
println!("fma: {:?}", is_x86_feature_detected!("fma"));
|
||||
println!("bmi1: {:?}", is_x86_feature_detected!("bmi1"));
|
||||
println!("bmi2: {:?}", is_x86_feature_detected!("bmi2"));
|
||||
println!("abm: {:?}", is_x86_feature_detected!("abm"));
|
||||
println!("lzcnt: {:?}", is_x86_feature_detected!("lzcnt"));
|
||||
println!("tbm: {:?}", is_x86_feature_detected!("tbm"));
|
||||
println!("popcnt: {:?}", is_x86_feature_detected!("popcnt"));
|
||||
println!("fxsr: {:?}", is_x86_feature_detected!("fxsr"));
|
||||
println!("xsave: {:?}", is_x86_feature_detected!("xsave"));
|
||||
println!("xsaveopt: {:?}", is_x86_feature_detected!("xsaveopt"));
|
||||
println!("xsaves: {:?}", is_x86_feature_detected!("xsaves"));
|
||||
println!("xsavec: {:?}", is_x86_feature_detected!("xsavec"));
|
||||
}
|
@ -1 +1 @@
|
||||
Subproject commit 269d0ba959f70e9b692e528311c78b8f9601d4af
|
||||
Subproject commit b23541340b5941749e5fbb1930e666bbd1375244
|
@ -52,6 +52,8 @@ const EXCEPTION_PATHS: &[&str] = &[
|
||||
"src/libstd/path.rs",
|
||||
"src/libstd/f32.rs",
|
||||
"src/libstd/f64.rs",
|
||||
// Integration test for platform-specific run-time feature detection:
|
||||
"src/libstd/tests/run-time-detect.rs" ,
|
||||
"src/libstd/sys_common/mod.rs",
|
||||
"src/libstd/sys_common/net.rs",
|
||||
"src/libterm", // Not sure how to make this crate portable, but test crate needs it.
|
||||
|
Loading…
x
Reference in New Issue
Block a user