Skip to content

Commit 7d91357

Browse files
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.
1 parent 949f71c commit 7d91357

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

.github/workflows/ci.yml

+12-6
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,14 @@ jobs:
228228
run: cross test --verbose --target=${{ matrix.target }} --release
229229

230230
features:
231-
name: "Check cargo features (${{ matrix.features }} ${{ matrix.rustflags }})"
231+
name: "Check cargo features (${{ matrix.simd }} × ${{ matrix.features }})"
232232
runs-on: ubuntu-latest
233233
strategy:
234234
fail-fast: false
235235
matrix:
236-
rustflags:
236+
simd:
237237
- ""
238-
- "-Ctarget-feature=+avx512f" # AVX-512 uses packed bit masks, so enable it to test more code paths
238+
- "avx512"
239239
features:
240240
- ""
241241
- "--features std"
@@ -248,7 +248,13 @@ jobs:
248248
run: |
249249
rustup update nightly --no-self-update
250250
rustup default nightly
251+
- name: Detect AVX512
252+
run: echo "CPU_FEATURE=$(lscpu | grep -o avx512[a-z]* | sed s/avx/+avx/ | tr '\n' ',' )" >> $GITHUB_ENV
251253
- name: Check build
252-
run: cargo check --all-targets --no-default-features ${{ matrix.features }}
253-
env:
254-
RUSTFLAGS: -Dwarnings ${{ matrix.rustflags }}
254+
if: ${{ matrix.simd == '' }}
255+
run: RUSTFLAGS="-Dwarnings" cargo check --all-targets --no-default-features ${{ matrix.features }}
256+
- name: Check AVX
257+
if: ${{ matrix.simd == 'avx512' && contains(env.CPU_FEATURE, 'avx512') }}
258+
run: |
259+
echo "Found AVX features: $CPU_FEATURE"
260+
RUSTFLAGS="-Dwarnings -Ctarget-feature=$CPU_FEATURE" cargo check --all-targets --no-default-features ${{ matrix.features }}

0 commit comments

Comments
 (0)