Skip to content

Commit be96995

Browse files
Add portable_simd unstable feature gate (#141)
1 parent 3954b27 commit be96995

24 files changed

+71
-7
lines changed

crates/core_simd/examples/matrix_inversion.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
//! 4x4 matrix inverse
22
// Code ported from the `packed_simd` crate
33
// Run this code with `cargo test --example matrix_inversion`
4-
#![feature(array_chunks)]
4+
#![feature(
5+
array_chunks,
6+
portable_simd,
7+
)]
58
use core_simd::*;
69

710
// Gotta define our own 4x4 matrix since Rust doesn't ship multidim arrays yet :^)

crates/core_simd/examples/nbody.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(portable_simd)]
2+
13
/// Benchmarks game nbody code
24
/// Taken from the `packed_simd` crate
35
/// Run this benchmark with `cargo test --example nbody`

crates/core_simd/src/array.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ where
2525
/// SIMD gather: construct a SIMD vector by reading from a slice, using potentially discontiguous indices.
2626
/// If an index is out of bounds, that lane instead selects the value from the "or" vector.
2727
/// ```
28+
/// # #![feature(portable_simd)]
2829
/// # use core_simd::*;
2930
/// let vec: Vec<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
3031
/// let idxs = SimdUsize::<4>::from_array([9, 3, 0, 5]);
@@ -42,6 +43,7 @@ where
4243
/// SIMD gather: construct a SIMD vector by reading from a slice, using potentially discontiguous indices.
4344
/// Out-of-bounds indices instead use the default value for that lane (0).
4445
/// ```
46+
/// # #![feature(portable_simd)]
4547
/// # use core_simd::*;
4648
/// let vec: Vec<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
4749
/// let idxs = SimdUsize::<4>::from_array([9, 3, 0, 5]);
@@ -61,6 +63,7 @@ where
6163
/// SIMD gather: construct a SIMD vector by reading from a slice, using potentially discontiguous indices.
6264
/// Out-of-bounds or masked indices instead select the value from the "or" vector.
6365
/// ```
66+
/// # #![feature(portable_simd)]
6467
/// # use core_simd::*;
6568
/// let vec: Vec<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
6669
/// let idxs = SimdUsize::<4>::from_array([9, 3, 0, 5]);
@@ -90,6 +93,7 @@ where
9093
/// Out-of-bounds indices are not written.
9194
/// `scatter` writes "in order", so if an index receives two writes, only the last is guaranteed.
9295
/// ```
96+
/// # #![feature(portable_simd)]
9397
/// # use core_simd::*;
9498
/// let mut vec: Vec<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
9599
/// let idxs = SimdUsize::<4>::from_array([9, 3, 0, 0]);
@@ -107,6 +111,7 @@ where
107111
/// Out-of-bounds or masked indices are not written.
108112
/// `scatter_select` writes "in order", so if an index receives two writes, only the last is guaranteed.
109113
/// ```
114+
/// # #![feature(portable_simd)]
110115
/// # use core_simd::*;
111116
/// let mut vec: Vec<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
112117
/// let idxs = SimdUsize::<4>::from_array([9, 3, 0, 0]);

crates/core_simd/src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
#![no_std]
22
#![allow(incomplete_features)]
3-
#![feature(repr_simd, platform_intrinsics, simd_ffi, const_generics, stdsimd)]
3+
#![feature(
4+
const_generics,
5+
platform_intrinsics,
6+
repr_simd,
7+
simd_ffi,
8+
staged_api,
9+
stdsimd,
10+
)]
411
#![warn(missing_docs)]
12+
#![unstable(feature = "portable_simd", issue = "86656")]
513
//! Portable SIMD module.
614
715
#[macro_use]

crates/core_simd/src/math.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ macro_rules! impl_uint_arith {
66
///
77
/// # Examples
88
/// ```
9+
/// # #![feature(portable_simd)]
910
/// # use core_simd::*;
1011
#[doc = concat!("# use core::", stringify!($n), "::MAX;")]
1112
#[doc = concat!("let x = ", stringify!($name), "::from_array([2, 1, 0, MAX]);")]
@@ -24,6 +25,7 @@ macro_rules! impl_uint_arith {
2425
///
2526
/// # Examples
2627
/// ```
28+
/// # #![feature(portable_simd)]
2729
/// # use core_simd::*;
2830
#[doc = concat!("# use core::", stringify!($n), "::MAX;")]
2931
#[doc = concat!("let x = ", stringify!($name), "::from_array([2, 1, 0, MAX]);")]
@@ -48,6 +50,7 @@ macro_rules! impl_int_arith {
4850
///
4951
/// # Examples
5052
/// ```
53+
/// # #![feature(portable_simd)]
5154
/// # use core_simd::*;
5255
#[doc = concat!("# use core::", stringify!($n), "::{MIN, MAX};")]
5356
#[doc = concat!("let x = ", stringify!($name), "::from_array([MIN, 0, 1, MAX]);")]
@@ -66,6 +69,7 @@ macro_rules! impl_int_arith {
6669
///
6770
/// # Examples
6871
/// ```
72+
/// # #![feature(portable_simd)]
6973
/// # use core_simd::*;
7074
#[doc = concat!("# use core::", stringify!($n), "::{MIN, MAX};")]
7175
#[doc = concat!("let x = ", stringify!($name), "::from_array([MIN, -2, -1, MAX]);")]
@@ -84,6 +88,7 @@ macro_rules! impl_int_arith {
8488
///
8589
/// # Examples
8690
/// ```
91+
/// # #![feature(portable_simd)]
8792
/// # use core_simd::*;
8893
#[doc = concat!("# use core::", stringify!($n), "::{MIN, MAX};")]
8994
#[doc = concat!("let xs = ", stringify!($name), "::from_array([MIN, MIN +1, -5, 0]);")]
@@ -101,6 +106,7 @@ macro_rules! impl_int_arith {
101106
///
102107
/// # Examples
103108
/// ```
109+
/// # #![feature(portable_simd)]
104110
/// # use core_simd::*;
105111
#[doc = concat!("# use core::", stringify!($n), "::{MIN, MAX};")]
106112
#[doc = concat!("let xs = ", stringify!($name), "::from_array([MIN, -2, 0, 3]);")]
@@ -122,6 +128,7 @@ macro_rules! impl_int_arith {
122128
///
123129
/// # Examples
124130
/// ```
131+
/// # #![feature(portable_simd)]
125132
/// # use core_simd::*;
126133
#[doc = concat!("# use core::", stringify!($n), "::{MIN, MAX};")]
127134
#[doc = concat!("let x = ", stringify!($name), "::from_array([MIN, -2, 3, MAX]);")]

crates/core_simd/src/permute.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ macro_rules! impl_shuffle_lane {
1111
/// than storing and reloading from memory.
1212
///
1313
/// ```
14+
/// #![feature(portable_simd)]
1415
/// # use core_simd::*;
15-
// let a = f32x4::from_array([1.0, 2.0, 3.0, 4.0]);
16-
// let b = f32x4::from_array([5.0, 6.0, 7.0, 8.0]);
17-
// const IDXS: [u32; 4] = [4,0,3,7];
18-
// let c = f32x4::shuffle::<IDXS>(a,b);
19-
// assert_eq!(f32x4::from_array([5.0, 1.0, 4.0, 8.0]), c);
16+
/// let a = f32x4::from_array([1.0, 2.0, 3.0, 4.0]);
17+
/// let b = f32x4::from_array([5.0, 6.0, 7.0, 8.0]);
18+
/// const IDXS: [u32; 4] = [4,0,3,7];
19+
/// let c = f32x4::shuffle::<IDXS>(a,b);
20+
/// assert_eq!(f32x4::from_array([5.0, 1.0, 4.0, 8.0]), c);
2021
/// ```
2122
#[inline]
2223
pub fn shuffle<const IDX: [u32; $n]>(self, second: Self) -> Self {
@@ -51,6 +52,7 @@ macro_rules! impl_shuffle_lane {
5152
/// This particular permutation is efficient on many architectures.
5253
///
5354
/// ```
55+
/// #![feature(portable_simd)]
5456
/// # use core_simd::SimdU32;
5557
/// let a = SimdU32::from_array([0, 1, 2, 3]);
5658
/// let b = SimdU32::from_array([4, 5, 6, 7]);
@@ -102,6 +104,7 @@ macro_rules! impl_shuffle_lane {
102104
/// This particular permutation is efficient on many architectures.
103105
///
104106
/// ```
107+
/// #![feature(portable_simd)]
105108
/// # use core_simd::SimdU32;
106109
/// let a = SimdU32::from_array([0, 4, 1, 5]);
107110
/// let b = SimdU32::from_array([2, 6, 3, 7]);

crates/core_simd/src/select.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ macro_rules! impl_select {
5757
/// that lane mask is true, and `false_values` if that lane mask is false.
5858
///
5959
/// ```
60+
/// # #![feature(portable_simd)]
6061
/// # use core_simd::{Mask32, SimdI32};
6162
/// let a = SimdI32::from_array([0, 1, 2, 3]);
6263
/// let b = SimdI32::from_array([4, 5, 6, 7]);
@@ -67,6 +68,7 @@ macro_rules! impl_select {
6768
///
6869
/// `select` can also be used on masks:
6970
/// ```
71+
/// # #![feature(portable_simd)]
7072
/// # use core_simd::Mask32;
7173
/// let a = Mask32::from_array([true, true, false, false]);
7274
/// let b = Mask32::from_array([false, false, true, true]);

crates/core_simd/tests/f32_ops.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(portable_simd)]
2+
13
#[macro_use]
24
mod ops_macros;
35
impl_float_tests! { SimdF32, f32, i32 }

crates/core_simd/tests/f64_ops.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(portable_simd)]
2+
13
#[macro_use]
24
mod ops_macros;
35
impl_float_tests! { SimdF64, f64, i64 }

crates/core_simd/tests/i16_ops.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(portable_simd)]
2+
13
#[macro_use]
24
mod ops_macros;
35
impl_signed_tests! { SimdI16, i16 }

crates/core_simd/tests/i32_ops.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(portable_simd)]
2+
13
#[macro_use]
24
mod ops_macros;
35
impl_signed_tests! { SimdI32, i32 }

crates/core_simd/tests/i64_ops.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(portable_simd)]
2+
13
#[macro_use]
24
mod ops_macros;
35
impl_signed_tests! { SimdI64, i64 }

crates/core_simd/tests/i8_ops.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(portable_simd)]
2+
13
#[macro_use]
24
mod ops_macros;
35
impl_signed_tests! { SimdI8, i8 }

crates/core_simd/tests/isize_ops.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(portable_simd)]
2+
13
#[macro_use]
24
mod ops_macros;
35
impl_signed_tests! { SimdIsize, isize }

crates/core_simd/tests/mask_ops.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
#![feature(portable_simd)]
2+
13
mod mask_ops_impl;

crates/core_simd/tests/masks.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(portable_simd)]
2+
13
#[cfg(target_arch = "wasm32")]
24
use wasm_bindgen_test::*;
35

crates/core_simd/tests/permute.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(portable_simd)]
2+
13
use core_simd::SimdU32;
24

35
#[cfg(target_arch = "wasm32")]

crates/core_simd/tests/round.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(portable_simd)]
2+
13
macro_rules! float_rounding_test {
24
{ $vector:ident, $scalar:tt, $int_scalar:tt } => {
35
mod $scalar {

crates/core_simd/tests/to_bytes.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(portable_simd)]
2+
13
use core_simd::SimdU32;
24

35
#[test]

crates/core_simd/tests/u16_ops.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(portable_simd)]
2+
13
#[macro_use]
24
mod ops_macros;
35
impl_unsigned_tests! { SimdU16, u16 }

crates/core_simd/tests/u32_ops.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(portable_simd)]
2+
13
#[macro_use]
24
mod ops_macros;
35
impl_unsigned_tests! { SimdU32, u32 }

crates/core_simd/tests/u64_ops.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(portable_simd)]
2+
13
#[macro_use]
24
mod ops_macros;
35
impl_unsigned_tests! { SimdU64, u64 }

crates/core_simd/tests/u8_ops.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(portable_simd)]
2+
13
#[macro_use]
24
mod ops_macros;
35
impl_unsigned_tests! { SimdU8, u8 }

crates/core_simd/tests/usize_ops.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(portable_simd)]
2+
13
#[macro_use]
24
mod ops_macros;
35
impl_unsigned_tests! { SimdUsize, usize }

0 commit comments

Comments
 (0)