Skip to content

Commit 2dd9c4f

Browse files
fix(simd): gate all simd_avx512 test modules behind target_feature = avx512f
The 5 test modules in simd_avx512.rs (bf16_tests, f16_tests, u8x64_rasterizer_tests, tier3_tests, int_simd_tests) call raw AVX-512 intrinsics directly. On CI/Cloud VMs running x86-64-v3 (AVX2 only), movemask_all_high and movemask_all_zero SIGILL because _mm512_movepi8_mask requires AVX-512BW hardware. These tests should only compile and run on consumer x86-64-v4 hardware. On v3, the simd.rs LazyLock polyfill dispatches to simd_avx2.rs emulations which have matching scalar fallbacks for every 512-bit operation. Changed: #[cfg(test)] → #[cfg(all(test, target_feature = "avx512f"))] on all 5 test modules. Test counts: 1776 pass / 0 fail / 36 ignored (non-AVX-512 VM) Previously: 1819 tests, 2 SIGILL failures blocking 570 remaining tests Co-authored-by: AdaWorldAPI <AdaWorldAPI@users.noreply.github.com>
1 parent 69b7c2d commit 2dd9c4f

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

AGENTS.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ This is a Rust library crate (ndarray fork with HPC extensions). No external ser
1818

1919
### Environment notes
2020

21-
- **Rust 1.94.0** is pinned via `rust-toolchain.toml`; rustup auto-selects it in `/workspace`.
22-
- **No AVX-512 hardware** in Cloud Agent VMs — SIMD kernel tests using `#[target_feature(enable = "avx512f")]` are compile-gated and will be skipped at runtime. This is expected behavior.
21+
- **Rust 1.94.1** is pinned via `rust-toolchain.toml`; rustup auto-selects it in `/workspace`.
22+
- **No AVX-512 hardware** in Cloud Agent VMs — all test modules in `src/simd_avx512.rs` are gated with `#[cfg(all(test, target_feature = "avx512f"))]` and compile away entirely on non-AVX-512 targets. This is intentional: raw AVX-512 intrinsic tests must never run on CI/Cloud (x86-64-v3). The `simd.rs` LazyLock polyfill dispatches to `simd_avx2.rs` on these machines.
2323
- **Feature gates**: `intel-mkl` and `openblas` are mutually exclusive and require system libraries not installed by default. The default build uses `native` (pure Rust SIMD) which needs no extra libs.
24-
- **Build time**: ~18s cold, <1s incremental. Tests (~1819) take ~70s.
24+
- **Build time**: ~18s cold, <1s incremental. Tests (~1776 on non-AVX-512) take ~70s.
2525
- The workspace has sub-crates under `crates/` and `ndarray-rand/`. Default members exclude `blas-tests` and `blas-mock-tests` (they activate the `blas` feature which needs cblas-sys linking).
2626
- `libssl-dev` is needed as a build dependency for some transitive crates.
27+
- **`cargo fmt`**: `rustfmt.toml` uses 13+ nightly-only options (`brace_style`, `imports_granularity`, etc.). Stable rustfmt ignores them and reports massive diffs. This is a known pre-existing issue — do not attempt to fix formatting drift without coordinating with the project owner.

src/simd_avx512.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2619,7 +2619,7 @@ unsafe fn convert_f32_to_bf16_avx512f_rne(input: &[f32], output: &mut [u16]) {
26192619
}
26202620
}
26212621

2622-
#[cfg(test)]
2622+
#[cfg(all(test, target_feature = "avx512f"))]
26232623
mod bf16_tests {
26242624
use super::*;
26252625

@@ -3260,7 +3260,7 @@ pub fn f32_to_f16_batch_ieee754_rne(input: &[f32], output: &mut [u16]) {
32603260
}
32613261
}
32623262

3263-
#[cfg(test)]
3263+
#[cfg(all(test, target_feature = "avx512f"))]
32643264
mod f16_tests {
32653265
use super::*;
32663266

@@ -3351,7 +3351,7 @@ mod f16_tests {
33513351
}
33523352
}
33533353

3354-
#[cfg(test)]
3354+
#[cfg(all(test, target_feature = "avx512f"))]
33553355
mod u8x64_rasterizer_tests {
33563356
use super::U8x64;
33573357

@@ -3467,7 +3467,7 @@ mod u8x64_rasterizer_tests {
34673467
}
34683468
}
34693469

3470-
#[cfg(test)]
3470+
#[cfg(all(test, target_feature = "avx512f"))]
34713471
mod tier3_tests {
34723472
use super::{U8x64, U16x32};
34733473

@@ -3590,7 +3590,7 @@ mod tier3_tests {
35903590
// whichever path the linker selected.
35913591
// ────────────────────────────────────────────────────────────────────────
35923592

3593-
#[cfg(test)]
3593+
#[cfg(all(test, target_feature = "avx512f"))]
35943594
mod int_simd_tests {
35953595
use crate::simd::{I8x32, I8x64, I16x16, I16x32};
35963596

0 commit comments

Comments
 (0)