Skip to content

Commit ae86071

Browse files
authored
Add f64s and mask64s associated types (#125)
Stacked on #123 since it touches the same code. Adding 64-bit *integer* types is tricky because SSE4.2 and AVX2 are missing some important 64-bit operations, and I don't feel comfortable implementing those until #124 is addressed. However, we already have `mask64x[N]` and `f64x[N]` types. The `f32s` associated type has a `Bytes = <Self::u32s as Bytes>::Bytes` constraint, which misled me into thinking that a float type *needs* an associated int type, but that constraint is only there to assert that the two share the same `Bytes` type.
1 parent 3c9ce65 commit ae86071

File tree

13 files changed

+28
-0
lines changed

13 files changed

+28
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ This release has an [MSRV][] of 1.88.
2020
- All vector types now implement `Index` and `IndexMut`. ([#112][] by [@Ralith][])
2121
- 256-bit vector types now use native AVX2 intrinsics on supported platforms. ([#115][] by [@valadaptive][])
2222
- 8-bit integer multiplication is now implemented on x86. ([#115][] by [@valadaptive][])
23+
- New native-width associated types: `f64s` and `mask64s`. ([#125][] by [@valadaptive][])
2324

2425
### Fixed
2526

@@ -116,6 +117,7 @@ No changelog was kept for this release.
116117
[#105]: https://github.com/linebender/fearless_simd/pull/105
117118
[#115]: https://github.com/linebender/fearless_simd/pull/115
118119
[#123]: https://github.com/linebender/fearless_simd/pull/123
120+
[#125]: https://github.com/linebender/fearless_simd/pull/125
119121

120122
[Unreleased]: https://github.com/linebender/fearless_simd/compare/v0.3.0...HEAD
121123
[0.3.0]: https://github.com/linebender/fearless_simd/compare/v0.3.0...v0.2.0

fearless_simd/src/generated/avx2.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ impl Avx2 {
3636
impl Seal for Avx2 {}
3737
impl Simd for Avx2 {
3838
type f32s = f32x8<Self>;
39+
type f64s = f64x4<Self>;
3940
type u8s = u8x32<Self>;
4041
type i8s = i8x32<Self>;
4142
type u16s = u16x16<Self>;
@@ -45,6 +46,7 @@ impl Simd for Avx2 {
4546
type mask8s = mask8x32<Self>;
4647
type mask16s = mask16x16<Self>;
4748
type mask32s = mask32x8<Self>;
49+
type mask64s = mask64x4<Self>;
4850
#[inline(always)]
4951
fn level(self) -> Level {
5052
Level::Avx2(self)

fearless_simd/src/generated/fallback.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ impl Fallback {
7272
impl Seal for Fallback {}
7373
impl Simd for Fallback {
7474
type f32s = f32x4<Self>;
75+
type f64s = f64x2<Self>;
7576
type u8s = u8x16<Self>;
7677
type i8s = i8x16<Self>;
7778
type u16s = u16x8<Self>;
@@ -81,6 +82,7 @@ impl Simd for Fallback {
8182
type mask8s = mask8x16<Self>;
8283
type mask16s = mask16x8<Self>;
8384
type mask32s = mask32x4<Self>;
85+
type mask64s = mask64x2<Self>;
8486
#[inline(always)]
8587
fn level(self) -> Level {
8688
#[cfg(feature = "force_support_fallback")]

fearless_simd/src/generated/neon.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ impl Neon {
2727
impl Seal for Neon {}
2828
impl Simd for Neon {
2929
type f32s = f32x4<Self>;
30+
type f64s = f64x2<Self>;
3031
type u8s = u8x16<Self>;
3132
type i8s = i8x16<Self>;
3233
type u16s = u16x8<Self>;
@@ -36,6 +37,7 @@ impl Simd for Neon {
3637
type mask8s = mask8x16<Self>;
3738
type mask16s = mask16x8<Self>;
3839
type mask32s = mask32x4<Self>;
40+
type mask64s = mask64x2<Self>;
3941
#[inline(always)]
4042
fn level(self) -> Level {
4143
Level::Neon(self)

fearless_simd/src/generated/simd_trait.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub trait Simd: Sized + Clone + Copy + Send + Sync + Seal + 'static {
2323
Bytes = <Self::u32s as Bytes>::Bytes,
2424
> + SimdCvtFloat<Self::u32s>
2525
+ SimdCvtFloat<Self::i32s>;
26+
type f64s: SimdFloat<f64, Self, Block = f64x2<Self>, Mask = Self::mask64s>;
2627
type u8s: SimdInt<u8, Self, Block = u8x16<Self>, Mask = Self::mask8s>;
2728
type i8s: SimdInt<
2829
i8,
@@ -62,6 +63,9 @@ pub trait Simd: Sized + Clone + Copy + Send + Sync + Seal + 'static {
6263
+ Select<Self::u32s>
6364
+ Select<Self::i32s>
6465
+ Select<Self::mask32s>;
66+
type mask64s: SimdMask<i64, Self, Block = mask64x2<Self>>
67+
+ Select<Self::f64s>
68+
+ Select<Self::mask64s>;
6569
fn level(self) -> Level;
6670
#[doc = r" Call function with CPU features enabled."]
6771
#[doc = r""]

fearless_simd/src/generated/sse4_2.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ impl Sse4_2 {
3636
impl Seal for Sse4_2 {}
3737
impl Simd for Sse4_2 {
3838
type f32s = f32x4<Self>;
39+
type f64s = f64x2<Self>;
3940
type u8s = u8x16<Self>;
4041
type i8s = i8x16<Self>;
4142
type u16s = u16x8<Self>;
@@ -45,6 +46,7 @@ impl Simd for Sse4_2 {
4546
type mask8s = mask8x16<Self>;
4647
type mask16s = mask16x8<Self>;
4748
type mask32s = mask32x4<Self>;
49+
type mask64s = mask64x2<Self>;
4850
#[inline(always)]
4951
fn level(self) -> Level {
5052
#[cfg(not(all(target_feature = "avx2", target_feature = "fma")))]

fearless_simd/src/generated/wasm.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ impl WasmSimd128 {
2525
impl Seal for WasmSimd128 {}
2626
impl Simd for WasmSimd128 {
2727
type f32s = f32x4<Self>;
28+
type f64s = f64x2<Self>;
2829
type u8s = u8x16<Self>;
2930
type i8s = i8x16<Self>;
3031
type u16s = u16x8<Self>;
@@ -34,6 +35,7 @@ impl Simd for WasmSimd128 {
3435
type mask8s = mask8x16<Self>;
3536
type mask16s = mask16x8<Self>;
3637
type mask32s = mask32x4<Self>;
38+
type mask64s = mask64x2<Self>;
3739
#[inline(always)]
3840
fn level(self) -> Level {
3941
Level::WasmSimd128(self)

fearless_simd_gen/src/mk_avx2.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ fn mk_simd_impl() -> TokenStream {
9797
quote! {
9898
impl Simd for #level_tok {
9999
type f32s = f32x8<Self>;
100+
type f64s = f64x4<Self>;
100101
type u8s = u8x32<Self>;
101102
type i8s = i8x32<Self>;
102103
type u16s = u16x16<Self>;
@@ -106,6 +107,7 @@ fn mk_simd_impl() -> TokenStream {
106107
type mask8s = mask8x32<Self>;
107108
type mask16s = mask16x16<Self>;
108109
type mask32s = mask32x8<Self>;
110+
type mask64s = mask64x4<Self>;
109111
#[inline(always)]
110112
fn level(self) -> Level {
111113
Level::#level_tok(self)

fearless_simd_gen/src/mk_fallback.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ fn mk_simd_impl() -> TokenStream {
385385
quote! {
386386
impl Simd for #level_tok {
387387
type f32s = f32x4<Self>;
388+
type f64s = f64x2<Self>;
388389
type u8s = u8x16<Self>;
389390
type i8s = i8x16<Self>;
390391
type u16s = u16x8<Self>;
@@ -394,6 +395,7 @@ fn mk_simd_impl() -> TokenStream {
394395
type mask8s = mask8x16<Self>;
395396
type mask16s = mask16x8<Self>;
396397
type mask32s = mask32x4<Self>;
398+
type mask64s = mask64x2<Self>;
397399
#[inline(always)]
398400
fn level(self) -> Level {
399401
#[cfg(feature = "force_support_fallback")]

fearless_simd_gen/src/mk_neon.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ fn mk_simd_impl(level: Level) -> TokenStream {
401401
quote! {
402402
impl Simd for #level_tok {
403403
type f32s = f32x4<Self>;
404+
type f64s = f64x2<Self>;
404405
type u8s = u8x16<Self>;
405406
type i8s = i8x16<Self>;
406407
type u16s = u16x8<Self>;
@@ -410,6 +411,7 @@ fn mk_simd_impl(level: Level) -> TokenStream {
410411
type mask8s = mask8x16<Self>;
411412
type mask16s = mask16x8<Self>;
412413
type mask32s = mask32x4<Self>;
414+
type mask64s = mask64x2<Self>;
413415
#[inline(always)]
414416
fn level(self) -> Level {
415417
Level::#level_tok(self)

0 commit comments

Comments
 (0)