From be96995d8ddec03fac9a0caf4d4c51c7fbc33507 Mon Sep 17 00:00:00 2001 From: Caleb Zulawski Date: Mon, 19 Jul 2021 19:13:24 -0400 Subject: [PATCH] Add portable_simd unstable feature gate (#141) --- crates/core_simd/examples/matrix_inversion.rs | 5 ++++- crates/core_simd/examples/nbody.rs | 2 ++ crates/core_simd/src/array.rs | 5 +++++ crates/core_simd/src/lib.rs | 10 +++++++++- crates/core_simd/src/math.rs | 7 +++++++ crates/core_simd/src/permute.rs | 13 ++++++++----- crates/core_simd/src/select.rs | 2 ++ crates/core_simd/tests/f32_ops.rs | 2 ++ crates/core_simd/tests/f64_ops.rs | 2 ++ crates/core_simd/tests/i16_ops.rs | 2 ++ crates/core_simd/tests/i32_ops.rs | 2 ++ crates/core_simd/tests/i64_ops.rs | 2 ++ crates/core_simd/tests/i8_ops.rs | 2 ++ crates/core_simd/tests/isize_ops.rs | 2 ++ crates/core_simd/tests/mask_ops.rs | 2 ++ crates/core_simd/tests/masks.rs | 2 ++ crates/core_simd/tests/permute.rs | 2 ++ crates/core_simd/tests/round.rs | 2 ++ crates/core_simd/tests/to_bytes.rs | 2 ++ crates/core_simd/tests/u16_ops.rs | 2 ++ crates/core_simd/tests/u32_ops.rs | 2 ++ crates/core_simd/tests/u64_ops.rs | 2 ++ crates/core_simd/tests/u8_ops.rs | 2 ++ crates/core_simd/tests/usize_ops.rs | 2 ++ 24 files changed, 71 insertions(+), 7 deletions(-) diff --git a/crates/core_simd/examples/matrix_inversion.rs b/crates/core_simd/examples/matrix_inversion.rs index 001187124d84..5c2d4390ad08 100644 --- a/crates/core_simd/examples/matrix_inversion.rs +++ b/crates/core_simd/examples/matrix_inversion.rs @@ -1,7 +1,10 @@ //! 4x4 matrix inverse // Code ported from the `packed_simd` crate // Run this code with `cargo test --example matrix_inversion` -#![feature(array_chunks)] +#![feature( + array_chunks, + portable_simd, +)] use core_simd::*; // Gotta define our own 4x4 matrix since Rust doesn't ship multidim arrays yet :^) diff --git a/crates/core_simd/examples/nbody.rs b/crates/core_simd/examples/nbody.rs index 44e1c6e87d0e..40e4e18b0264 100644 --- a/crates/core_simd/examples/nbody.rs +++ b/crates/core_simd/examples/nbody.rs @@ -1,3 +1,5 @@ +#![feature(portable_simd)] + /// Benchmarks game nbody code /// Taken from the `packed_simd` crate /// Run this benchmark with `cargo test --example nbody` diff --git a/crates/core_simd/src/array.rs b/crates/core_simd/src/array.rs index 0a52876e55b5..25c53097bebe 100644 --- a/crates/core_simd/src/array.rs +++ b/crates/core_simd/src/array.rs @@ -25,6 +25,7 @@ where /// SIMD gather: construct a SIMD vector by reading from a slice, using potentially discontiguous indices. /// If an index is out of bounds, that lane instead selects the value from the "or" vector. /// ``` + /// # #![feature(portable_simd)] /// # use core_simd::*; /// let vec: Vec = vec![10, 11, 12, 13, 14, 15, 16, 17, 18]; /// let idxs = SimdUsize::<4>::from_array([9, 3, 0, 5]); @@ -42,6 +43,7 @@ where /// SIMD gather: construct a SIMD vector by reading from a slice, using potentially discontiguous indices. /// Out-of-bounds indices instead use the default value for that lane (0). /// ``` + /// # #![feature(portable_simd)] /// # use core_simd::*; /// let vec: Vec = vec![10, 11, 12, 13, 14, 15, 16, 17, 18]; /// let idxs = SimdUsize::<4>::from_array([9, 3, 0, 5]); @@ -61,6 +63,7 @@ where /// SIMD gather: construct a SIMD vector by reading from a slice, using potentially discontiguous indices. /// Out-of-bounds or masked indices instead select the value from the "or" vector. /// ``` + /// # #![feature(portable_simd)] /// # use core_simd::*; /// let vec: Vec = vec![10, 11, 12, 13, 14, 15, 16, 17, 18]; /// let idxs = SimdUsize::<4>::from_array([9, 3, 0, 5]); @@ -90,6 +93,7 @@ where /// Out-of-bounds indices are not written. /// `scatter` writes "in order", so if an index receives two writes, only the last is guaranteed. /// ``` + /// # #![feature(portable_simd)] /// # use core_simd::*; /// let mut vec: Vec = vec![10, 11, 12, 13, 14, 15, 16, 17, 18]; /// let idxs = SimdUsize::<4>::from_array([9, 3, 0, 0]); @@ -107,6 +111,7 @@ where /// Out-of-bounds or masked indices are not written. /// `scatter_select` writes "in order", so if an index receives two writes, only the last is guaranteed. /// ``` + /// # #![feature(portable_simd)] /// # use core_simd::*; /// let mut vec: Vec = vec![10, 11, 12, 13, 14, 15, 16, 17, 18]; /// let idxs = SimdUsize::<4>::from_array([9, 3, 0, 0]); diff --git a/crates/core_simd/src/lib.rs b/crates/core_simd/src/lib.rs index 235733b34909..a64904dee304 100644 --- a/crates/core_simd/src/lib.rs +++ b/crates/core_simd/src/lib.rs @@ -1,7 +1,15 @@ #![no_std] #![allow(incomplete_features)] -#![feature(repr_simd, platform_intrinsics, simd_ffi, const_generics, stdsimd)] +#![feature( + const_generics, + platform_intrinsics, + repr_simd, + simd_ffi, + staged_api, + stdsimd, +)] #![warn(missing_docs)] +#![unstable(feature = "portable_simd", issue = "86656")] //! Portable SIMD module. #[macro_use] diff --git a/crates/core_simd/src/math.rs b/crates/core_simd/src/math.rs index 6a243dbd1962..7290a28362f9 100644 --- a/crates/core_simd/src/math.rs +++ b/crates/core_simd/src/math.rs @@ -6,6 +6,7 @@ macro_rules! impl_uint_arith { /// /// # Examples /// ``` + /// # #![feature(portable_simd)] /// # use core_simd::*; #[doc = concat!("# use core::", stringify!($n), "::MAX;")] #[doc = concat!("let x = ", stringify!($name), "::from_array([2, 1, 0, MAX]);")] @@ -24,6 +25,7 @@ macro_rules! impl_uint_arith { /// /// # Examples /// ``` + /// # #![feature(portable_simd)] /// # use core_simd::*; #[doc = concat!("# use core::", stringify!($n), "::MAX;")] #[doc = concat!("let x = ", stringify!($name), "::from_array([2, 1, 0, MAX]);")] @@ -48,6 +50,7 @@ macro_rules! impl_int_arith { /// /// # Examples /// ``` + /// # #![feature(portable_simd)] /// # use core_simd::*; #[doc = concat!("# use core::", stringify!($n), "::{MIN, MAX};")] #[doc = concat!("let x = ", stringify!($name), "::from_array([MIN, 0, 1, MAX]);")] @@ -66,6 +69,7 @@ macro_rules! impl_int_arith { /// /// # Examples /// ``` + /// # #![feature(portable_simd)] /// # use core_simd::*; #[doc = concat!("# use core::", stringify!($n), "::{MIN, MAX};")] #[doc = concat!("let x = ", stringify!($name), "::from_array([MIN, -2, -1, MAX]);")] @@ -84,6 +88,7 @@ macro_rules! impl_int_arith { /// /// # Examples /// ``` + /// # #![feature(portable_simd)] /// # use core_simd::*; #[doc = concat!("# use core::", stringify!($n), "::{MIN, MAX};")] #[doc = concat!("let xs = ", stringify!($name), "::from_array([MIN, MIN +1, -5, 0]);")] @@ -101,6 +106,7 @@ macro_rules! impl_int_arith { /// /// # Examples /// ``` + /// # #![feature(portable_simd)] /// # use core_simd::*; #[doc = concat!("# use core::", stringify!($n), "::{MIN, MAX};")] #[doc = concat!("let xs = ", stringify!($name), "::from_array([MIN, -2, 0, 3]);")] @@ -122,6 +128,7 @@ macro_rules! impl_int_arith { /// /// # Examples /// ``` + /// # #![feature(portable_simd)] /// # use core_simd::*; #[doc = concat!("# use core::", stringify!($n), "::{MIN, MAX};")] #[doc = concat!("let x = ", stringify!($name), "::from_array([MIN, -2, 3, MAX]);")] diff --git a/crates/core_simd/src/permute.rs b/crates/core_simd/src/permute.rs index a64fdbc9dd0a..01148a26bad4 100644 --- a/crates/core_simd/src/permute.rs +++ b/crates/core_simd/src/permute.rs @@ -11,12 +11,13 @@ macro_rules! impl_shuffle_lane { /// than storing and reloading from memory. /// /// ``` + /// #![feature(portable_simd)] /// # use core_simd::*; - // let a = f32x4::from_array([1.0, 2.0, 3.0, 4.0]); - // let b = f32x4::from_array([5.0, 6.0, 7.0, 8.0]); - // const IDXS: [u32; 4] = [4,0,3,7]; - // let c = f32x4::shuffle::(a,b); - // assert_eq!(f32x4::from_array([5.0, 1.0, 4.0, 8.0]), c); + /// let a = f32x4::from_array([1.0, 2.0, 3.0, 4.0]); + /// let b = f32x4::from_array([5.0, 6.0, 7.0, 8.0]); + /// const IDXS: [u32; 4] = [4,0,3,7]; + /// let c = f32x4::shuffle::(a,b); + /// assert_eq!(f32x4::from_array([5.0, 1.0, 4.0, 8.0]), c); /// ``` #[inline] pub fn shuffle(self, second: Self) -> Self { @@ -51,6 +52,7 @@ macro_rules! impl_shuffle_lane { /// This particular permutation is efficient on many architectures. /// /// ``` + /// #![feature(portable_simd)] /// # use core_simd::SimdU32; /// let a = SimdU32::from_array([0, 1, 2, 3]); /// let b = SimdU32::from_array([4, 5, 6, 7]); @@ -102,6 +104,7 @@ macro_rules! impl_shuffle_lane { /// This particular permutation is efficient on many architectures. /// /// ``` + /// #![feature(portable_simd)] /// # use core_simd::SimdU32; /// let a = SimdU32::from_array([0, 4, 1, 5]); /// let b = SimdU32::from_array([2, 6, 3, 7]); diff --git a/crates/core_simd/src/select.rs b/crates/core_simd/src/select.rs index 343fd33a5350..dee1d775eb82 100644 --- a/crates/core_simd/src/select.rs +++ b/crates/core_simd/src/select.rs @@ -57,6 +57,7 @@ macro_rules! impl_select { /// that lane mask is true, and `false_values` if that lane mask is false. /// /// ``` + /// # #![feature(portable_simd)] /// # use core_simd::{Mask32, SimdI32}; /// let a = SimdI32::from_array([0, 1, 2, 3]); /// let b = SimdI32::from_array([4, 5, 6, 7]); @@ -67,6 +68,7 @@ macro_rules! impl_select { /// /// `select` can also be used on masks: /// ``` + /// # #![feature(portable_simd)] /// # use core_simd::Mask32; /// let a = Mask32::from_array([true, true, false, false]); /// let b = Mask32::from_array([false, false, true, true]); diff --git a/crates/core_simd/tests/f32_ops.rs b/crates/core_simd/tests/f32_ops.rs index ac5499b7ffeb..98283110097e 100644 --- a/crates/core_simd/tests/f32_ops.rs +++ b/crates/core_simd/tests/f32_ops.rs @@ -1,3 +1,5 @@ +#![feature(portable_simd)] + #[macro_use] mod ops_macros; impl_float_tests! { SimdF32, f32, i32 } diff --git a/crates/core_simd/tests/f64_ops.rs b/crates/core_simd/tests/f64_ops.rs index dcdb2aa31522..0818b0c5c5a9 100644 --- a/crates/core_simd/tests/f64_ops.rs +++ b/crates/core_simd/tests/f64_ops.rs @@ -1,3 +1,5 @@ +#![feature(portable_simd)] + #[macro_use] mod ops_macros; impl_float_tests! { SimdF64, f64, i64 } diff --git a/crates/core_simd/tests/i16_ops.rs b/crates/core_simd/tests/i16_ops.rs index 4d2a7b053b5c..33d92faa5956 100644 --- a/crates/core_simd/tests/i16_ops.rs +++ b/crates/core_simd/tests/i16_ops.rs @@ -1,3 +1,5 @@ +#![feature(portable_simd)] + #[macro_use] mod ops_macros; impl_signed_tests! { SimdI16, i16 } diff --git a/crates/core_simd/tests/i32_ops.rs b/crates/core_simd/tests/i32_ops.rs index 90079d727e4b..481bca23e834 100644 --- a/crates/core_simd/tests/i32_ops.rs +++ b/crates/core_simd/tests/i32_ops.rs @@ -1,3 +1,5 @@ +#![feature(portable_simd)] + #[macro_use] mod ops_macros; impl_signed_tests! { SimdI32, i32 } diff --git a/crates/core_simd/tests/i64_ops.rs b/crates/core_simd/tests/i64_ops.rs index ebc3e194974b..5ab0614c8480 100644 --- a/crates/core_simd/tests/i64_ops.rs +++ b/crates/core_simd/tests/i64_ops.rs @@ -1,3 +1,5 @@ +#![feature(portable_simd)] + #[macro_use] mod ops_macros; impl_signed_tests! { SimdI64, i64 } diff --git a/crates/core_simd/tests/i8_ops.rs b/crates/core_simd/tests/i8_ops.rs index 082422b86d29..0db9ee47a9e2 100644 --- a/crates/core_simd/tests/i8_ops.rs +++ b/crates/core_simd/tests/i8_ops.rs @@ -1,3 +1,5 @@ +#![feature(portable_simd)] + #[macro_use] mod ops_macros; impl_signed_tests! { SimdI8, i8 } diff --git a/crates/core_simd/tests/isize_ops.rs b/crates/core_simd/tests/isize_ops.rs index 1509d701c29a..8f5470b685c9 100644 --- a/crates/core_simd/tests/isize_ops.rs +++ b/crates/core_simd/tests/isize_ops.rs @@ -1,3 +1,5 @@ +#![feature(portable_simd)] + #[macro_use] mod ops_macros; impl_signed_tests! { SimdIsize, isize } diff --git a/crates/core_simd/tests/mask_ops.rs b/crates/core_simd/tests/mask_ops.rs index 96330550b40b..f113b50cb769 100644 --- a/crates/core_simd/tests/mask_ops.rs +++ b/crates/core_simd/tests/mask_ops.rs @@ -1 +1,3 @@ +#![feature(portable_simd)] + mod mask_ops_impl; diff --git a/crates/core_simd/tests/masks.rs b/crates/core_simd/tests/masks.rs index 32dea49729f0..61d8e449744b 100644 --- a/crates/core_simd/tests/masks.rs +++ b/crates/core_simd/tests/masks.rs @@ -1,3 +1,5 @@ +#![feature(portable_simd)] + #[cfg(target_arch = "wasm32")] use wasm_bindgen_test::*; diff --git a/crates/core_simd/tests/permute.rs b/crates/core_simd/tests/permute.rs index 2be43c9cf3ce..4c771002528f 100644 --- a/crates/core_simd/tests/permute.rs +++ b/crates/core_simd/tests/permute.rs @@ -1,3 +1,5 @@ +#![feature(portable_simd)] + use core_simd::SimdU32; #[cfg(target_arch = "wasm32")] diff --git a/crates/core_simd/tests/round.rs b/crates/core_simd/tests/round.rs index 85853c0e8778..37044a751125 100644 --- a/crates/core_simd/tests/round.rs +++ b/crates/core_simd/tests/round.rs @@ -1,3 +1,5 @@ +#![feature(portable_simd)] + macro_rules! float_rounding_test { { $vector:ident, $scalar:tt, $int_scalar:tt } => { mod $scalar { diff --git a/crates/core_simd/tests/to_bytes.rs b/crates/core_simd/tests/to_bytes.rs index 20da1652a6dd..11228680dde7 100644 --- a/crates/core_simd/tests/to_bytes.rs +++ b/crates/core_simd/tests/to_bytes.rs @@ -1,3 +1,5 @@ +#![feature(portable_simd)] + use core_simd::SimdU32; #[test] diff --git a/crates/core_simd/tests/u16_ops.rs b/crates/core_simd/tests/u16_ops.rs index 488e703d54fb..d220dae64568 100644 --- a/crates/core_simd/tests/u16_ops.rs +++ b/crates/core_simd/tests/u16_ops.rs @@ -1,3 +1,5 @@ +#![feature(portable_simd)] + #[macro_use] mod ops_macros; impl_unsigned_tests! { SimdU16, u16 } diff --git a/crates/core_simd/tests/u32_ops.rs b/crates/core_simd/tests/u32_ops.rs index bf0631029e37..f27cc30a17fc 100644 --- a/crates/core_simd/tests/u32_ops.rs +++ b/crates/core_simd/tests/u32_ops.rs @@ -1,3 +1,5 @@ +#![feature(portable_simd)] + #[macro_use] mod ops_macros; impl_unsigned_tests! { SimdU32, u32 } diff --git a/crates/core_simd/tests/u64_ops.rs b/crates/core_simd/tests/u64_ops.rs index e52fc3cfce1f..ec3df39c53c3 100644 --- a/crates/core_simd/tests/u64_ops.rs +++ b/crates/core_simd/tests/u64_ops.rs @@ -1,3 +1,5 @@ +#![feature(portable_simd)] + #[macro_use] mod ops_macros; impl_unsigned_tests! { SimdU64, u64 } diff --git a/crates/core_simd/tests/u8_ops.rs b/crates/core_simd/tests/u8_ops.rs index 45be3580ec39..2c52a52b9216 100644 --- a/crates/core_simd/tests/u8_ops.rs +++ b/crates/core_simd/tests/u8_ops.rs @@ -1,3 +1,5 @@ +#![feature(portable_simd)] + #[macro_use] mod ops_macros; impl_unsigned_tests! { SimdU8, u8 } diff --git a/crates/core_simd/tests/usize_ops.rs b/crates/core_simd/tests/usize_ops.rs index 1ce6e7180045..070edc4e266f 100644 --- a/crates/core_simd/tests/usize_ops.rs +++ b/crates/core_simd/tests/usize_ops.rs @@ -1,3 +1,5 @@ +#![feature(portable_simd)] + #[macro_use] mod ops_macros; impl_unsigned_tests! { SimdUsize, usize }