Tests: wave32 forms are compared with the RDNA2 reference #3746
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3746"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-03T00:12:29Z.
Stacked on #3716; only the top commit belongs here.
#3716 compares XCL's wave64 forms with the RDNA2 reference. This adds the wave32 forms: a wave32 program translated with one console lane to one GPU lane (HLSL, direct DXIL, per-lane), the form most shaders take on a 32-lane GPU, compared with the reference running 32-lane waves. Test-only; no translator code is changed.
What is in it
rdna2_ref/forms.rs: a case carries its wave size; the three GPU forms translate a wave32 program with wave64 off, and the lowering on the CPU runs it at 32 lanes. 13 wave32 cases: the 8 wave64 cases whose masks need no change, 4 of wave32's own rules (lane selects of v_readlane / v_writelane modulo 32, ballots and lane counts in one SGPR, saveexec / wrexec on 32-bit masks, a scalar written in a wave32 branch), and a whole-wave section in a 48-thread group. Every (case, form) outcome is pinned inEXPECTED(12 CPU lines, 39 NVIDIA lines).rdna2_ref/fuzz.rs: the generator writes wave32 programs (its mask instructions as_B32, groups of 48, 64 and 96 threads), run through the wave32 forms with their own floors, refusals and known classes. Every known class that names a cause reruns the program without that cause and requires a match. The wave64 programs are unchanged.Flip::LaneClamp(lane selects clamped instead of wrapped). The flip checks also run over the wave32 forms and cases (LaneClamp,PermlaneOwnRow,ExecIgnored).Mismatches in main's wave32 forms (pinned as known, not fixed)
s_or_saveexec_b32 -1) in a group's last wave with lanes 16..31 empty: those lanes read 0, not the identity the section wrote. All three forms; the same as #3716's mismatch 2 for wave64.v_sub_f32(fuzz seed 1000001), as in HLSL split.s_cmp_eq_u32compares twos_mul_i32products of s0 that overflowed (seed 1000015, shrunk). The class holds only when the program matches both without itss_cmps and with s0 = 1, where no product overflows. Likely the signed multiply found on #3716 (the compiler may assume no overflow).ds_bpermute, which reads across the halves in the split forms, matches in all wave32 forms that translate it.Tested
fa03c332:cargo test --workspace -- rdna2_ref --test-threads=4: 63 passed, 0 failed, 1 ignored; 1 SKIPPED (no llvm-mc).cargo test -p xcl --lib rdna2_ref: 63 passed, 0 failed, 1 ignored; 11 SKIPPED (10 no GPU, 1 no llvm-mc). Lowering on the CPU at 32 lanes: 162 of 1,000 seeds compared, 3 mismatches (class 4).the_compare_class_…,the_empty_lanes_class_…,a_wave32_program_with_every_lane_on_…).Not tested
EXPECTED), the RTX 5070 Ti, the whole suite.AI use
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T00:17:57Z.
Review of
386053dd(code reading only, not a merge-check; draft) · 1 high, 4 mediumIn short: Stacked on #3716; this reviews only the top commit
386053dd(+346/-68 inrdna2_ref/forms.rsandfuzz.rs, test-only). #3716's split request applies to the stack. The wave32 cases are right: lane selects wrap modulo 32, masks sit in one SGPR, saveexec and wrexec work on 32-bit masks, and the reference runs 32-lane waves for them. Outcomes are keyed by adapter, so other GPUs print their results and skip instead of going red. What blocks it: one known fuzz class excuses every scalar mismatch of a compute program on HLSL wave32, and two other classes are wider at 32 lanes than the cause they name.High
group_scalarexcuses every scalar mismatch of a compute program on HLSL wave32.fuzz.rs~597, registered at ~586) matches any mismatch whose first differing dword is atk % 28 >= 16, which is s4..s15 of any thread in any compute program. It never looks at the program.s_mul_i32products of s0 that overflow, so "from s_mul_i32 products" is always true. The description says the cause is not confirmed.Fix: confirm the cause the way
section_with_lanes_offdoes withsections_cause_it(rerun without the overflowing multiplies or thes_cmpand require a match), or narrow the class to the shrunk shape from seed 1000015. Add a test likea_known_class_holds_only_for_the_mismatch_its_shape_causesfor it.Medium
section_shapetreats every wave32 kernel program as having lanes off.partial(fuzz.rs~631) testsp.exec != !0. A wave32 program'sexecisexec >> 16 & 0xFFFF_FFFF, so it is never!0. A program with a top-level whole-wave section and any if or loop then takes the "lanes are elsewhere" class onlowering on CPU wave32even with all 32 lanes on. Compare with the full mask forp.lanes.upper_half_emptyat 32 lanes excuses any mismatch in the last wave of a 48-thread group. The class (~589) checks only that the first differing dword belongs to thread 32..47, not that the program has the whole-wave section the class names. With 48 one of the three wave32 group sizes, a third of the threads of those programs are excused in all three wave32 forms, including the LDS and barrier paths a partial wave takes. Require the shape too, as the other section classes do.No flip check covers the wave32 forms or the modulo-32 rule.
gpu_every_form_is_checked_against_every_flip(forms.rs~1074) runs only overgpu_forms()andcases().Flip::Lane31does nothing at 32 lanes (lanes.rs~54), and neither doesFlip::VccLow(mod.rs~221). So "lane selects wrap at 32" is never shown to depend on its rule.Fix: add a wave32 lane-select flip with a
FLIPSentry, and run the flip checks overgpu_wave32_forms()andwave32_cases()as well.The per-lane wave32 floor is far below what it compares.
MIN_COMPARED_PERCENThas("NVIDIA", "per-lane wave32", 10)(fuzz.rs~532), but the description reports 17 of 50 seeds compared (34 %). A change that makes the form refuse two thirds of what it compares today still passes. Set the floor near the measured rate, with a margin.Checked and fine
referencepassescase.lanes == 64torun_kernelandrun_compute, which buildWave::new(32). Masks are read and written as one SGPR, andkernel_words,labeland the taint loop all go overcase.lanes.v_readlane/v_writelanelane selects with& (w.lanes - 1), andds_bpermutewraps with& 31. Saveexec and wrexec at 32 lanes refuse a_B64op and mask to 32 bits.v_readfirstlaneunder EXEC0xFF00.WAVE64_ONLYuse_B64mask ops,v_mbcnt_hiors127. The 8 kept cases use one-SGPR carries and VCC reads only._B64mask instructions are all inWAVE32_MASK_OPS, and wave32 programs never emitv_mbcnt_hiors127.EXPECTEDandKNOWNare keyed by adapter. Outside "CPU" and "NVIDIA",forms_agreeandfuzz_gpuprint and skip, so AMD, Intel and WARP do not go red. A known class that does not occur fails nothing.ON_CPUhas 12 wave32 lines andON_NVIDIAhas 39 (13 cases × 3 forms). No translator code is changed.Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-03T00:54:27Z.
All five points are fixed in
fa03c332, which replaces386053dd(still one commit on #3716'sde05c50e). On the RTX 2070 SUPER (driver 621.01, debug),cargo test --workspace -- rdna2_ref --test-threads=4gave 63 passed, 0 failed, 1 ignored. Under Wine on the CPU,cargo test -p xcl --lib rdna2_refgave the same 63 / 0 / 1.group_scalar: replaced byoverflowed_compare(fuzz.rs~600). It still requires a scalar dword of a compute program, and then two reruns that must both match: the program with everys_cmptaken out, and the same case with s0 = 1, where nos_mul_i32product overflows. Seed 1000015 still falls in it on the GPU. The new testthe_compare_class_holds_only_for_a_mismatch_the_compare_and_overflow_causegives the class a form that is wrong only when it has ans_cmpand s0 overflows, which must be known, and a form that is always wrong, which must not be. With the old class the second form was known, and the test failed.section_shape:partialnow comparesexecwith!0 >> (64 - p.lanes). The testa_wave32_program_with_every_lane_on_has_no_lanes_elsewherefailed with!0.upper_half_empty: now also requiressections_cause_itat both wave sizes. The testthe_empty_lanes_class_holds_only_for_a_mismatch_the_section_causesfailed without it. On the GPU, all 4 mismatches that fell in this class before still do (2 HLSL wave32, 2 direct wave32), and so does 1 of each in HLSL split and direct split.Flip::LaneClamp(lane selects clamped to the last lane instead of wrapping).FLIPSnow carries a wave size, with three wave32 entries:LaneClampon "lane selects wrap at 32", plusPermlaneOwnRowandExecIgnoredon their cases.gpu_every_wave32_form_is_checked_against_every_flipruns the check overgpu_wave32_forms()andwave32_cases(). On the GPU, all three wave32 forms are checked against all three flips. With clamping made the reference's own rule, "lane selects wrap at 32" fails inthe_wave32_lowering_on_the_cpu_agrees_with_the_reference(s10), and so do both CPU wave32 fuzz tests.per-lane wave32is now 20 %. The floor applies to each 25-seed test, and on the GPU those compared 6 of 25 (24 %) and 11 of 25 (44 %), so a floor near the 34 % pooled rate would fail the first test today.AI use: Claude Code (Claude Opus 5.5) made these changes, ran the tests and wrote this reply.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T00:56:44Z.
Follow-up review of
fa03c332, since386053dd(code reading only, not a merge-check; draft) · no new findingsIn short: This push answers all five points from my last review. The HLSL wave32 scalar class now confirms its cause by running the program again. The two section classes are narrowed to their shape. Wave32 has its own flip checks, including a lane-clamp flip for the modulo-32 rule. The per-lane floor is raised. Only the top commit belongs here, and #3716's commits under it are unchanged. Nothing in this commit blocks it; #3716's split request applies to the stack.
Checked and fine
group_scalarexcused every scalar mismatch.overflowed_compare(fuzz.rs) now requires a mismatch in s4..s15 that goes away both with everys_cmpremoved and with s0 = 1, where nos_mul_i32product overflows.the_compare_class_holds_only_for_a_mismatch_the_compare_and_overflow_causechecks it holds for a fake form that differs only with both, and not for one that always differs.section_shapesaw lanes off in every wave32 program.partialnow compares with!0 >> (64 - p.lanes), which is0xFFFF_FFFFat 32 lanes.upper_half_emptyexcused any mismatch in a 48-thread group's last wave. It now also requiressections_cause_it(p, form).FLIPScarries a wave size, andgpu_every_wave32_form_is_checked_against_every_fliprunsFlip::LaneClampon "lane selects wrap at 32", plusPermlaneOwnRowandExecIgnoredon the kept wave32 cases. The wave64 test runs only the 64-lane entries.without(items, drop)is shared by the section and compare checks, so the section check works as before.Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.