Skip to content

Commit

Permalink
chore(portable_simd): update to the latest nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
sebcrozet committed Jun 22, 2024
1 parent bc24862 commit 98c6e94
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 50 deletions.
41 changes: 13 additions & 28 deletions .github/workflows/simba-ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ jobs:
check-fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check formatting
run: cargo fmt -- --check
- uses: actions/checkout@v2
- name: Check formatting
run: cargo fmt -- --check
build-native:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build --no-default-feature
run: cargo build --no-default-features;
- name: Build libm only
run: cargo build --no-default-features --features libm;
- name: Build (default features)
run: cargo build;
- name: Build all features except cuda,libm
run: cargo build --features wide,rkyv-serialize,serde_serialize,partial_fixed_point_support;
- uses: actions/checkout@v2
- name: Build --no-default-feature
run: cargo build --no-default-features;
- name: Build libm only
run: cargo build --no-default-features --features libm;
- name: Build (default features)
run: cargo build;
- name: Build all features except libm
run: cargo build --features wide,rkyv-serialize,serde_serialize,partial_fixed_point_support;
build-wasm:
runs-on: ubuntu-latest
steps:
Expand All @@ -49,19 +49,4 @@ jobs:
- name: build x86_64-unknown-linux-gnu
run: xargo build --verbose --no-default-features --target=x86_64-unknown-linux-gnu;
- name: build x86_64-unknown-linux-gnu --features libm
run: xargo build --verbose --no-default-features --features libm --target=x86_64-unknown-linux-gnu;
build-cuda:
runs-on: ubuntu-latest
steps:
- uses: Jimver/[email protected]
- name: Install nightly-2021-12-04
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-12-04
override: true
- uses: actions/checkout@v2
- run: rustup target add nvptx64-nvidia-cuda
- run: cargo build --no-default-features --features cuda
- run: cargo build --no-default-features --features cuda --target=nvptx64-nvidia-cuda
env:
CUDA_ARCH: "350"
run: xargo build --verbose --no-default-features --features libm --target=x86_64-unknown-linux-gnu;
43 changes: 21 additions & 22 deletions src/simd/portable_simd_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ use std::{
RemAssign, Sub, SubAssign,
},
simd::{
self as portable_simd, SimdFloat, SimdInt, SimdOrd, SimdPartialEq,
SimdPartialOrd as PortableSimdPartialOrd, SimdUint, StdFloat, ToBitMask,
},
self as portable_simd, num::SimdFloat, num::SimdInt, cmp::SimdOrd, cmp::SimdPartialEq,
cmp::SimdPartialOrd as PortableSimdPartialOrd, num::SimdUint, StdFloat, },
};

// This is a hack to allow use to reuse `_0` as integers or as identifier,
// depending on whether or not `ident_to_value` has been called in scope.
// This helps writing macros that define both `::new` and `From([T; lanes()])`.
macro_rules! ident_to_value(
macro_rules! ident_to_value (
() => {
const _0: usize = 0; const _1: usize = 1; const _2: usize = 2; const _3: usize = 3; const _4: usize = 4; const _5: usize = 5; const _6: usize = 6; const _7: usize = 7;
const _8: usize = 8; const _9: usize = 9; const _10: usize = 10; const _11: usize = 11; const _12: usize = 12; const _13: usize = 13; const _14: usize = 14; const _15: usize = 15;
Expand All @@ -47,7 +46,7 @@ macro_rules! ident_to_value(
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct Simd<N>(pub N);

macro_rules! impl_bool_simd(
macro_rules! impl_bool_simd (
($($t: ty, $lanes: literal, $($i: ident),*;)*) => {$(
impl fmt::Display for Simd<$t> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down Expand Up @@ -243,7 +242,7 @@ macro_rules! impl_bool_simd(
)*}
);

macro_rules! impl_scalar_subset_of_simd(
macro_rules! impl_scalar_subset_of_simd (
($($t: ty),*) => {$(
impl<N2> SubsetOf<Simd<N2>> for $t
where Simd<N2>: SimdValue + Copy,
Expand Down Expand Up @@ -272,7 +271,7 @@ impl_scalar_subset_of_simd!(u8, u16, u32, u64, usize, i8, i16, i32, i64, isize,
#[cfg(feature = "decimal")]
impl_scalar_subset_of_simd!(d128);

macro_rules! impl_simd_value(
macro_rules! impl_simd_value (
($($t: ty, $elt: ty, $bool: ty, $($i: ident),*;)*) => ($(
impl fmt::Display for Simd<$t> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down Expand Up @@ -305,7 +304,7 @@ macro_rules! impl_simd_value(

#[inline(always)]
fn lanes() -> usize {
<$t>::LANES
<$t>::LEN
}

#[inline(always)]
Expand Down Expand Up @@ -341,7 +340,7 @@ macro_rules! impl_simd_value(
)*)
);

macro_rules! impl_uint_simd(
macro_rules! impl_uint_simd (
($($t: ty, $elt: ty, $bool: ty, $($i: ident),*;)*) => ($(
impl_simd_value!($t, $elt, $bool $(, $i)*;);

Expand All @@ -357,16 +356,16 @@ macro_rules! impl_uint_simd(
}
}

impl From<[$elt; <$t>::LANES]> for Simd<$t> {
impl From<[$elt; <$t>::LEN]> for Simd<$t> {
#[inline(always)]
fn from(vals: [$elt; <$t>::LANES]) -> Self {
fn from(vals: [$elt; <$t>::LEN]) -> Self {
Simd(<$t>::from(vals))
}
}

impl From<Simd<$t>> for [$elt; <$t>::LANES] {
impl From<Simd<$t>> for [$elt; <$t>::LEN] {
#[inline(always)]
fn from(val: Simd<$t>) -> [$elt; <$t>::LANES] {
fn from(val: Simd<$t>) -> [$elt; <$t>::LEN] {
val.0.to_array()
}
}
Expand Down Expand Up @@ -636,7 +635,7 @@ macro_rules! impl_uint_simd(
)*)
);

macro_rules! impl_int_simd(
macro_rules! impl_int_simd (
($($t: ty, $elt: ty, $bool: ty, $($i: ident),*;)*) => ($(
impl_uint_simd!($t, $elt, $bool $(, $i)*;);

Expand All @@ -651,7 +650,7 @@ macro_rules! impl_int_simd(
)*)
);

macro_rules! impl_float_simd(
macro_rules! impl_float_simd (
($($t: ty, $elt: ident, $int: ty, $bool: ty, $($i: ident),*;)*) => ($(
impl_int_simd!($t, $elt, $bool $(, $i)*;);

Expand Down Expand Up @@ -936,12 +935,12 @@ macro_rules! impl_float_simd(

#[inline(always)]
fn simd_exp(self) -> Self {
self.map_lanes(|e| e.exp())
Self(self.0.exp())
}

#[inline(always)]
fn simd_exp2(self) -> Self {
self.map_lanes(|e| e.exp2())
Self(self.0.exp2())
}

#[inline(always)]
Expand All @@ -956,7 +955,7 @@ macro_rules! impl_float_simd(

#[inline(always)]
fn simd_ln(self) -> Self {
self.map_lanes(|e| e.ln())
Self(self.0.ln())
}

#[inline(always)]
Expand All @@ -966,12 +965,12 @@ macro_rules! impl_float_simd(

#[inline(always)]
fn simd_log2(self) -> Self {
self.map_lanes(|e| e.log2())
Self(self.0.log2())
}

#[inline(always)]
fn simd_log10(self) -> Self {
self.map_lanes(|e| e.log10())
Self(self.0.log10())
}

#[inline(always)]
Expand All @@ -986,12 +985,12 @@ macro_rules! impl_float_simd(

#[inline(always)]
fn simd_sin(self) -> Self {
self.map_lanes(|e| e.sin())
Self(self.0.sin())
}

#[inline(always)]
fn simd_cos(self) -> Self {
self.map_lanes(|e| e.cos())
Self(self.0.cos())
}

#[inline(always)]
Expand Down

0 comments on commit 98c6e94

Please sign in to comment.