Skip to content

Commit 19d87a5

Browse files
calebzulawskigitbot
authored and
gitbot
committed
Merge commit '3383cfbd3572465febc7a8f816a46304373de46a' into sync-from-portable-simd-2025-01-18
1 parent 39d514d commit 19d87a5

31 files changed

+865
-388
lines changed

portable-simd/.github/workflows/ci.yml

+52-73
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,15 @@ on:
99
env:
1010
CARGO_NET_RETRY: 10
1111
RUSTUP_MAX_RETRIES: 10
12+
PROPTEST_CASES: 64
1213

1314
jobs:
1415
rustfmt:
1516
name: "rustfmt"
1617
runs-on: ubuntu-latest
1718

1819
steps:
19-
- uses: actions/checkout@v2
20-
- name: Setup Rust
21-
run: |
22-
rustup update nightly --no-self-update
23-
rustup default nightly
24-
rustup component add rustfmt
20+
- uses: actions/checkout@v4
2521
- name: Run rustfmt
2622
run: cargo fmt --all -- --check
2723

@@ -37,7 +33,9 @@ jobs:
3733
- i686-unknown-linux-gnu
3834
- i586-unknown-linux-gnu
3935
- aarch64-unknown-linux-gnu
36+
- arm64ec-pc-windows-msvc
4037
- armv7-unknown-linux-gnueabihf
38+
- loongarch64-unknown-linux-gnu
4139
# non-nightly since https://github.com/rust-lang/rust/pull/113274
4240
# - mips-unknown-linux-gnu
4341
# - mips64-unknown-linux-gnuabi64
@@ -49,13 +47,9 @@ jobs:
4947
- wasm32-unknown-unknown
5048

5149
steps:
52-
- uses: actions/checkout@v2
50+
- uses: actions/checkout@v4
5351
- name: Setup Rust
54-
run: |
55-
rustup update nightly --no-self-update
56-
rustup default nightly
57-
rustup target add ${{ matrix.target }}
58-
rustup component add clippy
52+
run: rustup target add ${{ matrix.target }}
5953
- name: Run Clippy
6054
run: cargo clippy --all-targets --target ${{ matrix.target }}
6155

@@ -65,26 +59,19 @@ jobs:
6559
strategy:
6660
fail-fast: false
6761
matrix:
68-
target: [x86_64-pc-windows-msvc, i686-pc-windows-msvc, i586-pc-windows-msvc, x86_64-unknown-linux-gnu, x86_64-apple-darwin]
62+
target: [x86_64-pc-windows-msvc, i686-pc-windows-msvc, i586-pc-windows-msvc, x86_64-unknown-linux-gnu]
6963
# `default` means we use the default target config for the target,
7064
# `native` means we run with `-Ctarget-cpu=native`, and anything else is
7165
# an arg to `-Ctarget-feature`
7266
target_feature: [default, native, +sse3, +ssse3, +sse4.1, +sse4.2, +avx, +avx2]
7367

7468
exclude:
75-
# The macos runners seem to only reliably support up to `avx`.
76-
- { target: x86_64-apple-darwin, target_feature: +avx2 }
77-
# These features are statically known to be present for all 64 bit
78-
# macs, and thus are covered by the `default` test
79-
- { target: x86_64-apple-darwin, target_feature: +sse3 }
80-
- { target: x86_64-apple-darwin, target_feature: +ssse3 }
8169
# -Ctarget-cpu=native sounds like bad-news if target != host
8270
- { target: i686-pc-windows-msvc, target_feature: native }
8371
- { target: i586-pc-windows-msvc, target_feature: native }
8472

8573
include:
8674
# Populate the `matrix.os` field
87-
- { target: x86_64-apple-darwin, os: macos-latest }
8875
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest }
8976
- { target: x86_64-pc-windows-msvc, os: windows-latest }
9077
- { target: i686-pc-windows-msvc, os: windows-latest }
@@ -98,12 +85,9 @@ jobs:
9885
# avx512vl, but occasionally doesn't. Maybe one day we can enable it.
9986

10087
steps:
101-
- uses: actions/checkout@v2
88+
- uses: actions/checkout@v4
10289
- name: Setup Rust
103-
run: |
104-
rustup update nightly --no-self-update
105-
rustup default nightly
106-
rustup target add ${{ matrix.target }}
90+
run: rustup target add ${{ matrix.target }}
10791

10892
- name: Configure RUSTFLAGS
10993
shell: bash
@@ -145,6 +129,35 @@ jobs:
145129
run: cargo doc --verbose --target=${{ matrix.target }}
146130
env:
147131
RUSTDOCFLAGS: -Dwarnings
132+
133+
macos-tests:
134+
name: ${{ matrix.target }}
135+
runs-on: macos-latest
136+
strategy:
137+
fail-fast: false
138+
matrix:
139+
target:
140+
- aarch64-apple-darwin
141+
- x86_64-apple-darwin
142+
steps:
143+
- uses: actions/checkout@v4
144+
- name: Setup Rust
145+
run: rustup target add ${{ matrix.target }}
146+
147+
- name: Configure RUSTFLAGS
148+
shell: bash
149+
run: echo "RUSTFLAGS=-Dwarnings" >> $GITHUB_ENV
150+
151+
- name: Test (debug)
152+
run: cargo test --verbose --target=${{ matrix.target }}
153+
154+
- name: Test (release)
155+
run: cargo test --verbose --target=${{ matrix.target }} --release
156+
157+
- name: Generate docs
158+
run: cargo doc --verbose --target=${{ matrix.target }}
159+
env:
160+
RUSTDOCFLAGS: -Dwarnings
148161

149162
wasm-tests:
150163
name: "wasm (firefox, ${{ matrix.name }})"
@@ -155,11 +168,7 @@ jobs:
155168
- { name: default, RUSTFLAGS: "" }
156169
- { name: simd128, RUSTFLAGS: "-C target-feature=+simd128" }
157170
steps:
158-
- uses: actions/checkout@v2
159-
- name: Setup Rust
160-
run: |
161-
rustup update nightly --no-self-update
162-
rustup default nightly
171+
- uses: actions/checkout@v4
163172
- name: Install wasm-pack
164173
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
165174
- name: Test (debug)
@@ -174,6 +183,8 @@ jobs:
174183
cross-tests:
175184
name: "${{ matrix.target_feature }} on ${{ matrix.target }} (via cross)"
176185
runs-on: ubuntu-latest
186+
env:
187+
PROPTEST_CASES: 16
177188
strategy:
178189
fail-fast: false
179190

@@ -185,6 +196,7 @@ jobs:
185196
- powerpc-unknown-linux-gnu
186197
- powerpc64le-unknown-linux-gnu # includes altivec by default
187198
- riscv64gc-unknown-linux-gnu
199+
- loongarch64-unknown-linux-gnu
188200
# MIPS uses a nonstandard binary representation for NaNs which makes it worth testing
189201
# non-nightly since https://github.com/rust-lang/rust/pull/113274
190202
# - mips-unknown-linux-gnu
@@ -201,24 +213,14 @@ jobs:
201213
# - { target: riscv64gc-unknown-linux-gnu, target_feature: "+v,+zvl128b" }
202214

203215
steps:
204-
- uses: actions/checkout@v2
216+
- uses: actions/checkout@v4
205217
- name: Setup Rust
206-
run: |
207-
rustup update nightly --no-self-update
208-
rustup default nightly
209-
rustup target add ${{ matrix.target }}
210-
rustup component add rust-src
218+
run: rustup target add ${{ matrix.target }}
211219

212220
- name: Install Cross
213-
# Equivalent to `cargo install cross`, but downloading a prebuilt
214-
# binary. Ideally we wouldn't hardcode a version, but the version number
215-
# being part of the tarball means we can't just use the download/latest
216-
# URL :(
221+
# Install the latest git version for newer targets.
217222
run: |
218-
CROSS_URL=https://github.com/cross-rs/cross/releases/download/v0.2.5/cross-x86_64-unknown-linux-gnu.tar.gz
219-
mkdir -p "$HOME/.bin"
220-
curl -sfSL --retry-delay 10 --retry 5 "${CROSS_URL}" | tar zxf - -C "$HOME/.bin"
221-
echo "$HOME/.bin" >> $GITHUB_PATH
223+
cargo install cross --git https://github.com/cross-rs/cross --rev 4090beca3cfffa44371a5bba524de3a578aa46c3
222224
223225
- name: Configure Emulated CPUs
224226
run: |
@@ -242,34 +244,11 @@ jobs:
242244
- name: Test (release)
243245
run: cross test --verbose --target=${{ matrix.target }} --release
244246

245-
features:
246-
name: "Test cargo features (${{ matrix.simd }} × ${{ matrix.features }})"
247+
miri:
247248
runs-on: ubuntu-latest
248-
strategy:
249-
fail-fast: false
250-
matrix:
251-
simd:
252-
- ""
253-
- "avx512"
254-
features:
255-
- ""
256-
- "--features std"
257-
- "--features all_lane_counts"
258-
- "--all-features"
259-
249+
env:
250+
PROPTEST_CASES: 16
260251
steps:
261-
- uses: actions/checkout@v2
262-
- name: Setup Rust
263-
run: |
264-
rustup update nightly --no-self-update
265-
rustup default nightly
266-
- name: Detect AVX512
267-
run: echo "CPU_FEATURE=$(lscpu | grep -o avx512[a-z]* | sed s/avx/+avx/ | tr '\n' ',' )" >> $GITHUB_ENV
268-
- name: Check build
269-
if: ${{ matrix.simd == '' }}
270-
run: RUSTFLAGS="-Dwarnings" cargo test --all-targets --no-default-features ${{ matrix.features }}
271-
- name: Check AVX
272-
if: ${{ matrix.simd == 'avx512' && contains(env.CPU_FEATURE, 'avx512') }}
273-
run: |
274-
echo "Found AVX features: $CPU_FEATURE"
275-
RUSTFLAGS="-Dwarnings -Ctarget-feature=$CPU_FEATURE" cargo test --all-targets --no-default-features ${{ matrix.features }}
252+
- uses: actions/checkout@v4
253+
- name: Test (Miri)
254+
run: cargo miri test

portable-simd/.github/workflows/doc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
steps:
1414
- name: Checkout Repository
15-
uses: actions/checkout@v1
15+
uses: actions/checkout@v4
1616

1717
- name: Setup Rust
1818
run: |

portable-simd/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/target
2+
git-subtree.sh

portable-simd/Cargo.toml

+6
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ members = [
55
"crates/std_float",
66
"crates/test_helpers",
77
]
8+
9+
[profile.test.package."*"]
10+
opt-level = 2
11+
12+
[profile.test.package.test_helpers]
13+
opt-level = 2

portable-simd/Cross.toml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[build.env]
2+
passthrough = ["PROPTEST_CASES"]

portable-simd/crates/core_simd/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ categories = ["hardware-support", "no-std"]
99
license = "MIT OR Apache-2.0"
1010

1111
[features]
12-
default = ["as_crate"]
12+
default = ["as_crate", "std"]
1313
as_crate = []
1414
std = []
15-
all_lane_counts = []
1615

1716
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
1817
wasm-bindgen = "0.2"

portable-simd/crates/core_simd/src/lane_count.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ macro_rules! supported_lane_count {
3333
};
3434
}
3535

36-
supported_lane_count!(1, 2, 4, 8, 16, 32, 64);
37-
#[cfg(feature = "all_lane_counts")]
3836
supported_lane_count!(
39-
3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
40-
31, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
41-
56, 57, 58, 59, 60, 61, 62, 63
37+
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
38+
27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
39+
51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64
4240
);

portable-simd/crates/core_simd/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#![no_std]
22
#![feature(
3-
const_refs_to_cell,
4-
const_mut_refs,
3+
const_eval_select,
54
convert_float_to_int,
65
core_intrinsics,
76
decl_macro,
@@ -26,6 +25,7 @@
2625
all(target_arch = "arm", target_feature = "v7"),
2726
feature(stdarch_arm_neon_intrinsics)
2827
)]
28+
#![cfg_attr(target_arch = "loongarch64", feature(stdarch_loongarch))]
2929
#![cfg_attr(
3030
any(target_arch = "powerpc", target_arch = "powerpc64"),
3131
feature(stdarch_powerpc)

portable-simd/crates/core_simd/src/masks.rs

-42
Original file line numberDiff line numberDiff line change
@@ -308,48 +308,6 @@ where
308308
Self(mask_impl::Mask::from_bitmask_integer(bitmask))
309309
}
310310

311-
/// Creates a bitmask vector from a mask.
312-
///
313-
/// Each bit is set if the corresponding element in the mask is `true`.
314-
/// The remaining bits are unset.
315-
///
316-
/// The bits are packed into the first N bits of the vector:
317-
/// ```
318-
/// # #![feature(portable_simd)]
319-
/// # #[cfg(feature = "as_crate")] use core_simd::simd;
320-
/// # #[cfg(not(feature = "as_crate"))] use core::simd;
321-
/// # use simd::mask32x8;
322-
/// let mask = mask32x8::from_array([true, false, true, false, false, false, true, false]);
323-
/// assert_eq!(mask.to_bitmask_vector()[0], 0b01000101);
324-
/// ```
325-
#[inline]
326-
#[must_use = "method returns a new integer and does not mutate the original value"]
327-
pub fn to_bitmask_vector(self) -> Simd<u8, N> {
328-
self.0.to_bitmask_vector()
329-
}
330-
331-
/// Creates a mask from a bitmask vector.
332-
///
333-
/// For each bit, if it is set, the corresponding element in the mask is set to `true`.
334-
///
335-
/// The bits are packed into the first N bits of the vector:
336-
/// ```
337-
/// # #![feature(portable_simd)]
338-
/// # #[cfg(feature = "as_crate")] use core_simd::simd;
339-
/// # #[cfg(not(feature = "as_crate"))] use core::simd;
340-
/// # use simd::{mask32x8, u8x8};
341-
/// let bitmask = u8x8::from_array([0b01000101, 0, 0, 0, 0, 0, 0, 0]);
342-
/// assert_eq!(
343-
/// mask32x8::from_bitmask_vector(bitmask),
344-
/// mask32x8::from_array([true, false, true, false, false, false, true, false]),
345-
/// );
346-
/// ```
347-
#[inline]
348-
#[must_use = "method returns a new mask and does not mutate the original value"]
349-
pub fn from_bitmask_vector(bitmask: Simd<u8, N>) -> Self {
350-
Self(mask_impl::Mask::from_bitmask_vector(bitmask))
351-
}
352-
353311
/// Finds the index of the first set element.
354312
///
355313
/// ```

portable-simd/crates/core_simd/src/masks/bitmask.rs

-17
Original file line numberDiff line numberDiff line change
@@ -122,23 +122,6 @@ where
122122
unsafe { Self(core::intrinsics::simd::simd_bitmask(value), PhantomData) }
123123
}
124124

125-
#[inline]
126-
#[must_use = "method returns a new vector and does not mutate the original value"]
127-
pub fn to_bitmask_vector(self) -> Simd<u8, N> {
128-
let mut bitmask = Simd::splat(0);
129-
bitmask.as_mut_array()[..self.0.as_ref().len()].copy_from_slice(self.0.as_ref());
130-
bitmask
131-
}
132-
133-
#[inline]
134-
#[must_use = "method returns a new mask and does not mutate the original value"]
135-
pub fn from_bitmask_vector(bitmask: Simd<u8, N>) -> Self {
136-
let mut bytes = <LaneCount<N> as SupportedLaneCount>::BitMask::default();
137-
let len = bytes.as_ref().len();
138-
bytes.as_mut().copy_from_slice(&bitmask.as_array()[..len]);
139-
Self(bytes, PhantomData)
140-
}
141-
142125
#[inline]
143126
pub fn to_bitmask_integer(self) -> u64 {
144127
let mut bitmask = [0u8; 8];

0 commit comments

Comments
 (0)