Skip to content

Commit bcddedb

Browse files
aabizrisebcrozet
andauthored
feat: add x1 portable_simd type aliases (f32x1, ...) and implementations of the corresponding traits (#67)
* feat: add portable_simd trait implementations for the x1 variants * chore: clippy fixes * chore: update changelog --------- Co-authored-by: Sébastien Crozet <[email protected]>
1 parent e7fe5c2 commit bcddedb

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## Unreleased
2+
- Add single-lanes portable-simd trait implementations.
3+
14
## Release v0.9.1 (05 Sept. 2025)
25
- `into_arr`, `from_arr`, `map`, `zip_map` are now public on `WideF32x4`, `WideF32x8` and `WideF64x4`.
36
- `from_arr` and `into_arr` are now public on `WideBoolF32x4`, `WideBoolF32x8`, `WideBoolF64x4`.

src/simd/portable_simd_impl.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ macro_rules! impl_bool_simd (
5858

5959
write!(f, "({}", self.extract(0))?;
6060

61+
// Suppress warning for single-lanes values.
62+
#[allow(clippy::reversed_empty_ranges)]
6163
for i in 1..Self::LANES {
6264
write!(f, ", {}", self.extract(i))?;
6365
}
@@ -279,6 +281,8 @@ macro_rules! impl_simd_value (
279281

280282
write!(f, "({}", self.extract(0))?;
281283

284+
// Suppress warning for single-lanes values.
285+
#[allow(clippy::reversed_empty_ranges)]
282286
for i in 1..Self::LANES {
283287
write!(f, ", {}", self.extract(i))?;
284288
}
@@ -1070,6 +1074,9 @@ macro_rules! impl_float_simd (
10701074
#[inline(always)]
10711075
fn simd_horizontal_product(self) -> Self::Element {
10721076
let mut prod = self.extract(0);
1077+
1078+
// Suppress warning for single-lanes values.
1079+
#[allow(clippy::reversed_empty_ranges)]
10731080
for ii in 1..Self::LANES {
10741081
prod *= self.extract(ii)
10751082
}
@@ -1498,82 +1505,99 @@ fn simd_complex_from_polar<N: SimdRealField>(r: N, theta: N) -> num_complex::Com
14981505
}
14991506

15001507
impl_float_simd!(
1508+
portable_simd::f32x1, f32, portable_simd::i32x1, mask32x1, _0;
15011509
portable_simd::f32x2, f32, portable_simd::i32x2, mask32x2, _0, _1;
15021510
portable_simd::f32x4, f32, portable_simd::i32x4, mask32x4, _0, _1, _2, _3;
15031511
portable_simd::f32x8, f32, portable_simd::i32x8, mask32x8, _0, _1, _2, _3, _4, _5, _6, _7;
15041512
portable_simd::f32x16, f32, portable_simd::i32x16, mask32x16, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
1513+
portable_simd::f64x1, f64, portable_simd::i64x1, mask64x1, _0;
15051514
portable_simd::f64x2, f64, portable_simd::i64x2, mask64x2, _0, _1;
15061515
portable_simd::f64x4, f64, portable_simd::i64x4, mask64x4, _0, _1, _2, _3;
15071516
portable_simd::f64x8, f64, portable_simd::i64x8, mask64x8, _0, _1, _2, _3, _4, _5, _6, _7;
15081517
);
15091518

15101519
impl_int_simd!(
1520+
portable_simd::i16x1, i16, mask16x1, _0;
15111521
portable_simd::i16x2, i16, mask16x2, _0, _1;
15121522
portable_simd::i16x4, i16, mask16x4, _0, _1, _2, _3;
15131523
portable_simd::i16x8, i16, mask16x8, _0, _1, _2, _3, _4, _5, _6, _7;
15141524
portable_simd::i16x16, i16, mask16x16, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
15151525
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;
1526+
portable_simd::i32x1, i32, mask32x1, _0;
15161527
portable_simd::i32x2, i32, mask32x2, _0, _1;
15171528
portable_simd::i32x4, i32, mask32x4, _0, _1, _2, _3;
15181529
portable_simd::i32x8, i32, mask32x8, _0, _1, _2, _3, _4, _5, _6, _7;
15191530
portable_simd::i32x16, i32, mask32x16, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
1531+
portable_simd::i64x1, i64, mask64x1, _0;
15201532
portable_simd::i64x2, i64, mask64x2, _0, _1;
15211533
portable_simd::i64x4, i64, mask64x4, _0, _1, _2, _3;
15221534
portable_simd::i64x8, i64, mask64x8, _0, _1, _2, _3, _4, _5, _6, _7;
1535+
portable_simd::i8x1, i8, mask8x1, _0;
15231536
portable_simd::i8x2, i8, mask8x2, _0, _1;
15241537
portable_simd::i8x4, i8, mask8x4, _0, _1, _2, _3;
15251538
portable_simd::i8x8, i8, mask8x8, _0, _1, _2, _3, _4, _5, _6, _7;
15261539
portable_simd::i8x16, i8, mask8x16, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
15271540
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;
15281541
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;
1542+
portable_simd::isizex1, isize, masksizex1, _0;
15291543
portable_simd::isizex2, isize, masksizex2, _0, _1;
15301544
portable_simd::isizex4, isize, masksizex4, _0, _1, _2, _3;
15311545
portable_simd::isizex8, isize, masksizex8, _0, _1, _2, _3, _4, _5, _6, _7;
15321546
);
15331547

15341548
impl_uint_simd!(
1549+
portable_simd::u16x1, u16, mask16x1, _0;
15351550
portable_simd::u16x2, u16, mask16x2, _0, _1;
15361551
portable_simd::u16x4, u16, mask16x4, _0, _1, _2, _3;
15371552
portable_simd::u16x8, u16, mask16x8, _0, _1, _2, _3, _4, _5, _6, _7;
15381553
portable_simd::u16x16, u16, mask16x16, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
15391554
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;
1555+
portable_simd::u32x1, u32, mask32x1, _0;
15401556
portable_simd::u32x2, u32, mask32x2, _0, _1;
15411557
portable_simd::u32x4, u32, mask32x4, _0, _1, _2, _3;
15421558
portable_simd::u32x8, u32, mask32x8, _0, _1, _2, _3, _4, _5, _6, _7;
15431559
portable_simd::u32x16, u32, mask32x16, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
1560+
portable_simd::u64x1, u64, mask64x1, _0;
15441561
portable_simd::u64x2, u64, mask64x2, _0, _1;
15451562
portable_simd::u64x4, u64, mask64x4, _0, _1, _2, _3;
15461563
portable_simd::u64x8, u64, mask64x8, _0, _1, _2, _3, _4, _5, _6, _7;
1564+
portable_simd::u8x1, u8, mask8x1, _0;
15471565
portable_simd::u8x2, u8, mask8x2, _0, _1;
15481566
portable_simd::u8x4, u8, mask8x4, _0, _1, _2, _3;
15491567
portable_simd::u8x8, u8, mask8x8, _0, _1, _2, _3, _4, _5, _6, _7;
15501568
portable_simd::u8x16, u8, mask8x16, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
15511569
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;
15521570
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;
1571+
portable_simd::usizex1, usize, masksizex1, _0;
15531572
portable_simd::usizex2, usize, masksizex2, _0, _1;
15541573
portable_simd::usizex4, usize, masksizex4, _0, _1, _2, _3;
15551574
portable_simd::usizex8, usize, masksizex8, _0, _1, _2, _3, _4, _5, _6, _7;
15561575
);
15571576

15581577
impl_bool_simd!(
1578+
portable_simd::mask16x1, 1, _0;
15591579
portable_simd::mask16x2, 2, _0, _1;
15601580
portable_simd::mask16x4, 4, _0, _1, _2, _3;
15611581
portable_simd::mask16x8, 8, _0, _1, _2, _3, _4, _5, _6, _7;
15621582
portable_simd::mask16x16, 16, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
15631583
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;
1584+
portable_simd::mask32x1, 1, _0;
15641585
portable_simd::mask32x2, 2, _0, _1;
15651586
portable_simd::mask32x4, 4, _0, _1, _2, _3;
15661587
portable_simd::mask32x8, 8, _0, _1, _2, _3, _4, _5, _6, _7;
15671588
portable_simd::mask32x16, 16, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
1589+
portable_simd::mask64x1, 1, _0;
15681590
portable_simd::mask64x2, 2, _0, _1;
15691591
portable_simd::mask64x4, 4, _0, _1, _2, _3;
15701592
portable_simd::mask64x8, 8, _0, _1, _2, _3, _4, _5, _6, _7;
1593+
portable_simd::mask8x1, 1, _0;
15711594
portable_simd::mask8x2, 2, _0, _1;
15721595
portable_simd::mask8x4, 4, _0, _1, _2, _3;
15731596
portable_simd::mask8x8, 8, _0, _1, _2, _3, _4, _5, _6, _7;
15741597
portable_simd::mask8x16, 16, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
15751598
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;
15761599
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;
1600+
portable_simd::masksizex1, 1, _0;
15771601
portable_simd::masksizex2, 2, _0, _1;
15781602
portable_simd::masksizex4, 4, _0, _1, _2, _3;
15791603
portable_simd::masksizex8, 8, _0, _1, _2, _3, _4, _5, _6, _7;
@@ -1607,52 +1631,64 @@ impl_bool_simd!(
16071631
// Aliases //
16081632
//////////////////////////////////////////
16091633

1634+
pub type f32x1 = Simd<portable_simd::f32x1>;
16101635
pub type f32x2 = Simd<portable_simd::f32x2>;
16111636
pub type f32x4 = Simd<portable_simd::f32x4>;
16121637
pub type f32x8 = Simd<portable_simd::f32x8>;
16131638
pub type f32x16 = Simd<portable_simd::f32x16>;
1639+
pub type f64x1 = Simd<portable_simd::f64x1>;
16141640
pub type f64x2 = Simd<portable_simd::f64x2>;
16151641
pub type f64x4 = Simd<portable_simd::f64x4>;
16161642
pub type f64x8 = Simd<portable_simd::f64x8>;
1643+
pub type i16x1 = Simd<portable_simd::i16x1>;
16171644
pub type i16x2 = Simd<portable_simd::i16x2>;
16181645
pub type i16x4 = Simd<portable_simd::i16x4>;
16191646
pub type i16x8 = Simd<portable_simd::i16x8>;
16201647
pub type i16x16 = Simd<portable_simd::i16x16>;
16211648
pub type i16x32 = Simd<portable_simd::i16x32>;
1649+
pub type i32x1 = Simd<portable_simd::i32x1>;
16221650
pub type i32x2 = Simd<portable_simd::i32x2>;
16231651
pub type i32x4 = Simd<portable_simd::i32x4>;
16241652
pub type i32x8 = Simd<portable_simd::i32x8>;
16251653
pub type i32x16 = Simd<portable_simd::i32x16>;
1654+
pub type i64x1 = Simd<portable_simd::i64x1>;
16261655
pub type i64x2 = Simd<portable_simd::i64x2>;
16271656
pub type i64x4 = Simd<portable_simd::i64x4>;
16281657
pub type i64x8 = Simd<portable_simd::i64x8>;
1658+
pub type i8x1 = Simd<portable_simd::i8x1>;
16291659
pub type i8x2 = Simd<portable_simd::i8x2>;
16301660
pub type i8x4 = Simd<portable_simd::i8x4>;
16311661
pub type i8x8 = Simd<portable_simd::i8x8>;
16321662
pub type i8x16 = Simd<portable_simd::i8x16>;
16331663
pub type i8x32 = Simd<portable_simd::i8x32>;
16341664
pub type i8x64 = Simd<portable_simd::i8x64>;
1665+
pub type isizex1 = Simd<portable_simd::isizex1>;
16351666
pub type isizex2 = Simd<portable_simd::isizex2>;
16361667
pub type isizex4 = Simd<portable_simd::isizex4>;
16371668
pub type isizex8 = Simd<portable_simd::isizex8>;
1669+
pub type u16x1 = Simd<portable_simd::u16x1>;
16381670
pub type u16x2 = Simd<portable_simd::u16x2>;
16391671
pub type u16x4 = Simd<portable_simd::u16x4>;
16401672
pub type u16x8 = Simd<portable_simd::u16x8>;
16411673
pub type u16x16 = Simd<portable_simd::u16x16>;
16421674
pub type u16x32 = Simd<portable_simd::u16x32>;
1675+
pub type u32x1 = Simd<portable_simd::u32x1>;
16431676
pub type u32x2 = Simd<portable_simd::u32x2>;
16441677
pub type u32x4 = Simd<portable_simd::u32x4>;
16451678
pub type u32x8 = Simd<portable_simd::u32x8>;
16461679
pub type u32x16 = Simd<portable_simd::u32x16>;
1680+
pub type u64x1 = Simd<portable_simd::u64x1>;
16471681
pub type u64x2 = Simd<portable_simd::u64x2>;
16481682
pub type u64x4 = Simd<portable_simd::u64x4>;
16491683
pub type u64x8 = Simd<portable_simd::u64x8>;
1684+
pub type u8x1 = Simd<portable_simd::u8x1>;
16501685
pub type u8x2 = Simd<portable_simd::u8x2>;
16511686
pub type u8x4 = Simd<portable_simd::u8x4>;
16521687
pub type u8x8 = Simd<portable_simd::u8x8>;
16531688
pub type u8x16 = Simd<portable_simd::u8x16>;
16541689
pub type u8x32 = Simd<portable_simd::u8x32>;
16551690
pub type u8x64 = Simd<portable_simd::u8x64>;
1691+
pub type usizex1 = Simd<portable_simd::usizex1>;
16561692
pub type usizex2 = Simd<portable_simd::usizex2>;
16571693
pub type usizex4 = Simd<portable_simd::usizex4>;
16581694
pub type usizex8 = Simd<portable_simd::usizex8>;

0 commit comments

Comments
 (0)