From 2dd9c4f4e38637a09d8bd81b65a90247d87a4df9 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 1 May 2026 13:39:36 +0000 Subject: [PATCH] fix(simd): gate all simd_avx512 test modules behind target_feature = avx512f MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- AGENTS.md | 7 ++++--- src/simd_avx512.rs | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index abab191a..134b7b87 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -18,9 +18,10 @@ This is a Rust library crate (ndarray fork with HPC extensions). No external ser ### Environment notes -- **Rust 1.94.0** is pinned via `rust-toolchain.toml`; rustup auto-selects it in `/workspace`. -- **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. +- **Rust 1.94.1** is pinned via `rust-toolchain.toml`; rustup auto-selects it in `/workspace`. +- **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. - **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. -- **Build time**: ~18s cold, <1s incremental. Tests (~1819) take ~70s. +- **Build time**: ~18s cold, <1s incremental. Tests (~1776 on non-AVX-512) take ~70s. - 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). - `libssl-dev` is needed as a build dependency for some transitive crates. +- **`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. diff --git a/src/simd_avx512.rs b/src/simd_avx512.rs index 1c6b8592..57c4b4f4 100644 --- a/src/simd_avx512.rs +++ b/src/simd_avx512.rs @@ -2619,7 +2619,7 @@ unsafe fn convert_f32_to_bf16_avx512f_rne(input: &[f32], output: &mut [u16]) { } } -#[cfg(test)] +#[cfg(all(test, target_feature = "avx512f"))] mod bf16_tests { use super::*; @@ -3260,7 +3260,7 @@ pub fn f32_to_f16_batch_ieee754_rne(input: &[f32], output: &mut [u16]) { } } -#[cfg(test)] +#[cfg(all(test, target_feature = "avx512f"))] mod f16_tests { use super::*; @@ -3351,7 +3351,7 @@ mod f16_tests { } } -#[cfg(test)] +#[cfg(all(test, target_feature = "avx512f"))] mod u8x64_rasterizer_tests { use super::U8x64; @@ -3467,7 +3467,7 @@ mod u8x64_rasterizer_tests { } } -#[cfg(test)] +#[cfg(all(test, target_feature = "avx512f"))] mod tier3_tests { use super::{U8x64, U16x32}; @@ -3590,7 +3590,7 @@ mod tier3_tests { // whichever path the linker selected. // ──────────────────────────────────────────────────────────────────────── -#[cfg(test)] +#[cfg(all(test, target_feature = "avx512f"))] mod int_simd_tests { use crate::simd::{I8x32, I8x64, I16x16, I16x32};