Skip to content

Commit e7fe5c2

Browse files
authored
feat: minor optimizaions + make more wide methods public (#75)
* feat: make more wide from/to array functions public * feat: use simd versions of more wide operations * feat: add some missing inlines * Release v0.9.1 * fix no-std ci
1 parent 45241f4 commit e7fe5c2

File tree

5 files changed

+45
-27
lines changed

5 files changed

+45
-27
lines changed

.github/workflows/simba-ci-build.yml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ jobs:
1313
fmt:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v4
1717
- name: Check formatting
1818
run: cargo fmt -- --check
1919
clippy:
2020
runs-on: ubuntu-latest
2121
env:
2222
RUSTFLAGS: -D warnings
2323
steps:
24-
- uses: actions/checkout@v2
24+
- uses: actions/checkout@v4
2525
- name: Install latest nightly
2626
uses: actions-rs/toolchain@v1
2727
with:
@@ -33,7 +33,7 @@ jobs:
3333
build-native:
3434
runs-on: ubuntu-latest
3535
steps:
36-
- uses: actions/checkout@v2
36+
- uses: actions/checkout@v4
3737
- name: Install latest nightly
3838
uses: actions-rs/toolchain@v1
3939
with:
@@ -52,22 +52,24 @@ jobs:
5252
build-wasm:
5353
runs-on: ubuntu-latest
5454
steps:
55-
- uses: actions/checkout@v2
55+
- uses: actions/checkout@v4
5656
- run: rustup target add wasm32-unknown-unknown
5757
- name: build
5858
run: cargo build --verbose --target wasm32-unknown-unknown;
5959
build-no-std:
6060
runs-on: ubuntu-latest
6161
steps:
62-
- uses: actions/checkout@v2
63-
- name: Install latest nightly
64-
uses: actions-rs/toolchain@v1
62+
- uses: actions/checkout@v4
63+
- name: Install latest stable
64+
uses: dtolnay/rust-toolchain@master
6565
with:
66-
toolchain: nightly
67-
override: true
68-
- name: install xargo
69-
run: cp .github/Xargo.toml .; rustup component add rust-src; cargo install -f xargo;
70-
- name: build x86_64-unknown-linux-gnu
71-
run: xargo build --verbose --no-default-features --target=x86_64-unknown-linux-gnu;
72-
- name: build x86_64-unknown-linux-gnu --features libm
73-
run: xargo build --verbose --no-default-features --features libm --target=x86_64-unknown-linux-gnu;
66+
toolchain: stable
67+
targets: "x86_64-unknown-none,thumbv7em-none-eabihf"
68+
- name: build x86_64-unknown-none
69+
run: cargo build --verbose --no-default-features --target=x86_64-unknown-none
70+
- name: build x86_64-unknown-none --features libm
71+
run: cargo build --verbose --no-default-features --features libm --target=x86_64-unknown-none
72+
- name: build thumbv7em-none-eabihf
73+
run: cargo build --verbose --no-default-features --target=thumbv7em-none-eabihf
74+
- name: build thumbv7em-none-eabihf --features libm
75+
run: cargo build --verbose --no-default-features --features libm --target=thumbv7em-none-eabihf

CHANGELOG

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Release v0.9.1 (05 Sept. 2025)
2+
- `into_arr`, `from_arr`, `map`, `zip_map` are now public on `WideF32x4`, `WideF32x8` and `WideF64x4`.
3+
- `from_arr` and `into_arr` are now public on `WideBoolF32x4`, `WideBoolF32x8`, `WideBoolF64x4`.
4+
- Use SIMD implementations of `WideBool*` methods `all`, `any`, and `none`.
5+
- Inline more `AutoSimd` methods.
6+
17
## Release v0.9.0 (22 June 2023)
28
- The `cuda` feature has been removed, as the toolchain it depends on is long abandoned.
39
- The `packed_simd` feature has been removes as it has been incompatible with the `nightly` compiler for several months.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "simba"
3-
version = "0.9.0"
3+
version = "0.9.1"
44
authors = ["sebcrozet <[email protected]>"]
55
description = "SIMD algebra for Rust"
66
keywords = ["algebra", "simd", "math"]

src/simd/auto_simd_impl.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ macro_rules! impl_bool_simd (
6868
pub const ZERO: Self = AutoSimd([false; $lanes]);
6969
pub const ONE: Self = AutoSimd([true; $lanes]);
7070

71+
#[inline(always)]
7172
pub fn new($($i: bool),*) -> Self {
7273
AutoSimd([$($i),*])
7374
}
@@ -83,28 +84,34 @@ macro_rules! impl_bool_simd (
8384
impl Not for AutoSimd<$t> {
8485
type Output = Self;
8586

86-
#[inline]
87+
#[inline(always)]
8788
fn not(self) -> Self {
8889
self.map(|x| !x)
8990
}
9091
}
9192

9293
impl BitAnd<AutoSimd<$t>> for AutoSimd<$t> {
9394
type Output = Self;
95+
96+
#[inline(always)]
9497
fn bitand(self, rhs: Self) -> Self {
9598
self.zip_map(rhs, |x, y| x & y)
9699
}
97100
}
98101

99102
impl BitOr<AutoSimd<$t>> for AutoSimd<$t> {
100103
type Output = Self;
104+
105+
#[inline(always)]
101106
fn bitor(self, rhs: Self) -> Self {
102107
self.zip_map(rhs, |x, y| x | y)
103108
}
104109
}
105110

106111
impl BitXor<AutoSimd<$t>> for AutoSimd<$t> {
107112
type Output = Self;
113+
114+
#[inline(always)]
108115
fn bitxor(self, rhs: Self) -> Self {
109116
self.zip_map(rhs, |x, y| x ^ y)
110117
}

src/simd/wide_simd_impl.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,23 +119,23 @@ macro_rules! impl_wide_f32 (
119119
pub const ONE: Self = $WideF32xX(<wide::$f32xX>::ONE);
120120

121121
#[inline(always)]
122-
fn into_arr(self) -> [$f32; $lanes] {
122+
pub fn into_arr(self) -> [$f32; $lanes] {
123123
self.0.into()
124124
}
125125

126126
#[inline(always)]
127-
fn from_arr(arr: [$f32; $lanes]) -> Self {
127+
pub fn from_arr(arr: [$f32; $lanes]) -> Self {
128128
Self(arr.into())
129129
}
130130

131131
#[inline(always)]
132-
fn map(self, f: impl Fn($f32) -> $f32) -> Self {
132+
pub fn map(self, f: impl Fn($f32) -> $f32) -> Self {
133133
let arr = self.into_arr();
134134
Self::from([f(arr[0]), $(f(arr[$ii])),+])
135135
}
136136

137137
#[inline(always)]
138-
fn zip_map(self, rhs: Self, f: impl Fn($f32, $f32) -> $f32) -> Self {
138+
pub fn zip_map(self, rhs: Self, f: impl Fn($f32, $f32) -> $f32) -> Self {
139139
let arr = self.into_arr();
140140
let rhs = rhs.into_arr();
141141
Self::from([
@@ -146,11 +146,13 @@ macro_rules! impl_wide_f32 (
146146
}
147147

148148
impl $WideBoolF32xX {
149-
fn from_arr(arr: [$f32; $lanes]) -> Self {
149+
#[inline(always)]
150+
pub fn from_arr(arr: [$f32; $lanes]) -> Self {
150151
Self(arr.into())
151152
}
152153

153-
fn into_arr(self) -> [$f32; $lanes] {
154+
#[inline(always)]
155+
pub fn into_arr(self) -> [$f32; $lanes] {
154156
self.0.into()
155157
}
156158
}
@@ -319,17 +321,17 @@ macro_rules! impl_wide_f32 (
319321

320322
#[inline(always)]
321323
fn all(self) -> bool {
322-
self == Self(!wide::$f32xX::ZERO)
324+
self.0.all()
323325
}
324326

325327
#[inline(always)]
326328
fn any(self) -> bool {
327-
self != Self(wide::$f32xX::ZERO)
329+
self.0.any()
328330
}
329331

330332
#[inline(always)]
331333
fn none(self) -> bool {
332-
self == Self(wide::$f32xX::ZERO)
334+
self.0.none()
333335
}
334336

335337
#[inline(always)]
@@ -1027,7 +1029,8 @@ macro_rules! impl_wide_f32 (
10271029

10281030
#[inline(always)]
10291031
fn simd_sin_cos(self) -> (Self, Self) {
1030-
(self.simd_sin(), self.simd_cos())
1032+
let (sin, cos) = self.0.sin_cos();
1033+
($WideF32xX(sin), $WideF32xX(cos))
10311034
}
10321035

10331036
// #[inline(always]

0 commit comments

Comments
 (0)