ci: run lavapipe at the AVX level on every Linux runner #477

Merged
oneandonlydean merged 1 commit from upstream-pr/477 into main 2026-10-03 19:50:16 +00:00
oneandonlydean commented 2026-10-03 19:32:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-03T19:32:22Z.


What

agc_driver_vopc_compare fails on some Linux CI runs with thread 1 compare 39 is 0, expected 1. It is not flaky: it depends on which CPU the runner has, and the bug is in the LLVM that Ubuntu 24.04's lavapipe uses, not in the recompiler. #399 changed how v_cmp_nle_f16 is lowered to fix it; LLVM receives the same compare either way, so that change neither caused nor fixed the failure.

This sets GALLIUM_OVERRIDE_CPU_CAPS=avx for the Linux ctest step, so lavapipe compiles at the same level on every runner and LLVM never emits AVX512-FP16 code.

The runner's CPU decides it. On 14 fork CI runners I ran the test 15 times per setting (6 runners), then 3 times per setting (8 runners). Every runner gave the same result on every run:

runner CPU runners AVX512-FP16 default GALLIUM_OVERRIDE_CPU_CAPS=avx
Intel Xeon 6973P-C (Granite Rapids) 2 yes fails passes
Intel Xeon Platinum 8573C (Emerald Rapids) 2 yes (one runner hides the flag from /proc/cpuinfo, but LLVM picks the target from the CPU model) fails passes
Intel Xeon Platinum 8370C (Ice Lake) 1 no passes passes
AMD EPYC 7763 / 9V74 9 no passes passes

On a failing runner, GALLIVM_PERF=nopt (no LLVM optimization) also passes. LP_NATIVE_VECTOR_WIDTH=128 still fails.

Where it goes wrong. With every compare reported (not just the first), the wrong results on those runners are compares 39 (v_cmp_nle_f16), 40 (v_cmp_nlt_f16) and 48 (v_cmpx_nle_f16), in both directions. Each returns its mirror's result: NLE gives NGE's, NLT gives NGT's.

  • The recompiler's SPIR-V is byte-identical on lavapipe and on an NVIDIA GPU, and correct: NGE is OpFUnordLessThan a b, NLE is OpFUnordLessThan b a.
  • I reproduced it locally with Ubuntu's exact packages (mesa-vulkan-drivers 25.2.8-0ubuntu0.24.04.4, libllvm20 20.1.2) under Intel SDE:
    • -spr fails;
    • -icx and -hsw pass;
    • Mesa 26.2.3 with LLVM 22.1.8 passes under -spr.
  • I captured the LLVM modules lavapipe builds under -spr. The optimized IR is still correct: fcmp ult <8 x half> %b, %a for NLE next to fcmp ult <8 x half> %a, %b for NGE, and the same for the uge pair. LLVM then targets sapphirerapids, which implies AVX512-FP16.
  • The same pattern alone reproduces it with llc -O2 -mcpu=sapphirerapids:
define void @f(<8 x half> %a, <8 x half> %b, <8 x i1> %m, ptr %o1, ptr %o2) {
  %c1 = fcmp ult <8 x half> %a, %b
  %c2 = fcmp ult <8 x half> %b, %a
  %d1 = and <8 x i1> %c1, %m
  %d2 = and <8 x i1> %c2, %m
  %r1 = sext <8 x i1> %d1 to <8 x i32>
  %r2 = sext <8 x i1> %d2 to <8 x i32>
  store <8 x i32> %r1, ptr %o1
  store <8 x i32> %r2, ptr %o2
  ret void
}

LLVM 20.1.2 emits a single masked vcmpnleph for both compares, so the second one gets the first one's result. LLVM 22.1.8 emits two with swapped operands. With a uge pair added, LLVM 20 emits 2 compares for 4 and LLVM 22 emits 4.

GALLIUM_OVERRIDE_CPU_CAPS=avx makes Mesa pass -avx512f and the other AVX-512 features to LLVM, which disables AVX512-FP16 too. The halves are then compared as floats, which is correct. It applies on every runner, so the Vulkan tests compile the same way whatever CPU the job lands on. Nothing in the recompiler or the tests changes.

Tested

  • Fork CI on this branch: Linux and Windows green; the Linux ctest step took 27.3 s, against 23.8 s for another branch on the same day, so the AVX level costs little.
  • The table above: the fork CI diagnostic runs (a throwaway branch, since deleted).
  • Locally (CachyOS, i9-14900KF): the test passes on NVIDIA and on lavapipe (Mesa 26.2.3), and the SDE runs listed above.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4729140716 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/477). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-03T19:32:22Z. --- ### What `agc_driver_vopc_compare` fails on some Linux CI runs with `thread 1 compare 39 is 0, expected 1`. It is not flaky: it depends on which CPU the runner has, and the bug is in the LLVM that Ubuntu 24.04's lavapipe uses, not in the recompiler. #399 changed how `v_cmp_nle_f16` is lowered to fix it; LLVM receives the same compare either way, so that change neither caused nor fixed the failure. This sets `GALLIUM_OVERRIDE_CPU_CAPS=avx` for the Linux `ctest` step, so lavapipe compiles at the same level on every runner and LLVM never emits AVX512-FP16 code. **The runner's CPU decides it.** On 14 fork CI runners I ran the test 15 times per setting (6 runners), then 3 times per setting (8 runners). Every runner gave the same result on every run: | runner CPU | runners | AVX512-FP16 | default | `GALLIUM_OVERRIDE_CPU_CAPS=avx` | |---|---|---|---|---| | Intel Xeon 6973P-C (Granite Rapids) | 2 | yes | fails | passes | | Intel Xeon Platinum 8573C (Emerald Rapids) | 2 | yes (one runner hides the flag from `/proc/cpuinfo`, but LLVM picks the target from the CPU model) | fails | passes | | Intel Xeon Platinum 8370C (Ice Lake) | 1 | no | passes | passes | | AMD EPYC 7763 / 9V74 | 9 | no | passes | passes | On a failing runner, `GALLIVM_PERF=nopt` (no LLVM optimization) also passes. `LP_NATIVE_VECTOR_WIDTH=128` still fails. **Where it goes wrong.** With every compare reported (not just the first), the wrong results on those runners are compares 39 (`v_cmp_nle_f16`), 40 (`v_cmp_nlt_f16`) and 48 (`v_cmpx_nle_f16`), in both directions. Each returns its mirror's result: NLE gives NGE's, NLT gives NGT's. - The recompiler's SPIR-V is byte-identical on lavapipe and on an NVIDIA GPU, and correct: NGE is `OpFUnordLessThan a b`, NLE is `OpFUnordLessThan b a`. - I reproduced it locally with Ubuntu's exact packages (mesa-vulkan-drivers 25.2.8-0ubuntu0.24.04.4, libllvm20 20.1.2) under Intel SDE: - `-spr` fails; - `-icx` and `-hsw` pass; - Mesa 26.2.3 with LLVM 22.1.8 passes under `-spr`. - I captured the LLVM modules lavapipe builds under `-spr`. The optimized IR is still correct: `fcmp ult <8 x half> %b, %a` for NLE next to `fcmp ult <8 x half> %a, %b` for NGE, and the same for the `uge` pair. LLVM then targets `sapphirerapids`, which implies AVX512-FP16. - The same pattern alone reproduces it with `llc -O2 -mcpu=sapphirerapids`: ```llvm define void @f(<8 x half> %a, <8 x half> %b, <8 x i1> %m, ptr %o1, ptr %o2) { %c1 = fcmp ult <8 x half> %a, %b %c2 = fcmp ult <8 x half> %b, %a %d1 = and <8 x i1> %c1, %m %d2 = and <8 x i1> %c2, %m %r1 = sext <8 x i1> %d1 to <8 x i32> %r2 = sext <8 x i1> %d2 to <8 x i32> store <8 x i32> %r1, ptr %o1 store <8 x i32> %r2, ptr %o2 ret void } ``` LLVM 20.1.2 emits a single masked `vcmpnleph` for both compares, so the second one gets the first one's result. LLVM 22.1.8 emits two with swapped operands. With a `uge` pair added, LLVM 20 emits 2 compares for 4 and LLVM 22 emits 4. `GALLIUM_OVERRIDE_CPU_CAPS=avx` makes Mesa pass `-avx512f` and the other AVX-512 features to LLVM, which disables AVX512-FP16 too. The halves are then compared as floats, which is correct. It applies on every runner, so the Vulkan tests compile the same way whatever CPU the job lands on. Nothing in the recompiler or the tests changes. ### Tested - Fork CI on this branch: Linux and Windows green; the Linux `ctest` step took 27.3 s, against 23.8 s for another branch on the same day, so the AVX level costs little. - The table above: the fork CI diagnostic runs (a throwaway branch, since deleted). - Locally (CachyOS, i9-14900KF): the test passes on NVIDIA and on lavapipe (Mesa 26.2.3), and the SDE runs listed above. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!477
No description provided.