Skip to content
Merged
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
119 changes: 119 additions & 0 deletions fearless_simd/src/generated/avx2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,18 @@ impl Simd for Avx2 {
kernel(self, a)
}
#[inline(always)]
fn reduce_product_f32x4(self, a: f32x4<Self>) -> f32 {
crate::kernel!(
#[inline(always)]
fn kernel(token: Avx2, a: f32x4<Avx2>) -> f32 {
let a: __m128 = a.into();
let adjacent = _mm_mul_ps(a, _mm_shuffle_ps::<0b10_11_00_01>(a, a));
_mm_cvtss_f32(_mm_mul_ss(adjacent, _mm_movehl_ps(adjacent, adjacent)))
}
);
kernel(self, a)
}
#[inline(always)]
fn max_f32x4(self, a: f32x4<Self>, b: f32x4<Self>) -> f32x4<Self> {
crate::kernel!(
#[inline(always)]
Expand Down Expand Up @@ -1006,6 +1018,25 @@ impl Simd for Avx2 {
kernel(self, a)
}
#[inline(always)]
fn reduce_product_i8x16(self, a: i8x16<Self>) -> i8 {
crate::kernel!(
#[inline(always)]
fn kernel(token: Avx2, a: i8x16<Avx2>) -> i8 {
let value: __m128i = a.into();
let product = _mm_mullo_epi16(
_mm_unpacklo_epi8(value, value),
_mm_unpackhi_epi8(value, value),
);
let product = _mm_mullo_epi16(product, _mm_shuffle_epi32::<0b11_10_11_10>(product));
let product = _mm_mullo_epi16(product, _mm_shuffle_epi32::<0b01_01_01_01>(product));
let product = _mm_mullo_epi16(product, _mm_srli_epi32::<16>(product));
let lanes: [i8; 16usize] = crate::transmute::checked_transmute_copy(&product);
lanes[0]
}
);
kernel(self, a)
}
#[inline(always)]
fn max_i8x16(self, a: i8x16<Self>, b: i8x16<Self>) -> i8x16<Self> {
crate::kernel!(
#[inline(always)]
Expand Down Expand Up @@ -1588,6 +1619,25 @@ impl Simd for Avx2 {
kernel(self, a)
}
#[inline(always)]
fn reduce_product_u8x16(self, a: u8x16<Self>) -> u8 {
crate::kernel!(
#[inline(always)]
fn kernel(token: Avx2, a: u8x16<Avx2>) -> u8 {
let value: __m128i = a.into();
let product = _mm_mullo_epi16(
_mm_unpacklo_epi8(value, value),
_mm_unpackhi_epi8(value, value),
);
let product = _mm_mullo_epi16(product, _mm_shuffle_epi32::<0b11_10_11_10>(product));
let product = _mm_mullo_epi16(product, _mm_shuffle_epi32::<0b01_01_01_01>(product));
let product = _mm_mullo_epi16(product, _mm_srli_epi32::<16>(product));
let lanes: [u8; 16usize] = crate::transmute::checked_transmute_copy(&product);
lanes[0]
}
);
kernel(self, a)
}
#[inline(always)]
fn max_u8x16(self, a: u8x16<Self>, b: u8x16<Self>) -> u8x16<Self> {
crate::kernel!(
#[inline(always)]
Expand Down Expand Up @@ -2288,6 +2338,21 @@ impl Simd for Avx2 {
kernel(self, a)
}
#[inline(always)]
fn reduce_product_i16x8(self, a: i16x8<Self>) -> i16 {
crate::kernel!(
#[inline(always)]
fn kernel(token: Avx2, a: i16x8<Avx2>) -> i16 {
let product: __m128i = a.into();
let product = _mm_mullo_epi16(product, _mm_shuffle_epi32::<0b11_10_11_10>(product));
let product = _mm_mullo_epi16(product, _mm_shuffle_epi32::<0b01_01_01_01>(product));
let product = _mm_mullo_epi16(product, _mm_srli_epi32::<16>(product));
let lanes: [i16; 8usize] = crate::transmute::checked_transmute_copy(&product);
lanes[0]
}
);
kernel(self, a)
}
#[inline(always)]
fn max_i16x8(self, a: i16x8<Self>, b: i16x8<Self>) -> i16x8<Self> {
crate::kernel!(
#[inline(always)]
Expand Down Expand Up @@ -2821,6 +2886,21 @@ impl Simd for Avx2 {
kernel(self, a)
}
#[inline(always)]
fn reduce_product_u16x8(self, a: u16x8<Self>) -> u16 {
crate::kernel!(
#[inline(always)]
fn kernel(token: Avx2, a: u16x8<Avx2>) -> u16 {
let product: __m128i = a.into();
let product = _mm_mullo_epi16(product, _mm_shuffle_epi32::<0b11_10_11_10>(product));
let product = _mm_mullo_epi16(product, _mm_shuffle_epi32::<0b01_01_01_01>(product));
let product = _mm_mullo_epi16(product, _mm_srli_epi32::<16>(product));
let lanes: [u16; 8usize] = crate::transmute::checked_transmute_copy(&product);
lanes[0]
}
);
kernel(self, a)
}
#[inline(always)]
fn max_u16x8(self, a: u16x8<Self>, b: u16x8<Self>) -> u16x8<Self> {
crate::kernel!(
#[inline(always)]
Expand Down Expand Up @@ -3572,6 +3652,15 @@ impl Simd for Avx2 {
kernel(self, a)
}
#[inline(always)]
fn reduce_product_i32x4(self, a: i32x4<Self>) -> i32 {
let mul_level_0: [i32; 2usize] = [
a[0usize].wrapping_mul(a[1usize]),
a[2usize].wrapping_mul(a[3usize]),
];
let mul_level_1: [i32; 1usize] = [mul_level_0[0usize].wrapping_mul(mul_level_0[1usize])];
mul_level_1[0]
}
#[inline(always)]
fn max_i32x4(self, a: i32x4<Self>, b: i32x4<Self>) -> i32x4<Self> {
crate::kernel!(
#[inline(always)]
Expand Down Expand Up @@ -4087,6 +4176,15 @@ impl Simd for Avx2 {
kernel(self, a)
}
#[inline(always)]
fn reduce_product_u32x4(self, a: u32x4<Self>) -> u32 {
let mul_level_0: [u32; 2usize] = [
a[0usize].wrapping_mul(a[1usize]),
a[2usize].wrapping_mul(a[3usize]),
];
let mul_level_1: [u32; 1usize] = [mul_level_0[0usize].wrapping_mul(mul_level_0[1usize])];
mul_level_1[0]
}
#[inline(always)]
fn max_u32x4(self, a: u32x4<Self>, b: u32x4<Self>) -> u32x4<Self> {
crate::kernel!(
#[inline(always)]
Expand Down Expand Up @@ -4763,6 +4861,17 @@ impl Simd for Avx2 {
kernel(self, a)
}
#[inline(always)]
fn reduce_product_f64x2(self, a: f64x2<Self>) -> f64 {
crate::kernel!(
#[inline(always)]
fn kernel(token: Avx2, a: f64x2<Avx2>) -> f64 {
let a: __m128d = a.into();
_mm_cvtsd_f64(_mm_mul_sd(a, _mm_unpackhi_pd(a, a)))
}
);
kernel(self, a)
}
#[inline(always)]
fn max_f64x2(self, a: f64x2<Self>, b: f64x2<Self>) -> f64x2<Self> {
crate::kernel!(
#[inline(always)]
Expand Down Expand Up @@ -5406,6 +5515,11 @@ impl Simd for Avx2 {
kernel(self, a)
}
#[inline(always)]
fn reduce_product_i64x2(self, a: i64x2<Self>) -> i64 {
let mul_level_0: [i64; 1usize] = [a[0usize].wrapping_mul(a[1usize])];
mul_level_0[0]
}
#[inline(always)]
fn max_i64x2(self, a: i64x2<Self>, b: i64x2<Self>) -> i64x2<Self> {
[
i64::max(a[0usize], b[0usize]),
Expand Down Expand Up @@ -5889,6 +6003,11 @@ impl Simd for Avx2 {
kernel(self, a)
}
#[inline(always)]
fn reduce_product_u64x2(self, a: u64x2<Self>) -> u64 {
let mul_level_0: [u64; 1usize] = [a[0usize].wrapping_mul(a[1usize])];
mul_level_0[0]
}
#[inline(always)]
fn max_u64x2(self, a: u64x2<Self>, b: u64x2<Self>) -> u64x2<Self> {
[
u64::max(a[0usize], b[0usize]),
Expand Down
119 changes: 119 additions & 0 deletions fearless_simd/src/generated/avx512.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,18 @@ impl Simd for Avx512 {
kernel(self, a)
}
#[inline(always)]
fn reduce_product_f32x4(self, a: f32x4<Self>) -> f32 {
crate::kernel!(
#[inline(always)]
fn kernel(token: Avx512, a: f32x4<Avx512>) -> f32 {
let a: __m128 = a.into();
let adjacent = _mm_mul_ps(a, _mm_shuffle_ps::<0b10_11_00_01>(a, a));
_mm_cvtss_f32(_mm_mul_ss(adjacent, _mm_movehl_ps(adjacent, adjacent)))
}
);
kernel(self, a)
}
#[inline(always)]
fn max_f32x4(self, a: f32x4<Self>, b: f32x4<Self>) -> f32x4<Self> {
crate::kernel!(
#[inline(always)]
Expand Down Expand Up @@ -1208,6 +1220,25 @@ impl Simd for Avx512 {
kernel(self, a)
}
#[inline(always)]
fn reduce_product_i8x16(self, a: i8x16<Self>) -> i8 {
crate::kernel!(
#[inline(always)]
fn kernel(token: Avx512, a: i8x16<Avx512>) -> i8 {
let value: __m128i = a.into();
let product = _mm_mullo_epi16(
_mm_unpacklo_epi8(value, value),
_mm_unpackhi_epi8(value, value),
);
let product = _mm_mullo_epi16(product, _mm_shuffle_epi32::<0b11_10_11_10>(product));
let product = _mm_mullo_epi16(product, _mm_shuffle_epi32::<0b01_01_01_01>(product));
let product = _mm_mullo_epi16(product, _mm_srli_epi32::<16>(product));
let lanes: [i8; 16usize] = crate::transmute::checked_transmute_copy(&product);
lanes[0]
}
);
kernel(self, a)
}
#[inline(always)]
fn max_i8x16(self, a: i8x16<Self>, b: i8x16<Self>) -> i8x16<Self> {
crate::kernel!(
#[inline(always)]
Expand Down Expand Up @@ -1776,6 +1807,25 @@ impl Simd for Avx512 {
kernel(self, a)
}
#[inline(always)]
fn reduce_product_u8x16(self, a: u8x16<Self>) -> u8 {
crate::kernel!(
#[inline(always)]
fn kernel(token: Avx512, a: u8x16<Avx512>) -> u8 {
let value: __m128i = a.into();
let product = _mm_mullo_epi16(
_mm_unpacklo_epi8(value, value),
_mm_unpackhi_epi8(value, value),
);
let product = _mm_mullo_epi16(product, _mm_shuffle_epi32::<0b11_10_11_10>(product));
let product = _mm_mullo_epi16(product, _mm_shuffle_epi32::<0b01_01_01_01>(product));
let product = _mm_mullo_epi16(product, _mm_srli_epi32::<16>(product));
let lanes: [u8; 16usize] = crate::transmute::checked_transmute_copy(&product);
lanes[0]
}
);
kernel(self, a)
}
#[inline(always)]
fn max_u8x16(self, a: u8x16<Self>, b: u8x16<Self>) -> u8x16<Self> {
crate::kernel!(
#[inline(always)]
Expand Down Expand Up @@ -2381,6 +2431,21 @@ impl Simd for Avx512 {
kernel(self, a)
}
#[inline(always)]
fn reduce_product_i16x8(self, a: i16x8<Self>) -> i16 {
crate::kernel!(
#[inline(always)]
fn kernel(token: Avx512, a: i16x8<Avx512>) -> i16 {
let product: __m128i = a.into();
let product = _mm_mullo_epi16(product, _mm_shuffle_epi32::<0b11_10_11_10>(product));
let product = _mm_mullo_epi16(product, _mm_shuffle_epi32::<0b01_01_01_01>(product));
let product = _mm_mullo_epi16(product, _mm_srli_epi32::<16>(product));
let lanes: [i16; 8usize] = crate::transmute::checked_transmute_copy(&product);
lanes[0]
}
);
kernel(self, a)
}
#[inline(always)]
fn max_i16x8(self, a: i16x8<Self>, b: i16x8<Self>) -> i16x8<Self> {
crate::kernel!(
#[inline(always)]
Expand Down Expand Up @@ -2882,6 +2947,21 @@ impl Simd for Avx512 {
kernel(self, a)
}
#[inline(always)]
fn reduce_product_u16x8(self, a: u16x8<Self>) -> u16 {
crate::kernel!(
#[inline(always)]
fn kernel(token: Avx512, a: u16x8<Avx512>) -> u16 {
let product: __m128i = a.into();
let product = _mm_mullo_epi16(product, _mm_shuffle_epi32::<0b11_10_11_10>(product));
let product = _mm_mullo_epi16(product, _mm_shuffle_epi32::<0b01_01_01_01>(product));
let product = _mm_mullo_epi16(product, _mm_srli_epi32::<16>(product));
let lanes: [u16; 8usize] = crate::transmute::checked_transmute_copy(&product);
lanes[0]
}
);
kernel(self, a)
}
#[inline(always)]
fn max_u16x8(self, a: u16x8<Self>, b: u16x8<Self>) -> u16x8<Self> {
crate::kernel!(
#[inline(always)]
Expand Down Expand Up @@ -3517,6 +3597,15 @@ impl Simd for Avx512 {
kernel(self, a)
}
#[inline(always)]
fn reduce_product_i32x4(self, a: i32x4<Self>) -> i32 {
let mul_level_0: [i32; 2usize] = [
a[0usize].wrapping_mul(a[1usize]),
a[2usize].wrapping_mul(a[3usize]),
];
let mul_level_1: [i32; 1usize] = [mul_level_0[0usize].wrapping_mul(mul_level_0[1usize])];
mul_level_1[0]
}
#[inline(always)]
fn max_i32x4(self, a: i32x4<Self>, b: i32x4<Self>) -> i32x4<Self> {
crate::kernel!(
#[inline(always)]
Expand Down Expand Up @@ -4012,6 +4101,15 @@ impl Simd for Avx512 {
kernel(self, a)
}
#[inline(always)]
fn reduce_product_u32x4(self, a: u32x4<Self>) -> u32 {
let mul_level_0: [u32; 2usize] = [
a[0usize].wrapping_mul(a[1usize]),
a[2usize].wrapping_mul(a[3usize]),
];
let mul_level_1: [u32; 1usize] = [mul_level_0[0usize].wrapping_mul(mul_level_0[1usize])];
mul_level_1[0]
}
#[inline(always)]
fn max_u32x4(self, a: u32x4<Self>, b: u32x4<Self>) -> u32x4<Self> {
crate::kernel!(
#[inline(always)]
Expand Down Expand Up @@ -4611,6 +4709,17 @@ impl Simd for Avx512 {
kernel(self, a)
}
#[inline(always)]
fn reduce_product_f64x2(self, a: f64x2<Self>) -> f64 {
crate::kernel!(
#[inline(always)]
fn kernel(token: Avx512, a: f64x2<Avx512>) -> f64 {
let a: __m128d = a.into();
_mm_cvtsd_f64(_mm_mul_sd(a, _mm_unpackhi_pd(a, a)))
}
);
kernel(self, a)
}
#[inline(always)]
fn max_f64x2(self, a: f64x2<Self>, b: f64x2<Self>) -> f64x2<Self> {
crate::kernel!(
#[inline(always)]
Expand Down Expand Up @@ -5179,6 +5288,11 @@ impl Simd for Avx512 {
kernel(self, a)
}
#[inline(always)]
fn reduce_product_i64x2(self, a: i64x2<Self>) -> i64 {
let mul_level_0: [i64; 1usize] = [a[0usize].wrapping_mul(a[1usize])];
mul_level_0[0]
}
#[inline(always)]
fn max_i64x2(self, a: i64x2<Self>, b: i64x2<Self>) -> i64x2<Self> {
crate::kernel!(
#[inline(always)]
Expand Down Expand Up @@ -5639,6 +5753,11 @@ impl Simd for Avx512 {
kernel(self, a)
}
#[inline(always)]
fn reduce_product_u64x2(self, a: u64x2<Self>) -> u64 {
let mul_level_0: [u64; 1usize] = [a[0usize].wrapping_mul(a[1usize])];
mul_level_0[0]
}
#[inline(always)]
fn max_u64x2(self, a: u64x2<Self>, b: u64x2<Self>) -> u64x2<Self> {
crate::kernel!(
#[inline(always)]
Expand Down
Loading
Loading