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 001187124d8..5c2d4390ad0 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 44e1c6e87d0..40e4e18b026 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 0a52876e55b..25c53097beb 100644 --- a/crates/core_simd/src/array.rs +++ b/crates/core_simd/src/array.rs @@ -25,6 +25,7 @@ pub trait SimdArray: crate::LanesAtMost32 /// 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 @@ fn gather_or(slice: &[Self::Scalar], idxs: SimdUsize, or: Self) -> Self { /// 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 @@ fn gather_or_default(slice: &[Self::Scalar], idxs: SimdUsize) -> Self /// 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 @@ fn gather_select( /// 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 @@ fn scatter(self, slice: &mut [Self::Scalar], idxs: SimdUsize) { /// 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 235733b3490..a64904dee30 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 6a243dbd196..7290a28362f 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 @@ pub fn saturating_add(self, second: Self) -> Self { /// /// # 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 @@ pub fn saturating_add(self, second: Self) -> Self { /// /// # 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 @@ pub fn saturating_sub(self, second: Self) -> Self { /// /// # 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 @@ pub fn abs(self) -> Self { /// /// # 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 @@ pub fn saturating_abs(self) -> Self { /// /// # 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 a64fdbc9dd0..01148a26bad 100644 --- a/crates/core_simd/src/permute.rs +++ b/crates/core_simd/src/permute.rs @@ -11,12 +11,13 @@ impl $name<$n> { /// 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 @@ pub fn reverse(self) -> Self { /// 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 @@ pub fn interleave(self, other: Self) -> (Self, Self) { /// 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 343fd33a535..dee1d775eb8 100644 --- a/crates/core_simd/src/select.rs +++ b/crates/core_simd/src/select.rs @@ -57,6 +57,7 @@ impl crate::$mask /// 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 @@ impl crate::$mask /// /// `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 ac5499b7ffe..98283110097 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 dcdb2aa3152..0818b0c5c5a 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 4d2a7b053b5..33d92faa595 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 90079d727e4..481bca23e83 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 ebc3e194974..5ab0614c848 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 082422b86d2..0db9ee47a9e 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 1509d701c29..8f5470b685c 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 96330550b40..f113b50cb76 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 32dea49729f..61d8e449744 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 2be43c9cf3c..4c771002528 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 85853c0e877..37044a75112 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 20da1652a6d..11228680dde 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 488e703d54f..d220dae6456 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 bf0631029e3..f27cc30a17f 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 e52fc3cfce1..ec3df39c53c 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 45be3580ec3..2c52a52b921 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 1ce6e718004..070edc4e266 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 }