From b3380eff0780254e2f51b17e3e559919d04a4b7f Mon Sep 17 00:00:00 2001 From: "Alexandre A. Bizri" Date: Tue, 4 Mar 2025 15:59:08 +0100 Subject: [PATCH 1/3] feat: add portable_simd trait implementations for the x1 variants --- src/simd/portable_simd_impl.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/simd/portable_simd_impl.rs b/src/simd/portable_simd_impl.rs index 766fd20..cdbed54 100644 --- a/src/simd/portable_simd_impl.rs +++ b/src/simd/portable_simd_impl.rs @@ -1498,82 +1498,99 @@ fn simd_complex_from_polar(r: N, theta: N) -> num_complex::Com } impl_float_simd!( + portable_simd::f32x1, f32, portable_simd::i32x1, mask32x1, _0; portable_simd::f32x2, f32, portable_simd::i32x2, mask32x2, _0, _1; portable_simd::f32x4, f32, portable_simd::i32x4, mask32x4, _0, _1, _2, _3; portable_simd::f32x8, f32, portable_simd::i32x8, mask32x8, _0, _1, _2, _3, _4, _5, _6, _7; portable_simd::f32x16, f32, portable_simd::i32x16, mask32x16, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15; + portable_simd::f64x1, f64, portable_simd::i64x1, mask64x1, _0; portable_simd::f64x2, f64, portable_simd::i64x2, mask64x2, _0, _1; portable_simd::f64x4, f64, portable_simd::i64x4, mask64x4, _0, _1, _2, _3; portable_simd::f64x8, f64, portable_simd::i64x8, mask64x8, _0, _1, _2, _3, _4, _5, _6, _7; ); impl_int_simd!( + portable_simd::i16x1, i16, mask16x1, _0; portable_simd::i16x2, i16, mask16x2, _0, _1; portable_simd::i16x4, i16, mask16x4, _0, _1, _2, _3; portable_simd::i16x8, i16, mask16x8, _0, _1, _2, _3, _4, _5, _6, _7; portable_simd::i16x16, i16, mask16x16, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15; portable_simd::i16x32, i16, mask16x32, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31; + portable_simd::i32x1, i32, mask32x1, _0; portable_simd::i32x2, i32, mask32x2, _0, _1; portable_simd::i32x4, i32, mask32x4, _0, _1, _2, _3; portable_simd::i32x8, i32, mask32x8, _0, _1, _2, _3, _4, _5, _6, _7; portable_simd::i32x16, i32, mask32x16, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15; + portable_simd::i64x1, i64, mask64x1, _0; portable_simd::i64x2, i64, mask64x2, _0, _1; portable_simd::i64x4, i64, mask64x4, _0, _1, _2, _3; portable_simd::i64x8, i64, mask64x8, _0, _1, _2, _3, _4, _5, _6, _7; + portable_simd::i8x1, i8, mask8x1, _0; portable_simd::i8x2, i8, mask8x2, _0, _1; portable_simd::i8x4, i8, mask8x4, _0, _1, _2, _3; portable_simd::i8x8, i8, mask8x8, _0, _1, _2, _3, _4, _5, _6, _7; portable_simd::i8x16, i8, mask8x16, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15; portable_simd::i8x32, i8, mask8x32, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31; portable_simd::i8x64, i8, mask8x64, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63; + portable_simd::isizex1, isize, masksizex1, _0; portable_simd::isizex2, isize, masksizex2, _0, _1; portable_simd::isizex4, isize, masksizex4, _0, _1, _2, _3; portable_simd::isizex8, isize, masksizex8, _0, _1, _2, _3, _4, _5, _6, _7; ); impl_uint_simd!( + portable_simd::u16x1, u16, mask16x1, _0; portable_simd::u16x2, u16, mask16x2, _0, _1; portable_simd::u16x4, u16, mask16x4, _0, _1, _2, _3; portable_simd::u16x8, u16, mask16x8, _0, _1, _2, _3, _4, _5, _6, _7; portable_simd::u16x16, u16, mask16x16, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15; portable_simd::u16x32, u16, mask16x32, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31; + portable_simd::u32x1, u32, mask32x1, _0; portable_simd::u32x2, u32, mask32x2, _0, _1; portable_simd::u32x4, u32, mask32x4, _0, _1, _2, _3; portable_simd::u32x8, u32, mask32x8, _0, _1, _2, _3, _4, _5, _6, _7; portable_simd::u32x16, u32, mask32x16, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15; + portable_simd::u64x1, u64, mask64x1, _0; portable_simd::u64x2, u64, mask64x2, _0, _1; portable_simd::u64x4, u64, mask64x4, _0, _1, _2, _3; portable_simd::u64x8, u64, mask64x8, _0, _1, _2, _3, _4, _5, _6, _7; + portable_simd::u8x1, u8, mask8x1, _0; portable_simd::u8x2, u8, mask8x2, _0, _1; portable_simd::u8x4, u8, mask8x4, _0, _1, _2, _3; portable_simd::u8x8, u8, mask8x8, _0, _1, _2, _3, _4, _5, _6, _7; portable_simd::u8x16, u8, mask8x16, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15; portable_simd::u8x32, u8, mask8x32, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31; portable_simd::u8x64, u8, mask8x64, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63; + portable_simd::usizex1, usize, masksizex1, _0; portable_simd::usizex2, usize, masksizex2, _0, _1; portable_simd::usizex4, usize, masksizex4, _0, _1, _2, _3; portable_simd::usizex8, usize, masksizex8, _0, _1, _2, _3, _4, _5, _6, _7; ); impl_bool_simd!( + portable_simd::mask16x1, 1, _0; portable_simd::mask16x2, 2, _0, _1; portable_simd::mask16x4, 4, _0, _1, _2, _3; portable_simd::mask16x8, 8, _0, _1, _2, _3, _4, _5, _6, _7; portable_simd::mask16x16, 16, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15; portable_simd::mask16x32, 32, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31; + portable_simd::mask32x1, 1, _0; portable_simd::mask32x2, 2, _0, _1; portable_simd::mask32x4, 4, _0, _1, _2, _3; portable_simd::mask32x8, 8, _0, _1, _2, _3, _4, _5, _6, _7; portable_simd::mask32x16, 16, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15; + portable_simd::mask64x1, 1, _0; portable_simd::mask64x2, 2, _0, _1; portable_simd::mask64x4, 4, _0, _1, _2, _3; portable_simd::mask64x8, 8, _0, _1, _2, _3, _4, _5, _6, _7; + portable_simd::mask8x1, 1, _0; portable_simd::mask8x2, 2, _0, _1; portable_simd::mask8x4, 4, _0, _1, _2, _3; portable_simd::mask8x8, 8, _0, _1, _2, _3, _4, _5, _6, _7; portable_simd::mask8x16, 16, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15; portable_simd::mask8x32, 32, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31; portable_simd::mask8x64, 64, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63; + portable_simd::masksizex1, 1, _0; portable_simd::masksizex2, 2, _0, _1; portable_simd::masksizex4, 4, _0, _1, _2, _3; portable_simd::masksizex8, 8, _0, _1, _2, _3, _4, _5, _6, _7; @@ -1607,52 +1624,64 @@ impl_bool_simd!( // Aliases // ////////////////////////////////////////// +pub type f32x1 = Simd; pub type f32x2 = Simd; pub type f32x4 = Simd; pub type f32x8 = Simd; pub type f32x16 = Simd; +pub type f64x1 = Simd; pub type f64x2 = Simd; pub type f64x4 = Simd; pub type f64x8 = Simd; +pub type i16x1 = Simd; pub type i16x2 = Simd; pub type i16x4 = Simd; pub type i16x8 = Simd; pub type i16x16 = Simd; pub type i16x32 = Simd; +pub type i32x1 = Simd; pub type i32x2 = Simd; pub type i32x4 = Simd; pub type i32x8 = Simd; pub type i32x16 = Simd; +pub type i64x1 = Simd; pub type i64x2 = Simd; pub type i64x4 = Simd; pub type i64x8 = Simd; +pub type i8x1 = Simd; pub type i8x2 = Simd; pub type i8x4 = Simd; pub type i8x8 = Simd; pub type i8x16 = Simd; pub type i8x32 = Simd; pub type i8x64 = Simd; +pub type isizex1 = Simd; pub type isizex2 = Simd; pub type isizex4 = Simd; pub type isizex8 = Simd; +pub type u16x1 = Simd; pub type u16x2 = Simd; pub type u16x4 = Simd; pub type u16x8 = Simd; pub type u16x16 = Simd; pub type u16x32 = Simd; +pub type u32x1 = Simd; pub type u32x2 = Simd; pub type u32x4 = Simd; pub type u32x8 = Simd; pub type u32x16 = Simd; +pub type u64x1 = Simd; pub type u64x2 = Simd; pub type u64x4 = Simd; pub type u64x8 = Simd; +pub type u8x1 = Simd; pub type u8x2 = Simd; pub type u8x4 = Simd; pub type u8x8 = Simd; pub type u8x16 = Simd; pub type u8x32 = Simd; pub type u8x64 = Simd; +pub type usizex1 = Simd; pub type usizex2 = Simd; pub type usizex4 = Simd; pub type usizex8 = Simd; From 5c407e3857144be6b9b7a677240d386de1942c07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Sun, 28 Sep 2025 11:45:27 +0200 Subject: [PATCH 2/3] chore: clippy fixes --- src/simd/portable_simd_impl.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/simd/portable_simd_impl.rs b/src/simd/portable_simd_impl.rs index cdbed54..c6c26fb 100644 --- a/src/simd/portable_simd_impl.rs +++ b/src/simd/portable_simd_impl.rs @@ -58,6 +58,8 @@ macro_rules! impl_bool_simd ( write!(f, "({}", self.extract(0))?; + // Suppress warning for single-lanes values. + #[allow(clippy::reversed_empty_ranges)] for i in 1..Self::LANES { write!(f, ", {}", self.extract(i))?; } @@ -279,6 +281,8 @@ macro_rules! impl_simd_value ( write!(f, "({}", self.extract(0))?; + // Suppress warning for single-lanes values. + #[allow(clippy::reversed_empty_ranges)] for i in 1..Self::LANES { write!(f, ", {}", self.extract(i))?; } @@ -1070,6 +1074,9 @@ macro_rules! impl_float_simd ( #[inline(always)] fn simd_horizontal_product(self) -> Self::Element { let mut prod = self.extract(0); + + // Suppress warning for single-lanes values. + #[allow(clippy::reversed_empty_ranges)] for ii in 1..Self::LANES { prod *= self.extract(ii) } From 8b7acaee28463cfab5dce7bd7db88d0bce15bac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Sun, 28 Sep 2025 11:46:12 +0200 Subject: [PATCH 3/3] chore: update changelog --- CHANGELOG | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 9c44e2f..f140a54 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +## Unreleased +- Add single-lanes portable-simd trait implementations. + ## Release v0.9.1 (05 Sept. 2025) - `into_arr`, `from_arr`, `map`, `zip_map` are now public on `WideF32x4`, `WideF32x8` and `WideF64x4`. - `from_arr` and `into_arr` are now public on `WideBoolF32x4`, `WideBoolF32x8`, `WideBoolF64x4`.