fix(simd): gate simd_avx512 tests behind target_feature = avx512f#134
fix(simd): gate simd_avx512 tests behind target_feature = avx512f#134AdaWorldAPI merged 1 commit intomasterfrom
Conversation
…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>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2dd9c4f4e3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| #[cfg(test)] | ||
| #[cfg(all(test, target_feature = "avx512f"))] |
There was a problem hiding this comment.
Keep BF16/F16 correctness tests in default test builds
This cfg gate now compiles out the entire bf16_tests module unless AVX-512 is enabled at compile time, but that module contains scalar and runtime-dispatched checks (for example scalar_roundtrip and batch_conversion_matches_scalar) that should still run on non-AVX-512 hosts. In normal cargo test runs (without -C target-feature=+avx512f), these core conversion tests disappear, so CI no longer validates BF16/F16 correctness on the default x86_64 path.
Useful? React with 👍 / 👎.
| // ──────────────────────────────────────────────────────────────────────── | ||
|
|
||
| #[cfg(test)] | ||
| #[cfg(all(test, target_feature = "avx512f"))] |
There was a problem hiding this comment.
Re-enable int SIMD tests for non-AVX512 dispatch path
Gating int_simd_tests on compile-time target_feature="avx512f" removes these tests from the default x86-64-v3/CI environment, even though the module tests crate::simd types that intentionally dispatch to AVX2/scalar implementations when AVX-512 is unavailable. That means regressions in the non-AVX512 path are no longer exercised by standard test runs.
Useful? React with 👍 / 👎.
Problem
CI tests 1746/1747 (
simd_avx512::tier3_tests::movemask_all_highandmovemask_all_zero) SIGILL on GitHub Actions runners (x86-64-v3, no AVX-512). This blocked 570 remaining tests from running.Root cause: the 5 test modules in
src/simd_avx512.rscall raw AVX-512 intrinsics (_mm512_movepi8_mask,_mm512_set1_epi8, etc.) directly, bypassing thesimd.rsLazyLock polyfill. On non-AVX-512 hardware, these instructions are illegal.Fix
Changed
#[cfg(test)]→#[cfg(all(test, target_feature = "avx512f"))]on all 5 test modules:bf16_testsf16_testsu8x64_rasterizer_teststier3_testsint_simd_testsThese tests now compile away entirely on x86-64-v3 (CI/Cloud). On consumer x86-64-v4 hardware, they still run as before.
Architecture context
The
simd.rsLazyLock polyfill is the contract — consumers callcrate::simd::F32x16which dispatches to:simd_avx512.rsnative intrinsics on AVX-512 hardwaresimd_avx2.rsemulation (two 256-bit ops or scalar fallbacks) on AVX2 hardwareRaw intrinsic tests in
simd_avx512.rsmust never run on CI/Cloud (x86-64-v3). The polyfill dispatch tests (simd_ops,simd_avx2) cover correctness on v3.Verification
cargo build— cleancargo clippy --features approx,serde,rayon -- -D warnings— cleancargo test --lib -p ndarray— 1776 passed, 0 failed, 36 ignored (vs. previous 2 SIGILL + 570 blocked)cargo test --lib -p ndarray -- simd_avx2— 16 passedcargo test --lib -p ndarray -- simd_ops— 11 passedcargo run --example life— runs correctlyAlso updated
AGENTS.mdwith accurate test count and clarified AVX-512 gating rationale.