Add portable_simd unstable feature gate (#141)
This commit is contained in:
parent
3954b27787
commit
be96995d8d
@ -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 :^)
|
||||
|
@ -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`
|
||||
|
@ -25,6 +25,7 @@ pub trait SimdArray<const LANES: usize>: 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<i32> = 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<LANES>, 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<i32> = 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<LANES>) -> 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<i32> = 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<i32> = 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<LANES>) {
|
||||
/// 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<i32> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
|
||||
/// let idxs = SimdUsize::<4>::from_array([9, 3, 0, 0]);
|
||||
|
@ -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]
|
||||
|
@ -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]);")]
|
||||
|
@ -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::<IDXS>(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::<IDXS>(a,b);
|
||||
/// assert_eq!(f32x4::from_array([5.0, 1.0, 4.0, 8.0]), c);
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn shuffle<const IDX: [u32; $n]>(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]);
|
||||
|
@ -57,6 +57,7 @@ impl<const LANES: usize> crate::$mask<LANES>
|
||||
/// 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<const LANES: usize> crate::$mask<LANES>
|
||||
///
|
||||
/// `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]);
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![feature(portable_simd)]
|
||||
|
||||
#[macro_use]
|
||||
mod ops_macros;
|
||||
impl_float_tests! { SimdF32, f32, i32 }
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![feature(portable_simd)]
|
||||
|
||||
#[macro_use]
|
||||
mod ops_macros;
|
||||
impl_float_tests! { SimdF64, f64, i64 }
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![feature(portable_simd)]
|
||||
|
||||
#[macro_use]
|
||||
mod ops_macros;
|
||||
impl_signed_tests! { SimdI16, i16 }
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![feature(portable_simd)]
|
||||
|
||||
#[macro_use]
|
||||
mod ops_macros;
|
||||
impl_signed_tests! { SimdI32, i32 }
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![feature(portable_simd)]
|
||||
|
||||
#[macro_use]
|
||||
mod ops_macros;
|
||||
impl_signed_tests! { SimdI64, i64 }
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![feature(portable_simd)]
|
||||
|
||||
#[macro_use]
|
||||
mod ops_macros;
|
||||
impl_signed_tests! { SimdI8, i8 }
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![feature(portable_simd)]
|
||||
|
||||
#[macro_use]
|
||||
mod ops_macros;
|
||||
impl_signed_tests! { SimdIsize, isize }
|
||||
|
@ -1 +1,3 @@
|
||||
#![feature(portable_simd)]
|
||||
|
||||
mod mask_ops_impl;
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![feature(portable_simd)]
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use wasm_bindgen_test::*;
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![feature(portable_simd)]
|
||||
|
||||
use core_simd::SimdU32;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![feature(portable_simd)]
|
||||
|
||||
macro_rules! float_rounding_test {
|
||||
{ $vector:ident, $scalar:tt, $int_scalar:tt } => {
|
||||
mod $scalar {
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![feature(portable_simd)]
|
||||
|
||||
use core_simd::SimdU32;
|
||||
|
||||
#[test]
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![feature(portable_simd)]
|
||||
|
||||
#[macro_use]
|
||||
mod ops_macros;
|
||||
impl_unsigned_tests! { SimdU16, u16 }
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![feature(portable_simd)]
|
||||
|
||||
#[macro_use]
|
||||
mod ops_macros;
|
||||
impl_unsigned_tests! { SimdU32, u32 }
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![feature(portable_simd)]
|
||||
|
||||
#[macro_use]
|
||||
mod ops_macros;
|
||||
impl_unsigned_tests! { SimdU64, u64 }
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![feature(portable_simd)]
|
||||
|
||||
#[macro_use]
|
||||
mod ops_macros;
|
||||
impl_unsigned_tests! { SimdU8, u8 }
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![feature(portable_simd)]
|
||||
|
||||
#[macro_use]
|
||||
mod ops_macros;
|
||||
impl_unsigned_tests! { SimdUsize, usize }
|
||||
|
Loading…
Reference in New Issue
Block a user