Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 38 additions & 12 deletions fearless_simd/src/generated/avx2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ impl Simd for Avx2 {
unsafe { _mm256_setr_m128(a.into(), b.into()).simd_into(self) }
}
#[inline(always)]
fn widen_f32x4(self, a: f32x4<Self>) -> f64x4<Self> {
unsafe { _mm256_cvtps_pd(a.into()).simd_into(self) }
}
#[inline(always)]
fn reinterpret_f64_f32x4(self, a: f32x4<Self>) -> f64x2<Self> {
f64x2 {
val: bytemuck::cast(a.val),
Expand Down Expand Up @@ -1449,6 +1453,15 @@ impl Simd for Avx2 {
}
}
#[inline(always)]
fn widen_f32x8(self, a: f32x8<Self>) -> f64x8<Self> {
unsafe {
let (a0, a1) = self.split_f32x8(a);
let high = _mm256_cvtps_pd(a0.into()).simd_into(self);
let low = _mm256_cvtps_pd(a1.into()).simd_into(self);
self.combine_f64x4(high, low)
}
}
#[inline(always)]
fn reinterpret_f64_f32x8(self, a: f32x8<Self>) -> f64x4<Self> {
f64x4 {
val: bytemuck::cast(a.val),
Expand Down Expand Up @@ -2818,6 +2831,10 @@ impl Simd for Avx2 {
}
}
#[inline(always)]
fn narrow_f64x4(self, a: f64x4<Self>) -> f32x4<Self> {
unsafe { _mm256_cvtpd_ps(a.into()).simd_into(self) }
}
#[inline(always)]
fn reinterpret_f32_f64x4(self, a: f64x4<Self>) -> f32x8<Self> {
f32x8 {
val: bytemuck::cast(a.val),
Expand Down Expand Up @@ -3052,6 +3069,18 @@ impl Simd for Avx2 {
(b0.simd_into(self), b1.simd_into(self))
}
#[inline(always)]
fn load_interleaved_128_f32x16(self, src: &[f32; 16usize]) -> f32x16<Self> {
crate::Fallback::new()
.load_interleaved_128_f32x16(src)
.val
.simd_into(self)
}
#[inline(always)]
fn store_interleaved_128_f32x16(self, a: f32x16<Self>, dest: &mut [f32; 16usize]) -> () {
let fb = crate::Fallback::new();
fb.store_interleaved_128_f32x16(a.val.simd_into(fb), dest);
}
#[inline(always)]
fn reinterpret_f64_f32x16(self, a: f32x16<Self>) -> f64x8<Self> {
let (a0, a1) = self.split_f32x16(a);
self.combine_f64x4(
Expand All @@ -3068,18 +3097,6 @@ impl Simd for Avx2 {
)
}
#[inline(always)]
fn load_interleaved_128_f32x16(self, src: &[f32; 16usize]) -> f32x16<Self> {
crate::Fallback::new()
.load_interleaved_128_f32x16(src)
.val
.simd_into(self)
}
#[inline(always)]
fn store_interleaved_128_f32x16(self, a: f32x16<Self>, dest: &mut [f32; 16usize]) -> () {
let fb = crate::Fallback::new();
fb.store_interleaved_128_f32x16(a.val.simd_into(fb), dest);
}
#[inline(always)]
fn reinterpret_u8_f32x16(self, a: f32x16<Self>) -> u8x64<Self> {
let (a0, a1) = self.split_f32x16(a);
self.combine_u8x32(self.reinterpret_u8_f32x8(a0), self.reinterpret_u8_f32x8(a1))
Expand Down Expand Up @@ -4484,6 +4501,15 @@ impl Simd for Avx2 {
(b0.simd_into(self), b1.simd_into(self))
}
#[inline(always)]
fn narrow_f64x8(self, a: f64x8<Self>) -> f32x8<Self> {
let (a, b) = self.split_f64x8(a);
unsafe {
let lo = _mm256_cvtpd_ps(a.into());
let hi = _mm256_cvtpd_ps(b.into());
_mm256_setr_m128(lo, hi).simd_into(self)
}
}
#[inline(always)]
fn reinterpret_f32_f64x8(self, a: f64x8<Self>) -> f32x16<Self> {
let (a0, a1) = self.split_f64x8(a);
self.combine_f32x8(
Expand Down
62 changes: 46 additions & 16 deletions fearless_simd/src/generated/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,16 @@ impl Simd for Fallback {
result.simd_into(self)
}
#[inline(always)]
fn widen_f32x4(self, a: f32x4<Self>) -> f64x4<Self> {
[
a[0usize] as f64,
a[1usize] as f64,
a[2usize] as f64,
a[3usize] as f64,
]
.simd_into(self)
}
#[inline(always)]
fn reinterpret_f64_f32x4(self, a: f32x4<Self>) -> f64x2<Self> {
f64x2 {
val: bytemuck::cast(a.val),
Expand Down Expand Up @@ -3251,6 +3261,11 @@ impl Simd for Fallback {
(b0.simd_into(self), b1.simd_into(self))
}
#[inline(always)]
fn widen_f32x8(self, a: f32x8<Self>) -> f64x8<Self> {
let (a0, a1) = self.split_f32x8(a);
self.combine_f64x4(self.widen_f32x4(a0), self.widen_f32x4(a1))
}
#[inline(always)]
fn reinterpret_f64_f32x8(self, a: f32x8<Self>) -> f64x4<Self> {
let (a0, a1) = self.split_f32x8(a);
self.combine_f64x2(
Expand Down Expand Up @@ -4684,6 +4699,16 @@ impl Simd for Fallback {
(b0.simd_into(self), b1.simd_into(self))
}
#[inline(always)]
fn narrow_f64x4(self, a: f64x4<Self>) -> f32x4<Self> {
[
a[0usize] as f32,
a[1usize] as f32,
a[2usize] as f32,
a[3usize] as f32,
]
.simd_into(self)
}
#[inline(always)]
fn reinterpret_f32_f64x4(self, a: f64x4<Self>) -> f32x8<Self> {
let (a0, a1) = self.split_f64x4(a);
self.combine_f32x4(
Expand Down Expand Up @@ -4934,22 +4959,6 @@ impl Simd for Fallback {
(b0.simd_into(self), b1.simd_into(self))
}
#[inline(always)]
fn reinterpret_f64_f32x16(self, a: f32x16<Self>) -> f64x8<Self> {
let (a0, a1) = self.split_f32x16(a);
self.combine_f64x4(
self.reinterpret_f64_f32x8(a0),
self.reinterpret_f64_f32x8(a1),
)
}
#[inline(always)]
fn reinterpret_i32_f32x16(self, a: f32x16<Self>) -> i32x16<Self> {
let (a0, a1) = self.split_f32x16(a);
self.combine_i32x8(
self.reinterpret_i32_f32x8(a0),
self.reinterpret_i32_f32x8(a1),
)
}
#[inline(always)]
fn load_interleaved_128_f32x16(self, src: &[f32; 16usize]) -> f32x16<Self> {
[
src[0usize],
Expand Down Expand Up @@ -4980,6 +4989,22 @@ impl Simd for Fallback {
];
}
#[inline(always)]
fn reinterpret_f64_f32x16(self, a: f32x16<Self>) -> f64x8<Self> {
let (a0, a1) = self.split_f32x16(a);
self.combine_f64x4(
self.reinterpret_f64_f32x8(a0),
self.reinterpret_f64_f32x8(a1),
)
}
#[inline(always)]
fn reinterpret_i32_f32x16(self, a: f32x16<Self>) -> i32x16<Self> {
let (a0, a1) = self.split_f32x16(a);
self.combine_i32x8(
self.reinterpret_i32_f32x8(a0),
self.reinterpret_i32_f32x8(a1),
)
}
#[inline(always)]
fn reinterpret_u8_f32x16(self, a: f32x16<Self>) -> u8x64<Self> {
let (a0, a1) = self.split_f32x16(a);
self.combine_u8x32(self.reinterpret_u8_f32x8(a0), self.reinterpret_u8_f32x8(a1))
Expand Down Expand Up @@ -6489,6 +6514,11 @@ impl Simd for Fallback {
(b0.simd_into(self), b1.simd_into(self))
}
#[inline(always)]
fn narrow_f64x8(self, a: f64x8<Self>) -> f32x8<Self> {
let (a0, a1) = self.split_f64x8(a);
self.combine_f32x4(self.narrow_f64x4(a0), self.narrow_f64x4(a1))
}
#[inline(always)]
fn reinterpret_f32_f64x8(self, a: f64x8<Self>) -> f32x16<Self> {
let (a0, a1) = self.split_f64x8(a);
self.combine_f32x8(
Expand Down
41 changes: 33 additions & 8 deletions fearless_simd/src/generated/neon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ impl Simd for Neon {
result.simd_into(self)
}
#[inline(always)]
fn widen_f32x4(self, a: f32x4<Self>) -> f64x4<Self> {
unsafe {
let low = vcvt_f64_f32(vget_low_f32(a.into()));
let high = vcvt_high_f64_f32(a.into());
float64x2x2_t(low, high).simd_into(self)
}
}
#[inline(always)]
fn reinterpret_f64_f32x4(self, a: f32x4<Self>) -> f64x2<Self> {
unsafe { vreinterpretq_f64_f32(a.into()).simd_into(self) }
}
Expand Down Expand Up @@ -1401,6 +1409,11 @@ impl Simd for Neon {
(b0.simd_into(self), b1.simd_into(self))
}
#[inline(always)]
fn widen_f32x8(self, a: f32x8<Self>) -> f64x8<Self> {
let (a0, a1) = self.split_f32x8(a);
self.combine_f64x4(self.widen_f32x4(a0), self.widen_f32x4(a1))
}
#[inline(always)]
fn reinterpret_f64_f32x8(self, a: f32x8<Self>) -> f64x4<Self> {
let (a0, a1) = self.split_f32x8(a);
self.combine_f64x2(
Expand Down Expand Up @@ -2821,6 +2834,13 @@ impl Simd for Neon {
(b0.simd_into(self), b1.simd_into(self))
}
#[inline(always)]
fn narrow_f64x4(self, a: f64x4<Self>) -> f32x4<Self> {
unsafe {
let converted: float64x2x2_t = a.into();
vcvt_high_f32_f64(vcvt_f32_f64(converted.0), converted.1).simd_into(self)
}
}
#[inline(always)]
fn reinterpret_f32_f64x4(self, a: f64x4<Self>) -> f32x8<Self> {
let (a0, a1) = self.split_f64x4(a);
self.combine_f32x4(
Expand Down Expand Up @@ -3071,6 +3091,14 @@ impl Simd for Neon {
(b0.simd_into(self), b1.simd_into(self))
}
#[inline(always)]
fn load_interleaved_128_f32x16(self, src: &[f32; 16usize]) -> f32x16<Self> {
unsafe { vld4q_f32(src.as_ptr()).simd_into(self) }
}
#[inline(always)]
fn store_interleaved_128_f32x16(self, a: f32x16<Self>, dest: &mut [f32; 16usize]) -> () {
unsafe { vst4q_f32(dest.as_mut_ptr(), a.into()) }
}
#[inline(always)]
fn reinterpret_f64_f32x16(self, a: f32x16<Self>) -> f64x8<Self> {
let (a0, a1) = self.split_f32x16(a);
self.combine_f64x4(
Expand All @@ -3087,14 +3115,6 @@ impl Simd for Neon {
)
}
#[inline(always)]
fn load_interleaved_128_f32x16(self, src: &[f32; 16usize]) -> f32x16<Self> {
unsafe { vld4q_f32(src.as_ptr()).simd_into(self) }
}
#[inline(always)]
fn store_interleaved_128_f32x16(self, a: f32x16<Self>, dest: &mut [f32; 16usize]) -> () {
unsafe { vst4q_f32(dest.as_mut_ptr(), a.into()) }
}
#[inline(always)]
fn reinterpret_u8_f32x16(self, a: f32x16<Self>) -> u8x64<Self> {
let (a0, a1) = self.split_f32x16(a);
self.combine_u8x32(self.reinterpret_u8_f32x8(a0), self.reinterpret_u8_f32x8(a1))
Expand Down Expand Up @@ -4465,6 +4485,11 @@ impl Simd for Neon {
(b0.simd_into(self), b1.simd_into(self))
}
#[inline(always)]
fn narrow_f64x8(self, a: f64x8<Self>) -> f32x8<Self> {
let (a0, a1) = self.split_f64x8(a);
self.combine_f32x4(self.narrow_f64x4(a0), self.narrow_f64x4(a1))
}
#[inline(always)]
fn reinterpret_f32_f64x8(self, a: f64x8<Self>) -> f32x16<Self> {
let (a0, a1) = self.split_f64x8(a);
self.combine_f32x8(
Expand Down
8 changes: 6 additions & 2 deletions fearless_simd/src/generated/simd_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ pub trait Simd: Sized + Clone + Copy + Send + Sync + Seal + 'static {
fn trunc_f32x4(self, a: f32x4<Self>) -> f32x4<Self>;
fn select_f32x4(self, a: mask32x4<Self>, b: f32x4<Self>, c: f32x4<Self>) -> f32x4<Self>;
fn combine_f32x4(self, a: f32x4<Self>, b: f32x4<Self>) -> f32x8<Self>;
fn widen_f32x4(self, a: f32x4<Self>) -> f64x4<Self>;
fn reinterpret_f64_f32x4(self, a: f32x4<Self>) -> f64x2<Self>;
fn reinterpret_i32_f32x4(self, a: f32x4<Self>) -> i32x4<Self>;
fn reinterpret_u8_f32x4(self, a: f32x4<Self>) -> u8x16<Self>;
Expand Down Expand Up @@ -374,6 +375,7 @@ pub trait Simd: Sized + Clone + Copy + Send + Sync + Seal + 'static {
fn select_f32x8(self, a: mask32x8<Self>, b: f32x8<Self>, c: f32x8<Self>) -> f32x8<Self>;
fn combine_f32x8(self, a: f32x8<Self>, b: f32x8<Self>) -> f32x16<Self>;
fn split_f32x8(self, a: f32x8<Self>) -> (f32x4<Self>, f32x4<Self>);
fn widen_f32x8(self, a: f32x8<Self>) -> f64x8<Self>;
fn reinterpret_f64_f32x8(self, a: f32x8<Self>) -> f64x4<Self>;
fn reinterpret_i32_f32x8(self, a: f32x8<Self>) -> i32x8<Self>;
fn reinterpret_u8_f32x8(self, a: f32x8<Self>) -> u8x32<Self>;
Expand Down Expand Up @@ -619,6 +621,7 @@ pub trait Simd: Sized + Clone + Copy + Send + Sync + Seal + 'static {
fn select_f64x4(self, a: mask64x4<Self>, b: f64x4<Self>, c: f64x4<Self>) -> f64x4<Self>;
fn combine_f64x4(self, a: f64x4<Self>, b: f64x4<Self>) -> f64x8<Self>;
fn split_f64x4(self, a: f64x4<Self>) -> (f64x2<Self>, f64x2<Self>);
fn narrow_f64x4(self, a: f64x4<Self>) -> f32x4<Self>;
fn reinterpret_f32_f64x4(self, a: f64x4<Self>) -> f32x8<Self>;
fn splat_mask64x4(self, val: i64) -> mask64x4<Self>;
fn not_mask64x4(self, a: mask64x4<Self>) -> mask64x4<Self>;
Expand Down Expand Up @@ -663,10 +666,10 @@ pub trait Simd: Sized + Clone + Copy + Send + Sync + Seal + 'static {
fn trunc_f32x16(self, a: f32x16<Self>) -> f32x16<Self>;
fn select_f32x16(self, a: mask32x16<Self>, b: f32x16<Self>, c: f32x16<Self>) -> f32x16<Self>;
fn split_f32x16(self, a: f32x16<Self>) -> (f32x8<Self>, f32x8<Self>);
fn reinterpret_f64_f32x16(self, a: f32x16<Self>) -> f64x8<Self>;
fn reinterpret_i32_f32x16(self, a: f32x16<Self>) -> i32x16<Self>;
fn load_interleaved_128_f32x16(self, src: &[f32; 16usize]) -> f32x16<Self>;
fn store_interleaved_128_f32x16(self, a: f32x16<Self>, dest: &mut [f32; 16usize]) -> ();
fn reinterpret_f64_f32x16(self, a: f32x16<Self>) -> f64x8<Self>;
fn reinterpret_i32_f32x16(self, a: f32x16<Self>) -> i32x16<Self>;
fn reinterpret_u8_f32x16(self, a: f32x16<Self>) -> u8x64<Self>;
fn reinterpret_u32_f32x16(self, a: f32x16<Self>) -> u32x16<Self>;
fn cvt_u32_f32x16(self, a: f32x16<Self>) -> u32x16<Self>;
Expand Down Expand Up @@ -905,6 +908,7 @@ pub trait Simd: Sized + Clone + Copy + Send + Sync + Seal + 'static {
fn trunc_f64x8(self, a: f64x8<Self>) -> f64x8<Self>;
fn select_f64x8(self, a: mask64x8<Self>, b: f64x8<Self>, c: f64x8<Self>) -> f64x8<Self>;
fn split_f64x8(self, a: f64x8<Self>) -> (f64x4<Self>, f64x4<Self>);
fn narrow_f64x8(self, a: f64x8<Self>) -> f32x8<Self>;
fn reinterpret_f32_f64x8(self, a: f64x8<Self>) -> f32x16<Self>;
fn splat_mask64x8(self, val: i64) -> mask64x8<Self>;
fn not_mask64x8(self, a: mask64x8<Self>) -> mask64x8<Self>;
Expand Down
Loading