Skip to content

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

Merged
boykopovar merged 1 commit into
boykopovar:mainfrom
oneandonlydean:ci/lavapipe-avx-caps
Oct 3, 2026
Merged

boykopovar merged 1 commit into
boykopovar:mainfrom
oneandonlydean:ci/lavapipe-avx-caps

Conversation

@oneandonlydean

Copy link
Copy Markdown
Collaborator

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

agc_driver_vopc_compare failed on every Linux runner with an
AVX512-FP16 Xeon (Sapphire, Emerald and Granite Rapids) and passed on
AMD EPYC and Ice Lake runners. Ubuntu 24.04's lavapipe compiles with
LLVM 20.1.2, which on these CPUs merges a masked fcmp ult/uge on half
vectors with the same compare of swapped operands, so v_cmp_nle_f16,
v_cmp_nlt_f16 and v_cmpx_nle_f16 return the result of their mirror.
The recompiler's SPIR-V is the same on every device and correct.

GALLIUM_OVERRIDE_CPU_CAPS=avx keeps LLVM off AVX-512, so every runner
compiles the tests the same way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants