From 7d91357875da59d52284d506dcb457f7f88bf6bf Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Tue, 9 Nov 2021 23:49:16 -0800 Subject: [PATCH] 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. --- .github/workflows/ci.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 90007a2f8f6..d50dfa1be4c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 }}