Skip to content

Commit

Permalink
Provide {Read,Bits}::{as_simd,as_simd_mut}.
Browse files Browse the repository at this point in the history
  • Loading branch information
n3vu0r committed Apr 30, 2024
1 parent d464dbf commit bc8cf12
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 92 deletions.
1 change: 1 addition & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Version 0.8.1 (2024-04-30)

* Fix misnamed `Bits::{slice_as_simd,slice_as_simd_mut}`.
* Provide instead of require `{Real,Bits}::{as_simd,as_simd_mut}`.

# Version 0.8.0 (2024-04-30)

Expand Down
20 changes: 14 additions & 6 deletions src/bits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ where
Self::Simd::splat(self)
}

/// Split a slice into a prefix, a middle of aligned SIMD types, and a suffix.
/// Split a slice into a prefix, a middle of aligned SIMD vectors, and a suffix.
///
/// You're only assured thatc`self.len() == prefix.len() + middle.len() * N + suffix.len()`.
///
Expand All @@ -106,13 +106,17 @@ where
///
/// # Panics
///
/// Panic if the size of the SIMD type is different from `N` times that of the scalar.
/// Panic if the size of the SIMD vector is different from `N` times that of the scalar.
#[must_use]
#[inline]
fn as_simd<const N: usize>(slice: &[Self]) -> (&[Self], &[Self::Simd<N>], &[Self])
where
LaneCount<N>: SupportedLaneCount;
LaneCount<N>: SupportedLaneCount,
{
Self::Simd::as_simd(slice)
}

/// Split a mutable slice into a mutable prefix, a middle of aligned SIMD types, and a mutable
/// Split a mutable slice into a mutable prefix, a middle of aligned SIMD vectors, and a mutable
/// suffix.
///
/// You're only assured that `self.len() == prefix.len() + middle.len() * N + suffix.len()`.
Expand All @@ -130,11 +134,15 @@ where
///
/// # Panics
///
/// Panic if the size of the SIMD type is different from `N` times that of the scalar.
/// Panic if the size of the SIMD vector is different from `N` times that of the scalar.
#[must_use]
#[inline]
fn as_simd_mut<const N: usize>(
slice: &mut [Self],
) -> (&mut [Self], &mut [Self::Simd<N>], &mut [Self])
where
LaneCount<N>: SupportedLaneCount;
LaneCount<N>: SupportedLaneCount,
{
Self::Simd::as_simd_mut(slice)
}
}
18 changes: 0 additions & 18 deletions src/bits/u32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,4 @@ impl Bits for u32 {
fn saturating_sub(self, other: Self) -> Self {
self.saturating_sub(other)
}

#[inline]
fn as_simd<const N: usize>(slice: &[Self]) -> (&[Self], &[Self::Simd<N>], &[Self])
where
LaneCount<N>: SupportedLaneCount,
{
slice.as_simd()
}

#[inline]
fn as_simd_mut<const N: usize>(
slice: &mut [Self],
) -> (&mut [Self], &mut [Self::Simd<N>], &mut [Self])
where
LaneCount<N>: SupportedLaneCount,
{
slice.as_simd_mut()
}
}
18 changes: 0 additions & 18 deletions src/bits/u64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,4 @@ impl Bits for u64 {
fn saturating_sub(self, other: Self) -> Self {
self.saturating_sub(other)
}

#[inline]
fn as_simd<const N: usize>(slice: &[Self]) -> (&[Self], &[Self::Simd<N>], &[Self])
where
LaneCount<N>: SupportedLaneCount,
{
slice.as_simd()
}

#[inline]
fn as_simd_mut<const N: usize>(
slice: &mut [Self],
) -> (&mut [Self], &mut [Self::Simd<N>], &mut [Self])
where
LaneCount<N>: SupportedLaneCount,
{
slice.as_simd_mut()
}
}
18 changes: 0 additions & 18 deletions src/real/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,22 +524,4 @@ impl Real for f32 {
fn total_cmp(&self, other: &Self) -> Ordering {
self.total_cmp(other)
}

#[inline]
fn as_simd<const N: usize>(slice: &[Self]) -> (&[Self], &[Self::Simd<N>], &[Self])
where
LaneCount<N>: SupportedLaneCount,
{
slice.as_simd()
}

#[inline]
fn as_simd_mut<const N: usize>(
slice: &mut [Self],
) -> (&mut [Self], &mut [Self::Simd<N>], &mut [Self])
where
LaneCount<N>: SupportedLaneCount,
{
slice.as_simd_mut()
}
}
18 changes: 0 additions & 18 deletions src/real/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,22 +524,4 @@ impl Real for f64 {
fn total_cmp(&self, other: &Self) -> Ordering {
self.total_cmp(other)
}

#[inline]
fn as_simd<const N: usize>(slice: &[Self]) -> (&[Self], &[Self::Simd<N>], &[Self])
where
LaneCount<N>: SupportedLaneCount,
{
slice.as_simd()
}

#[inline]
fn as_simd_mut<const N: usize>(
slice: &mut [Self],
) -> (&mut [Self], &mut [Self::Simd<N>], &mut [Self])
where
LaneCount<N>: SupportedLaneCount,
{
slice.as_simd_mut()
}
}
20 changes: 14 additions & 6 deletions src/real/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ where
Self::Simd::splat(self)
}

/// Split a slice into a prefix, a middle of aligned SIMD types, and a suffix.
/// Split a slice into a prefix, a middle of aligned SIMD vectors, and a suffix.
///
/// You're only assured thatc`self.len() == prefix.len() + middle.len() * N + suffix.len()`.
///
Expand All @@ -467,13 +467,17 @@ where
///
/// # Panics
///
/// Panic if the size of the SIMD type is different from `N` times that of the scalar.
/// Panic if the size of the SIMD vector is different from `N` times that of the scalar.
#[must_use]
#[inline]
fn as_simd<const N: usize>(slice: &[Self]) -> (&[Self], &[Self::Simd<N>], &[Self])
where
LaneCount<N>: SupportedLaneCount;
LaneCount<N>: SupportedLaneCount,
{
Self::Simd::as_simd(slice)
}

/// Split a mutable slice into a mutable prefix, a middle of aligned SIMD types, and a mutable
/// Split a mutable slice into a mutable prefix, a middle of aligned SIMD vectors, and a mutable
/// suffix.
///
/// You're only assured that `self.len() == prefix.len() + middle.len() * N + suffix.len()`.
Expand All @@ -491,13 +495,17 @@ where
///
/// # Panics
///
/// Panic if the size of the SIMD type is different from `N` times that of the scalar.
/// Panic if the size of the SIMD vector is different from `N` times that of the scalar.
#[must_use]
#[inline]
fn as_simd_mut<const N: usize>(
slice: &mut [Self],
) -> (&mut [Self], &mut [Self::Simd<N>], &mut [Self])
where
LaneCount<N>: SupportedLaneCount;
LaneCount<N>: SupportedLaneCount,
{
Self::Simd::as_simd_mut(slice)
}
}

impl<R: Real> ApproxEq<R> for R {
Expand Down
8 changes: 4 additions & 4 deletions src/simd_bits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ where
#[must_use]
fn splat(value: B) -> Self;

/// Split a slice into a prefix, a middle of aligned SIMD types, and a suffix.
/// Split a slice into a prefix, a middle of aligned SIMD vectors, and a suffix.
///
/// You're only assured thatc`self.len() == prefix.len() + middle.len() * N + suffix.len()`.
///
Expand All @@ -91,11 +91,11 @@ where
///
/// # Panics
///
/// Panic if the size of the SIMD type is different from `N` times that of the scalar.
/// Panic if the size of the SIMD vector is different from `N` times that of the scalar.
#[must_use]
fn as_simd(slice: &[B]) -> (&[B], &[Self], &[B]);

/// Split a mutable slice into a mutable prefix, a middle of aligned SIMD types, and a mutable
/// Split a mutable slice into a mutable prefix, a middle of aligned SIMD vectors, and a mutable
/// suffix.
///
/// You're only assured that `self.len() == prefix.len() + middle.len() * N + suffix.len()`.
Expand All @@ -113,7 +113,7 @@ where
///
/// # Panics
///
/// Panic if the size of the SIMD type is different from `N` times that of the scalar.
/// Panic if the size of the SIMD vector is different from `N` times that of the scalar.
#[must_use]
fn as_simd_mut(slice: &mut [B]) -> (&mut [B], &mut [Self], &mut [B]);

Expand Down
8 changes: 4 additions & 4 deletions src/simd_real/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ where
#[must_use]
fn splat(value: R) -> Self;

/// Split a slice into a prefix, a middle of aligned SIMD types, and a suffix.
/// Split a slice into a prefix, a middle of aligned SIMD vectors, and a suffix.
///
/// You're only assured thatc`self.len() == prefix.len() + middle.len() * N + suffix.len()`.
///
Expand All @@ -116,11 +116,11 @@ where
///
/// # Panics
///
/// Panic if the size of the SIMD type is different from `N` times that of the scalar.
/// Panic if the size of the SIMD vector is different from `N` times that of the scalar.
#[must_use]
fn as_simd(slice: &[R]) -> (&[R], &[Self], &[R]);

/// Split a mutable slice into a mutable prefix, a middle of aligned SIMD types, and a mutable
/// Split a mutable slice into a mutable prefix, a middle of aligned SIMD vectors, and a mutable
/// suffix.
///
/// You're only assured that `self.len() == prefix.len() + middle.len() * N + suffix.len()`.
Expand All @@ -138,7 +138,7 @@ where
///
/// # Panics
///
/// Panic if the size of the SIMD type is different from `N` times that of the scalar.
/// Panic if the size of the SIMD vector is different from `N` times that of the scalar.
#[must_use]
fn as_simd_mut(slice: &mut [R]) -> (&mut [R], &mut [Self], &mut [R]);

Expand Down

0 comments on commit bc8cf12

Please sign in to comment.