Dynamically detect AVX512 in CI

We would like to check for errors with AVX512,
but we don't pick our CPU. So, detect available features.
This variance in checks stochastically reveals issues.
Nondeterminism is acceptable as our goal is protecting downstream.
This commit is contained in:
Jubilee Young 2021-11-09 23:49:16 -08:00 committed by Jubilee
parent 949f71c0dc
commit 7d91357875

View File

@ -228,14 +228,14 @@ jobs:
run: cross test --verbose --target=${{ matrix.target }} --release
features:
name: "Check cargo features (${{ matrix.features }} ${{ matrix.rustflags }})"
name: "Check cargo features (${{ matrix.simd }} × ${{ matrix.features }})"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rustflags:
simd:
- ""
- "-Ctarget-feature=+avx512f" # AVX-512 uses packed bit masks, so enable it to test more code paths
- "avx512"
features:
- ""
- "--features std"
@ -248,7 +248,13 @@ jobs:
run: |
rustup update nightly --no-self-update
rustup default nightly
- name: Detect AVX512
run: echo "CPU_FEATURE=$(lscpu | grep -o avx512[a-z]* | sed s/avx/+avx/ | tr '\n' ',' )" >> $GITHUB_ENV
- name: Check build
run: cargo check --all-targets --no-default-features ${{ matrix.features }}
env:
RUSTFLAGS: -Dwarnings ${{ matrix.rustflags }}
if: ${{ matrix.simd == '' }}
run: RUSTFLAGS="-Dwarnings" cargo check --all-targets --no-default-features ${{ matrix.features }}
- name: Check AVX
if: ${{ matrix.simd == 'avx512' && contains(env.CPU_FEATURE, 'avx512') }}
run: |
echo "Found AVX features: $CPU_FEATURE"
RUSTFLAGS="-Dwarnings -Ctarget-feature=$CPU_FEATURE" cargo check --all-targets --no-default-features ${{ matrix.features }}