Tests: an RDNA2 wave64 reference interpreter, every wave64 form against it, and a fuzzer #3716
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3716"
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-02T19:24:54Z.
(Edited: head
de05c50e. After thehollowedone's and CharlyRien's latest reviews: v_sad_u32 wraps; the known fuzz classes now check the mismatch itself or its cause; OMOD stops until the program writes MODE; a NaN from float arithmetic is exact to the next float instruction; a gap at the start of the code stops the run; s_buffer_load masks the summed address. After the reviews of fyreic-dev, CharlyRien and Foniass: every (case, form) outcome is pinned per adapter, the fuzz counts and floors what it compares and knows mismatches by class, a panic is a failure, the float tolerance is narrowed, and the reference rules CharlyRien found wrong are fixed, each with a test. The test counts and the pinned table's size below are new; the earlier "40,000 seeds, 0 mismatches" compared almost nothing and is withdrawn.)A CPU interpreter of RDNA2 code with true wave64 semantics (
gpu::rdna2_ref, test-only), and a harness that runs each wave64 form XCL has against it. Until now every wave64 check compared a form with another form, or with our own lowering run on the CPU, so a rule that both get wrong passes. The reference is written from AMD's RDNA2 ISA guide (document 70648) and uses nothing ofrecomp/ordxil/except the runner's ABI types andrdna2's decoder. An instruction, operand or modifier it does not model stops the run; it never skips one. On a GPU with 32-lane waves it found 4 mismatches in main's forms (listed below). No translator code is changed here.This is one PR of about 5,000 lines rather than a stack of ~400-line parts, because the interpreter, its tests, the harness and the fuzzer can't be judged apart: the harness is what shows the interpreter right wherever the forms agree with each other, and two interpreter bugs were found only that way (ds_swizzle's source operand, v_bfe_i32's arithmetic shift). Each commit builds and passes on its own, one ISA area per commit.
What is in it
rdna2_ref/{mod,salu}.rs: the core (one wave of 32 or 64 lanes, VCC and EXEC as SGPR pairs, a step limit,Stop::Unsupported, a word that does not decode stops the run), grown from the 64-laneMachineof the folded-form tests in #3562; SOPP/SOPK/SOP1/SOP2/SOPC. The decoder check is in the same commit: the opcode name of one encoding of every modelled instruction againstllvm-mc --disassemblewhere llvm-mc runs, or against a listing (XCL_LLVM_DISASM); skipped otherwise, and in CI. It checks the opcode-to-name table, not field positions or semantics.valu.rs,lanes.rs: integer VALU, carries, DPP16/DPP8/SDWA, readlane/writelane/readfirstlane, mbcnt, permlane16/x16, movrel. Tests that go red when a rule is flipped (Flip): lane select modulo 32, permlanex16 on its own row, EXEC ignored, VCC read as its low half.mem.rs: SMEM, buffer/tbuffer with formats and atomics and the range checks of each OOB_SELECT mode (8.1, Table 35), global, LDS (64 KB a group), ds_swizzle/permute/bpermute within each 32-lane half (10.4.4);run_computewith groups of waves meeting ats_barrier.float.rs,image.rs: the f32 set exactly (legacy multiply, zero and NaN rules of min/max/med3, conversions, fma_mix, OMOD/CLAMP under MODE's IEEE, DX10_CLAMP and denormal bits, OMOD only once the program has written MODE; a MODE bit it does not model stops the run, as do v_fmac_legacy/v_fma_legacy until their rounding is measured). Transcendentals are tainted: rcp/rsq/sqrt with a ULP bound on their own result only, sin/cos with D3D's absolute 0.0008, exp/log not compared; a copy keeps the taint, a value computed from it is not compared, and a NaN from float arithmetic agrees with any NaN and is exact to the next float instruction. The taint does not reach addresses or control flow: a load from a tainted address, or EXEC from a compare of a tainted value, is compared exactly; no case or fuzz program does either today. Image load/store/atomics/resinfo, sample_lz/sample_l/gather4 at level 0.forms.rs: the harness (HLSL split, direct split, per-lane split; the native wave64 forms on a 64-lane GPU; on the CPU, the lowering run by its own interpreter, for whichlower::tests::run_instsis split out ofrun_mem). 15 cases, among them a 64-lane OR/AND/MIN reduction in the shape of a tile classifier over 6 groups of 16 x 16; EXEC, VCC and SCC are copied to SGPRs at the end of each kernel case.EXPECTEDpins the outcome of every (case, form) pair per adapter, 58 lines (13 for the lowering on the CPU, 45 for the split forms on NVIDIA): a match, a known mismatch from a named dword, or a refusal with its reason. Any change fails with the line it would need; on an adapter without lines (AMD, Intel) the test prints them and skips, as do the flip test and the GPU fuzz. Negative controls: each of the four flipped rules changes a compared word of its cases, and every form agrees with the reference on a case of every flip.wave64_pack_programs_the_reference_models(XCL_SAMPLE_RPF, ignored by default) counts the pack's wave64 compute programs the reference models whole.fuzz.rs: seeded random wave64 programs (if/else to depth 3, loops each lane leaves on its own pass, whole-wave sections, lane exchanges under a partial EXEC, masks as data, LDS across the waves of a group, partial waves; float inputs with signed zeros, infinities, a NaN and rounding products), a shrinker that keeps a mismatch in its class and prints the smallest program asrdna2::encodelines. CPU: 1,000 programs through the reference alone and 1,000 of what the lowering translates against its interpreter; GPU: 100 seeds in every form;XCL_FUZZ_WAVE64_SEEDSfor longer runs. Each test prints per form the seeds compared, refusals by reason and mismatches by class, and fails on a mismatch of no class infuzz.rs'sKNOWN(classes of mismatch, not seeds), a refusal not inREFUSALS, a failure, or fewer comparisons than the form's floor inMIN_COMPARED_PERCENT(lowering on the CPU 12 %, HLSL and direct split 90 %, per-lane split 10 %), all keyed by adapter.Mismatches in main's forms (RTX 2070 SUPER, the reference's value / the form's)
ds_bpermute_b32in a wave64 reads across the halves in the HLSL split form: the index is taken modulo 64, not within the lane's own 32-lane half as the ISA guide says in 10.4.4. Case "ds_swizzle, ds_bpermute and ds_permute", v11 of lane 0: 31684507 / 24204809, 44 lanes. The direct split form refuses the case (ds_permute_b32 ... atomic); with a program that has only ds_bpermute it gives the same wrong lanes as HLSL (the local check below, 3 of 8 words).s_or_saveexec_b64 -1, an identity fromv_cndmask,v_readlane32 and 63) in a wave whose upper half has no threads (a 96-thread group):v_readlane32 gives 0 instead of the identity the section wrote there. All three split forms; memory dword 128: 7 / 0, 64 dwords. Fuzz seed 1000014 shows it in HLSL and direct split.0 - xto-x;-Giskeeps it). The new generator also showsx - xof an infinity giving 0 instead of a NaN in HLSL split, likely the same cause.CharlyRien's 2,000-seed run on an RTX 3090 adds
s_mul_i32emitted as a signed multiply (HLSL split), direct split with one EXEC half empty at the start, andfma(+0, -4, +0)giving -0. None of these is fixed here; they are open for anyone to take. Only the second is a known class infuzz.rs(a whole-wave section in an if, one EXEC half empty, confirmed by the section's removal), and CharlyRien measured it as an NVIDIA driver miscompile: the same DXIL is right on WARP.s_mul_i32and his compute nested if/else group for direct split (fixed on the RTX 3090 byXCL_DXIL_NO_OPT=all, so XCL's DXIL optimiser; WARP crashes on it) are not classes, so a long run on NVIDIA still fails on them.Also seen: AMD's tables give
v_readfirstlane_b32a VOP3 form, which LLVM's gfx10 does not have (the decoder check allows that one); and VOP2 0x06 / VOP3 0x140 decode as the fusedv_fmac_legacy_f32/v_fma_legacy_f32(gfx10.3 names) where gfx10.1 has the unfused mac/mad_legacy. Which one the console has is not settled, so the reference stops on them.Tested
de05c50e:cargo test --workspace -- rdna2_ref --test-threads=4: 53 passed, 0 failed, 1 ignored (the pack census); 1 SKIPPED (no llvm-mc). Harness cases: HLSL split 13 match, 2 known mismatches; direct split 13 match, 1 known mismatch, 1 refused; per-lane split 9 match, 1 known mismatch, 5 refused; all four flips checked by all three forms. Fuzzer, 100 seeds: HLSL split 100 compared (5 known: 1 empty upper half, 1 -0, 3 a number for a NaN); direct split 100 compared (1 known); per-lane split 29 compared, 71 refused.cargo test --workspace) was not run at this head; it last ran before the reviews, on this PR's first head: 3032 passed, 0 failed, 53 ignored.cargo check -p xcl --releasewith and without--testsandcargo test -p xcl --lib --release rdna2_refat every commit (7, 17, 23, 38, 43 and 53 passed, 0 failed, commit by commit); at the head 53 passed, 0 failed, 1 ignored. CPU fuzz: the lowering compared 149 of the 1,000 default seeds (atd2293dcb, 1);XCL_FUZZ_WAVE64_SEEDS=5000: 1,535 of 10,000 compared, 12 mismatches; 9 confirmed as mismatch 4's class, and 3 reported because the lowering refuses the program without its sections, so the cause cannot be confirmed.expected Match, got Refused); made to refuse 9 of 10 fuzz seeds, both CPU fuzz tests fail ("8 of 500 seeds compared, under its floor of 12 %").-mcpu=gfx1013, wave64) throughXCL_LLVM_DISASM, after this round's changes: 823 opcode names agree.XCL_SAMPLE_RPFon a retail pack: the reference models 728 of 1,151 distinct wave64 compute programs whole.Regression run
rdna2_ref/it adds the#[cfg(test)]module line ingpu/mod.rsand splitsrun_instsout ofrun_meminsiderecomp/lower.rs's test module.Not tested
EXPECTEDhas no AMD lines;cargo test -p xcl --lib rdna2_ref -- --nocaptureon an RDNA2/3/4 card prints the per-form counts and the lines to add. The rules not measured by us rest on the ISA text and on measurements others published (DPP and permlane with a source lane off, ds_swizzle/bpermute reading 0 from a lane off, ds_permute's highest sender, readfirstlane under EXEC 0). The native wave64 forms did not run (NVIDIA has no 64-lane waves).AI use
The description check needs the maintainer's test-only waiver for this head.
Imported from ivall/xcl. Originally posted by gut0to on 2026-12-02T19:45:54Z.
Review: COMMENTED
AI-assisted review: GPT-6 helped inspect the conversion path; I verified the overflow branch.
Imported from ivall/xcl. Originally posted by gut0to on 2026-12-02T19:45:54Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/float.rs; line 73Medium:
f32_to_f16sends an input that is already infinite through the finite-overflow path. Forf32::INFINITY,log2produces an infinite exponent, so this branch returns0x7BFFwhenrtzis true; negative infinity similarly returns0xFBFF. An exactly representable infinity should remain0x7C00or0xFC00, regardless of rounding direction. Could infinities be handled before finite overflow, with tests for both signs and a finite-overflow control? AI-assisted review: GPT-6 helped inspect the conversion path; I verified the overflow branch.Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T20:19:26Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/float.rs; line 73Right, thanks: an infinite input went through the finite-overflow branch, so round-toward-zero gave 0x7BFF / 0xFBFF.
f32_to_f16now returns ±0x7C00 for infinities before the overflow test (float.rs).an_infinity_stays_infinite_in_f16_whatever_the_roundingcovers both signs in both rounding modes, plus a finite overflow (±1e6) that still stops at 0x7BFF / 0xFBFF toward zero and goes to 0x7C00 to nearest; it fails without the change (0x7BFF for +inf) and passes with it. Squashed into the f32 commit; headd2293dcb(also rebased ontomain5ad98adb).rdna2_ref: 29 passed, 0 failed, 1 ignored (CPU, under Wine).AI use: Claude Code (Claude Opus 5.5) made the fix and wrote this reply.
Imported from ivall/xcl. Originally posted by fyreic-dev on 2026-12-02T20:23:48Z.
Review: CHANGES_REQUESTED
I’d like to land the independent wave64 reference, but the harness can currently stay green when comparisons disappear. In
forms.rs, a known output mismatch can become a DXC or dispatch failure and still pass, and a previously working case can become Refused. Could we pin the expected outcome per supported case/form pair and narrow exceptions to the known wrong outputs?On CPU, fuzz_cpu only fails on Mismatch, while the runner maps interpreter panics to Refused. Please report compared versus reference-only seeds, fail on unexpected refusals and execution failures, and require actual comparisons. The float tolerance also needs a cancellation test or a narrower scope, since an input ULP bound does not carry through subtraction as the same number of output ULPs.
Once those are addressed and the f16 thread is resolved, please share an AMD run with native wave64 results and per-form counts. The description check also needs the maintainer’s test-only waiver for the revised head.
(No agent was used for my review)
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T20:43:05Z.
Review: COMMENTED
Thank you for this. A reference that does not share code with the forms is the piece that was missing, and the harness numbers reproduce here. I reviewed it at
d2293dcb, by reading the code (five reviewers, see AI use below), and spot-checked by hand every point marked as confirmed. The inline comments are the details; this is the summary.Tested here
9ceea007(itsrdna2_refdiffers fromd2293dcbonly by the f16 infinity fix):cargo test -p xcl --lib rdna2_ref -- --nocapture --test-threads=4.XCL_FUZZ_WAVE64_SEEDS=2000) was still running after 20 minutes when I posted this.Reference rules that look wrong (each can blame a correct form or let a wrong one pass)
The harness can stay green on a regression
ci.yml: Windows runner, Basic Render Driver), so the GPU forms and the "100 GPU seeds" do not run there; only the CPU part does.& 63as well (recomp/emit.rs:4697,dxil/lower_mem.rs:2272), and KNOWN lists only split forms. Not run (no AMD card here).ds_bpermute in wave64
The reference is right. The ISA guide says it in 10.4.4 (LDS lane-permute ops, p. 96): in wave64 both DS_PERMUTE and DS_BPERMUTE work on each half as two independent wave32s, and only index bits [6:2] are used. The per-instruction pseudocode in 12.13 writes
mod 64, which contradicts that paragraph, so citing 10.4.4 would avoid the confusion. Mesa ACO (aco_lower_to_hw_instr.cpp, which emulates a full-wave bpermute on gfx10-10.3) and LLVM (GCNSubtarget::supportsWaveWideBPermute(), false for gfx10/11 in wave64) agree. XCL's owndocs/wave64-on-wave32.md:43says "ds_bpermute (any lane)", which would need fixing with the forms.Where the four mismatches come from in XCL (read, not run)
recomp/emit.rs:4697-4703masks the index with 63 and reads throughxcl_x_rla_any; the direct form does the same indxil/lower_mem.rs:2270-2282anddxil/lanes.rs:746-790. ds_permute just below stays in its half.xcl_x_meet()is false (emit.rs:6667) andxcl_x_rla_uniformreturns 0 (emit.rs:6717-6722); direct indxil/lanes.rs:631-647.a - b(emit.rs:4041) compiled without-Gis, so DXC's default fast-math (no signed zeros) can rewrite e.g.x - (x + y)into-y; the direct path sets no fast-math flags, which fits it showing only in HLSL split. Recompiling seed 1000001's HLSL with-Giswould settle it.recomp/lower.rs:681-690, and as far as I can see nothing refuses an EXEC write that turns lanes back on after they left the loop, whichrecomp/lower/wave.rsassumes does not happen. Less sure of this one.What looks right (checked against LLVM and the guide): the SALU core and the saveexec family, integer VALU carries in wave64, the refusal of NEG/ABS/CLAMP/OMOD on integers, DPP16/DPP8 decoding including row_share / row_xmask, the fi / bound_ctrl rule, readlane modulo 64, mbcnt, permlane16/x16, mul_legacy / fma_legacy giving +0 on a zero, the med3 NaN rule, the gfx10 buffer format table, read2/write2/st64 offsets, the LDS atomic rules, gather4 texel order, s_barrier with ended waves, and the deterministic fuzz seeds with re-checked shrinking.
AI use: Claude Code (Claude Opus 5.5, four reviewers by area) and OpenAI Codex (GPT-6) reviewed the code; Claude Code ran the tests and wrote this review; checked and posted by me.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T20:43:05Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/salu.rs; line 299S_ABSDIFF_I32 subtracts in i64 here. The hardware subtracts in 32 bits and wraps, which is also how LLVM selects it (abs of a 32-bit sub) and how XCL emits it. For (0x80000000, 1) the reference gives 0x80000001; the ISA guide's own example in the S_ABSDIFF_I32 entry (SOP2, p. 105) gives 0x7fffffff. No test or fuzz program uses it yet, so it is latent.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T20:43:05Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/mem.rs; line 44The two low bits are dropped after base + offset + SOFFSET are added (here and at line 58). The ISA guide (7.2.1, S_LOAD_DWORD) treats the two LSBs of every address component as zero, so before the add; XCL main does that since
1a447e60, with a GPU test. With base 0x1002 and SOFFSET 2 the reference reads 0x1004 and XCL 0x1000, so the reference would blame a correct form. For S_BUFFER_LOAD (line 50/57) both sides add first, so a wrong rule there passes on both.Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T20:43:05Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/mod.rs; line 95An undecodable word is dropped from the list, and step() goes to the next decoded instruction. So straight-line execution walks over a decode error, and the second dword of an unknown 64-bit instruction can run as another instruction. It only faults as a branch target. Could you keep the gaps and stop when execution reaches one? The description says the reference never skips an instruction.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T20:43:05Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/valu.rs; line 413For V_CMP_CLASS_F16 this converts the f16 to f32, then get() (line 402) reads the low 16 bits of that f32 as an f16 again. For +1.0 (0x3C00) that gives +0. The class should also be taken on the f16 bits themselves: an f16 denormal is a normal f32, and an sNaN can become a qNaN on the way.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T20:43:05Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/float.rs; line 157With a NaN input, a - a.floor() is NaN and Rust's f32::min returns the other operand, so V_FRACT_F32(NaN) gives 0x3F7FFFFF. It should stay NaN (LLVM folds fract with minimum, which propagates it).
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T20:43:06Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/float.rs; line 181Question: this writes the f16 with bits 31:16 cleared. LLVM's GCNSubtarget::zeroesHigh16BitsOfDest lists V_CVT_F16_F32 as keeping the high half on gfx10, and XCL keeps it too. If LLVM is right, any program that packs two halves with it gets a false mismatch.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T20:43:06Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/float.rs; line 90min and max return the second operand when both are zeros of opposite sign, so MIN(-0, +0) gives +0 and MAX(+0, -0) gives -0. The pseudocode in the ISA guide (12.7, V_MIN_F32 / V_MAX_F32) has explicit cases for this: min gives -0 and max gives +0 whatever the operand order. It also quiets and returns an sNaN operand when IEEE mode is set, where this helper drops it. Could you add bit-pattern tests for both operand orders? The same probably applies to the other min/max/med3 variants.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T20:43:06Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/float.rs; line 160The ISA guide's entries for V_RCP_F32, V_RSQ_F32 and V_SQRT_F32 (12.8, p. 141-142) say denormals are flushed, whatever MODE says. With MODE 0xF0, RCP(0x00400000) gives 2^127 here instead of +inf.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T20:43:06Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/mod.rs; line 28MODE starts at 0xF0: f32 denormals kept, DX10_CLAMP = 0, IEEE = 0. Per the ISA guide: output modifiers are ignored when output denormals are enabled or IEEE is set (6.2, p. 44), so in this mode the OMOD x2 that the "exact float rules" case checks should do nothing, yet the reference and XCL both apply it and the case passes on both sides. DX10_CLAMP clear means CLAMP passes NaN through (3.5, Table 4), while the reference turns it into 0. The round, denormal and dx10_clamp bits are initialized from the program's RSRC1 (3.12, p. 23). Could MODE come from RSRC1, and could the reference stop on the MODE bits it does not read (s_setreg of IEEE, DX10_CLAMP, the f16 bits)?
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T20:43:06Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/mem.rs; line 164Bounds: the ISA guide (8.1, Range Checking, Table 35 and its notes, p. 61-62) has four OOB_SELECT modes; in mode 3 num_records is reduced by SOFFSET; DWORDX2/X3/X4 loads and stores are range-checked per component, while format loads/stores and atomics are all or nothing. The reference reads neither OOB_SELECT (word 3, bits 29:28) nor SWIZZLE_ENABLE, and checks a DWORDX2/X3/X4 access as a whole. XCL main has its own rule (no SOFFSET, per dword, emit.rs around 2172-2240), so both sides can be wrong together depending on the mode. Could the reference follow Table 35 for the modes it models and stop on the others, with a test per mode?
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T20:43:06Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/mem.rs; line 179For an 8-bit format with 4 channels at an address that is not 4-aligned, the shift reaches 32 or more: a panic in debug, a wrong byte in release. The bytes can also cross into the next dword. Also, an out-of-range format load returns W = 1 here (line 169); the ISA guide (8.1, note 1 under Table 35) returns 0, and 1 only for components whose dst_sel is SEL_1.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T20:43:06Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/tests.rs; line 452This DS_READ_B32 fills v4 and the global store uses v4 without an s_waitcnt lgkmcnt(0). The synchronous interpreter hides it, but on hardware the store needs the wait. Since these programs are meant to be compared with hardware later, it would be good to add it here and check the other memory tests for the same pattern.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T20:43:06Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/tests.rs; line 437Question: the returned values assume contending LDS atomics run in lane order. The final sum is fixed, but the old values each lane gets depend on an order I could not find stated in the ISA guide. Checking the sum, or one address per lane, would not depend on it. For DS_PERMUTE_B32 with several senders to one lane the guide is explicit: its pseudocode says the highest-numbered source wins, but the text under it says the final value is not predictable (12.13). A case should avoid that.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T20:43:06Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/tests.rs; line 121The check encodes each instruction with every field at 0 and compares the mnemonic only (line 160). Since encode and decode share one table, it proves the opcode-to-name table, not field positions, DPP/SDWA/literal variants or semantics. S_SETREG/S_GETREG are filtered out (hwreg 0). It is also always SKIPPED in CI (no llvm-mc there). The description's "826 modelled encodings agree" would read better as "826 opcode names agree".
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T20:43:06Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/forms.rs; line 706A KNOWN entry accepts any Mismatch and also Failed, so a DXC or dispatch failure, or a different mismatch in the same case and form, stays green. Refused passes for every pair, so a case that stops translating, or a form that refuses the whole suite while another one matches (matched > 0 is a total), is not seen. Could KNOWN name the expected first differing word, Failed always count as unexpected, and each available form need at least one Match?
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T20:43:06Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/forms.rs; line 221A panic in the lowering or in its interpreter is reported as Refused, so it never fails a test. The CPU fuzz (fuzz.rs:446) reports only mismatches and does not count refusals, so "40,000 seeds, 0 mismatches" does not say how many seeds were translated at all. Could panics be failures, and the fuzz print matched / refused per form?
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T20:43:06Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/forms.rs; line 727This control does not depend on the forms: with taint 0, a form that matches
rightcannot matchwrongas soon asright != wrong. So it shows that the flipped rule changes a compared word, which needs no GPU, and it is silent for a form that refuses or fails. It also uses 2 of the 4 flips (ExecIgnored and VccLow are only in tests.rs). Assertingright != wrongdirectly, for every flip, and reporting which forms were really checked, would say the same more honestly.Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T20:43:06Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/forms.rs; line 282The taint bound is applied the same way to every dword. After a cancellation (an approximate value minus 1.0, or a Newton step after V_RCP) a one-ULP input error is many ULPs at the output, which gives false mismatches; and an integer dword downstream (V_RCP then V_CVT_U32_F32) accepts 2 for 1. Also V_SIN_F32(0.5) is about 1.2e-16 in the reference and -8.7e-8 on the GPU: opposite signs, far apart in ULPs, while D3D allows an absolute error of 0.0008 for sincos. And NaNs without taint are compared bit for bit, but their bits come from the host FPU. Could tolerant checks be limited to direct float outputs with the D3D bounds (relative for rcp/rsq, absolute for sin/cos/log)?
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T20:43:06Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/forms.rs; line 44The compared registers are the static destinations. V_MOVRELD_B32 v5 with M0 = 10 writes v15 (lanes.rs:96-108); if nothing else writes v15, a form that leaves it alone passes. VCC, EXEC and SCC are also only seen indirectly. Copying such results to a fixed output in the case would close it.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T20:43:06Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/fuzz.rs; line 58LDS[t ^ k] with k below 32 never leaves the lane's own 32-lane half, nor its wave, so this block does not test "LDS across two waves" as the description says (the unit test at tests.rs:442 does). DPP, ds_swizzle and permlane are also only generated with every lane on, and the float values are small and exact: no NaN, inf, denormal or -0 reaches a form, and they are too small to tell a fused FMA from an unfused one.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T20:47:21Z.
Review of
d2293dcb(code reading only, not a merge-check;Build and test (Windows, no GPU)red,PR descriptionred) · 2 high, 1 mediumIn short: The PR adds a test-only CPU interpreter of RDNA2 wave64 code (
gpu::rdna2_ref), a harness that compares every wave64 form with it, and a fuzzer. It is 4,414 hand-written lines, none of them generated or test data. The runtime is untouched apart from a test-module split inrecomp/lower.rs. What blocks it is the size, plus known-mismatch lists that can turn the suite red on other GPUs.High
Too large to review as one PR; please split it into a stack. 4,414 lines is more than five times the ~800 lines at which CONTRIBUTING.md asks for a split. The description argues the interpreter is only shown right by the harness, but each commit already builds on its own, so a stack (
Stacked on #N) works. The commits give a natural split:asm.rs, with the llvm-mc decoder check as its own part;valu.rs,lanes.rs);mem.rs);float.rs,image.rs);run_instssplit inrecomp/lower.rs(forms.rs);fuzz.rs).Each commit is 550-930 lines, so the larger ones need halving again to get near ~400.
The known-mismatch lists come from one NVIDIA card but fail elsewhere when a mismatch is absent.
KNOWN(forms.rs~675) andKNOWN_SEEDS(fuzz.rs~466) are keyed only by case or seed and form.forms.rs~707; "known to differ, now ..." infuzz.rs~505).gpu_forms()(forms.rs~229) also runs the native wave64 forms, which the description says have never run. Thev_sub_f32-0 case has no known cause, so it may be specific to NVIDIA.Fix: key the known entries by the adapter or wave size they were seen on, or report a known mismatch that went away instead of failing.
Medium
Two CPU tests take about a minute each on every suite run.
an_instruction_outside_the_model_stops_the_run(tests.rs~107) loops onS_BRANCH -1up to the fullSTEPS = 4_000_000(mod.rs~345).modelled_instructions_decode_as_llvm_disassembles_thembuildsmodelled_words()(~112) before it checks for llvm-mc (~146-155), then only logsSKIPPED ...: no llvm-mc.Fix: pass a small step limit for the endless branch, and look for llvm-mc before building the words.
Checked and fine
rdna2_ref/, the only changes are the#[cfg(test)]module line ingpu/mod.rsand therun_instssplit out ofrun_memin the test module ofrecomp/lower.rs.run_memstill panics on a refusal, so the runtime path is untouched.runner::skip_testwhen there is no adapter or no wave64 form. The pack census readsXCL_SAMPLE_RPFand is#[ignore].Build and testcheck fails intests/frame_clock.rs, which this diff does not touch. Everyrdna2_reftest passed or was skipped in that job.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 CharlyRien on 2026-12-02T21:08:22Z.
Follow-up: a longer fuzz run on a 32-lane GPU.
Stack: RTX 3090 (driver 616.56), Ryzen 9 5950X, Windows 11 22631, rustc 1.100.0, debug, PR head
9ceea007with no local change.Command:
XCL_FUZZ_WAVE64_SEEDS=2000 cargo test -p xcl --lib rdna2_ref -- --nocaptureResult: 24 passed, 4 failed (
gpu_fuzz_wave64_0to_3), 1 ignored, 1687 s. The 8,000 seeds give 468 mismatches that are not inKNOWN_SEEDS, on 323 seeds. None of them is in the first 25 seeds of a base, so a 100-seed run cannot see them.I sorted them from the shrunk programs. I found no case where the reference is wrong. One small group is a harness issue.
s_mul_i32emitted as a signed multiplymul nswin the DXIL (new)fma(+0, -4, +0)gives -0+ 01. All 128 are compute programs with 96 threads. The first wrong dword is always in threads 64-95. This is the hand-written case already in
KNOWN. It shows up in about 6% of the seeds, so any largerXCL_FUZZ_WAVE64_SEEDSwill fail until it is fixed, or known as a class rather than by seed.2. The cause of mismatch 3 is DXC's default fast-math. Seed 833, shrunk:
v13 = v16 - v15, where v16 = (16·tid + K) & 7 is always 0. DXC compiles it tofsub fast float -0.000000e+00, %v15, that is-v15, so -0 when v15 is +0. With-Gisit staysfsub float 0.000000e+00, %v15. DXC needs to see a0 - xor(x - y) - xshape, which is why the hand-written subtraction gives +0. Smallest seed: 1242 (kernel),v13 = v15 + v16; v13 = v15 - v13with v16 = +0.3. New.
recomp/emit.rs:1703emitss_mul_i32as(uint)((int)a * (int)b). DXC turns it intomul nsw i32, so a product that wraps is poison. Seed 2001922: s8 = s0 * 0x2F5E5358 with s0 = 0x40000000 wraps to 0, ands_flbit_i32_b32 s5, s8should give -1. DXC replaces thes8 == 0test withs0 == 0, and the form gives 32. With an unsigneds0 * 0x2F5E5358uthe DXIL keeps the test on the product. The other seeds ares_max_i32,s_cmp_gt_i32ors_cmp_lg_u32on wrapped products (wrong SCC). A plaina * bon uint gives the same low 32 bits.v_mul_i32_i24(emit.rs:4077) has the same shape; the fuzzer does not generate it.4. Same root as mismatch 4, but a plain if/else is enough:
s_or_saveexec_b64turns on only the running lane's bit (recomp/lower.rs:681-690). Seed 3000238: lane 0 takes the else side, so it never runs the section in the then side, and v8 of lane 0 keeps 1 instead of the identity 0. 7 of the 19 seeds use a loop instead.5. New, direct split only. All 58 programs start with one half of EXEC empty (0x3FFFFFFF, 0x7, 0xFFFFFFFF00000000, …). Only half of the kernel programs do (3,004 of 6,026), so this is not chance. HLSL split and per-lane split agree with the reference on these seeds. I did not find the cause. Smallest, seed 2000282 (EXEC = 0x3FFFFFFF): in the else side's section, lane 0 gets the identity, as if bit 0 of the saved EXEC (s46) were 0. v17 of lane 0: reference 0x9B3E8BCD (its v4), direct split 0xFFFFFFFF.
My guess is the per-half branches or the lazy mask exchange (the local vote in dxil/idioms.rs,
skip_is_localin dxil/mask_exchange.rs). A run of this seed withXCL_WAVE64_IDIOMS=0would tell them apart. I have not run it.6. Compute programs with nested if/else and sections; the first wrong dword is mostly in thread 0. Smallest: seed 1000823. I think a half with no lane in EXEC at a branch is the trigger here too, but I did not check it.
7. Seed 1501:
fma(+0, -4, +0)is +0 in IEEE and in the reference. All three forms give -0. They emit FMad, andDisableMathRefactoringis dropped when FMad is used (dxil/prelude.rs:849-858), so the driver may drop the+ 0. Not checked further.8. Seed 1000650: a loop squares v16 until it is infinite, then computes inf - inf. The reference gives 0xFFC00000 (the x86 default NaN, which is also the NaN in AMD's ISA examples); the GPU gives 0x7FFFFFFF. D3D does not fix the bits of a NaN. The generator says floats stay small integers (fuzz.rs:5-6), but a loop of
v_mul_f32overflows, andjudgetakes two NaNs as equal only for tainted words (forms.rs:277-282). Taking any two NaNs as equal would fix it.Also seen: two seeds of group 2 shrank into a group 1 program (2001255, 1000761), because the shrinker accepts any mismatch (fuzz.rs:402-404).
Not tested: AMD and the native wave64 forms; the rebased head
d2293dcb; the exact causes of groups 5, 6 and 7.AI use: Claude Code (Claude Opus 5.5) ran the fuzz and sorted the mismatches; checked and posted by me.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:01:23Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/salu.rs; line 299Fixed in
salu.rs: S_ABSDIFF_I32 now subtracts in 32 bits and wraps (sa.wrapping_sub(sb).unsigned_abs()).salu_absdiff_pack_borrow_and_64_bit_fieldschecks the guide's example, (0x80000000, 1) gives 0x7fffffff with SCC = 1; with the old i64 subtraction it fails with 0x80000001. The same test covers s_pack_, s_subb_u32, s_cmp_u64, s_bfe64 across the dwords and s_bitset_b64.In head
66daa6c0.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:01:25Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/mem.rs; line 44Fixed in
mem.rs: S_LOAD now clears the two low bits of the base, the immediate and SOFFSET before adding them (7.2.1). For S_BUFFER_LOAD the guide's pseudocode under "Reads using Buffer Constant" adds first,addr = (m_base + offset) & ~0x3, and the reference keeps that.s_load_drops_the_low_bits_of_each_address_component_and_s_buffer_load_of_the_sumloads base 0x1002 with offsets 1 and 2 through both; it failed before the change.In head
66daa6c0.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:01:27Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/mod.rs; line 95Fixed in
mod.rs: an undecodable word stays in the program as a gap, and a run that falls through into one stops with a fault. A branch over the gap still works.execution_stops_at_a_word_that_does_not_decodeputs 0xFFFFFFFF between two moves; it failed before the change.In head
66daa6c0.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:01:29Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/valu.rs; line 413Fixed in
valu.rs: V_CMP_CLASS_F16 takes the class from the f16 bits (ABS and NEG on bit 15, then the exponent and mantissa fields), with no conversion.cmp_class_f16_classifies_the_f16_bitschecks +1.0, the denormal 0x0001, the sNaN 0x7C01, -0 and NEG +1.0.In head
66daa6c0.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:01:31Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/float.rs; line 157Fixed in
float.rs: V_FRACT_F32 of a NaN is now a NaN, as an infinity already was.fract_of_nan_is_nanchecks it.In head
66daa6c0.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:01:33Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/float.rs; line 181Decided by LLVM: GCNSubtarget::zeroesHigh16BitsOfDest has gfx10 keep the high half, and Mesa ACO's instr_is_16bit counts v_cvt_f16_f32 as a 16-bit write on GFX10+. The guide does not say.
valu.rsnow keeps bits 31:16 of the destination (under SDWA, DST_SEL decides).cvt_f16_f32_keeps_the_high_halfchecks 0xABCD0000 becoming 0xABCD3C00.In head
66daa6c0.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:01:35Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/float.rs; line 90Fixed in
float.rs, following 12.7: of two zeros V_MIN_F32 gives -0 and V_MAX_F32 +0 in either order, and with IEEE set an sNaN operand is quieted and returned. MIN3/MAX3 are built from these, and V_MED3_F32 follows its pseudocode.min_max_and_med3_order_zeros_by_sign_and_return_an_snan_in_ieee_modechecks the bit patterns in both orders, with IEEE set by s_setreg.In head
66daa6c0.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:01:37Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/float.rs; line 160Fixed in
float.rs: V_RCP_F32, V_RSQ_F32 and V_SQRT_F32 flush denormal inputs and results whatever MODE says (12.8). Inrcp_rsq_and_sqrt_flush_denormals_whatever_the_mode, RCP(0x00400000) gives +inf, RCP(2^127) 0, SQRT of a denormal 0 and RSQ of a negative denormal -inf.In head
66daa6c0.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:01:38Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/mod.rs; line 28Changed in
float.rsandmod.rs: OMOD is ignored when f32 output denormals are on or IEEE is set (6.2), and CLAMP gives 0 for a NaN only with DX10_CLAMP set (3.5, Table 4). MODE starts at 0x1F0 (f32 and f16 denormals kept, DX10_CLAMP set, IEEE clear). It stays a constant because neither the kernel ABI nor CsInterface carries an RSRC1, and XCL's forms assume one fixed mode. A float instruction stops on MODE bits above IEEE and on an f32 rounding other than to nearest, and an f16 one on a non-default f16 rounding or flushed f16 denormals. "exact float rules" now starts withs_denorm_mode 0xC(f32 denormals flushed), so its OMOD is still checked where it applies. Tests:omod_is_off_with_output_denormals_or_ieee_and_clamp_keeps_nan_without_dx10_clamp,a_float_instruction_stops_on_mode_bits_the_reference_does_not_model.In head
66daa6c0.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:01:40Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/mem.rs; line 164Changed in
mem.rs: the reference reads OOB_SELECT (word 3, bits 29:28) and follows 8.1 Table 35 and its notes. Mode 3 counts SOFFSET against num_records; dword x2/x3/x4 accesses are checked per dword; format elements and atomics are all or nothing. Mode 0 uses offset + payload > stride, which agrees with the table for aligned dwords. SWIZZLE_ENABLE stops the run.buffer_range_checks_follow_each_oob_selecthas one case per mode. XCL ignores OOB_SELECT and checks stride-0 buffers without SOFFSET, so it agrees with the reference in modes 1 and 3 only when SOFFSET is 0; that is for a separate pull request.In head
66daa6c0.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:01:42Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/mem.rs; line 179Fixed in
mem.rs: each byte of an 8-bit element is read from its own address, across dwords, and an out-of-range format load returns 0 in W (8.1, note 1). A dst_sel other than x, y, z, w still stops the run, so SEL_1 does not arise.an_8_bit_format_element_reads_its_bytes_across_dwordsloads at offset 2 (it panicked in debug before), and the OOB test checks W = 0.In head
66daa6c0.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:01:44Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/tests.rs; line 452Added in
tests.rs:s_waitcntbefore the global store in the groups test,s_waitcnt_vscntbetween the global store and the atomic on the same address, and a finals_waitcntin the memory, swizzle, image and new tests.In head
66daa6c0.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:01:46Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/tests.rs; line 437Changed in
tests.rs: DS_ADD_RTN_U32 now works on each lane's own dword, and the test checks the old value and the value read back, so lane order no longer matters. The DS_PERMUTE_B32 case informs.rsuses address 4·lane ^ 0x54, lane ^ 21 within each half: one sender per lane, so the unpredictable case in 12.13 does not arise.In head
66daa6c0.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:01:48Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/tests.rs; line 121Agreed: it proves the opcode-to-name table and nothing about field positions, variants or semantics. The description now says "823 opcode names agree with llvm-mc" (run through
XCL_LLVM_DISASMafter this round's changes; V_FMAC/FMA_LEGACY are no longer modelled) and that CI skips the check. It also looks for llvm-mc before it builds the words now.In head
66daa6c0.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:01:50Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/forms.rs; line 706Changed in
forms.rs:KNOWNis gone.EXPECTEDpins the outcome of every (case, form) pair per adapter:Match,KnownMismatch(first differing dword)orRefused(part of the reason). Failed is never expected. A different first dword, a new refusal, a refusal that now translates, or a pair with no line fails with the line it would need. Every pair that ran here has a line, so every form needs its matches. On an adapter with no lines (AMD, and so the native wave64 forms) the test prints the lines and skips.In head
66daa6c0.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:01:52Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/forms.rs; line 221Changed: a panic in the lowering or its interpreter is
Got::Failednow, which fails the test. The fuzz prints, per form, the seeds compared, refused (by reason) and mismatched (by known class), fails on a refusal not inREFUSALS, and fails when a form compares fewer seeds than its floor inMIN_COMPARED_PERCENT. You were right about the number: atd2293dcbthe lowering compared 1 of the 1,000 CPU seeds (264 compute, the rest used instructions it does not translate). The CPU part now generates programs of what the lowering translates: 149 of 1,000 compared, 0 mismatches. At 5,000 seeds a base, 1,535 of 10,000 compared and 12 mismatched, all a whole-wave section while lanes are elsewhere (mismatch 4's class).In head
66daa6c0.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:01:53Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/forms.rs; line 727Changed in
forms.rs:a_flipped_rule_changes_a_compared_word_of_its_casesasserts right != wrong on the CPU for all four flips (Lane31, PermlaneOwnRow, ExecIgnored, VccLow).gpu_every_form_is_checked_against_every_fliprequires each form to match the reference on a case of every flip, prints which forms were checked, and fails for a form that matched none of them. On the RTX 2070 SUPER all four flips were checked by all three split forms.In head
66daa6c0.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:01:55Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/forms.rs; line 282Changed in
mod.rsandforms.rs: a bound now holds only for the approximate op's own result and for bit copies of it (moves, lane reads, selects). Anything computed from it isUNBOUNDEDand not compared (counted inMatch), so an integer downstream such as V_CVT_U32_F32 after V_RCP is not compared loosely. RCP/RSQ/SQRT keep their ULP bounds; V_SIN/V_COS use D3D's absolute 0.0008; V_EXP/V_LOG are not compared. A NaN made by float arithmetic agrees with any NaN.a_cancellation_after_an_approximate_rcp_is_not_comparedgives v_rcp a 1-ULP error and checks that rcp(x)·x - 1 moves by over 2^20 ULPs and is not compared.In head
66daa6c0.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:01:57Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/forms.rs; line 44Changed in
forms.rs: every kernel case now copies EXEC, VCC and SCC to s[100:105] at its end, so they are compared as SGPRs. No case or fuzz program uses V_MOVRELD; its rule is tested in the reference's own tests (sdwa_selects_relative_moves_and_swap). A case that uses it would copy the destination to a fixed register.In head
66daa6c0.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:02:00Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/fuzz.rs; line 58Changed in
fuzz.rs: the LDS block reads LDS[(t + k) mod threads] with k below 128, so it crosses halves and waves of 64-, 96- and 128-thread groups. Lane exchanges (DPP16, DPP8, ds_swizzle, permlanex16, readlane) are also generated outside whole-wave sections, under the EXEC of the moment. Kernel programs' float inputs now include ±0, ±inf, a NaN, -1, 2^24 + 2 and 1 + 2^-12, whose square rounds differently fused and unfused. A denormal input is left out: D3D lets a GPU flush it, and on the RTX 2070 SUPER every form did; the reference's denormal rules are covered by its own tests.In head
66daa6c0.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:04:55Z.
@fyreic-dev, thanks. Points 1 to 5 are in head
66daa6c0(onmain5ad98adb), each change squashed into the commit it belongs to; 6 and 7 need someone else.KNOWNinforms.rsis gone. Informs.rs,KnownMismatchnow names the first differing dword and accepts only aMismatchthat starts there.Failedis never expected.EXPECTEDinforms.rspins every (case, form) pair per adapter asMatch,KnownMismatch(dword)orRefused(part of the reason): 13 lines for the lowering on the CPU and 45 for the three split forms on NVIDIA. Any change fails and prints the line it would need: a new refusal, a refusal that now translates, a fixed or a new mismatch, or a missing line. To check it goes red, I made the lowering refuse "permlane16 and permlanex16" for one run. The CPU test failed withexpected Match, got Refused(...).Failed. Each fuzz test prints, per form, the seeds compared, the refusals by reason and the mismatches by known class. It fails on a refusal not inREFUSALS, and when a form compares fewer seeds than its floor (MIN_COMPARED_PERCENT). You were right: atd2293dcbthe lowering compared 1 of the 1,000 CPU seeds. 264 were compute, and the rest used instructions it does not translate. The CPU part now generates programs from what the lowering translates, and compares 149 of 1,000; its floor is 12 %. When I made the lowering refuse 9 seeds in 10, the comparisons fell to 8 and 7 of 500 and both CPU fuzz tests failed with "under its floor of 12 %". On the RTX 2070 SUPER, of the 100 GPU seeds, HLSL split compared 100, direct split 100 and per-lane split 29 (71 refused). Their floors are 90 %, 90 % and 10 %. The 5 mismatches were all of known classes. Known mismatches in the fuzz are recognised by class (KNOWNinfuzz.rs), not by seed, so a longerXCL_FUZZ_WAVE64_SEEDSrun fails only on a mismatch of no class: today that includes CharlyRien's groups 3 and 6, until they are fixed.a_cancellation_after_an_approximate_rcp_is_not_comparedgives v_rcp a 1-ULP error and checks that rcp(x)·x - 1 moves by over 2^20 ULPs. The ULP bound did not hold through that subtraction, so it now holds only for the approximate result and its copies. Details are in CharlyRien's taint thread.d2293dcb, and the thread is resolved.cargo test -p xcl --lib rdna2_ref -- --nocapture? It prints per-form counts and theEXPECTEDlines for that adapter. On an adapter without lines, the forms test, the flip test and the GPU fuzz print and skip instead of failing (Foniass's point 2). Posting the printed lines would let us pin AMD.rdna2_ref/, plus the#[cfg(test)]module line and therun_instssplit inrecomp/lower.rs's test module). The description check needs the maintainer's test-only waiver for this head, which we cannot apply.Tested: RTX 2070 SUPER (driver 621.01), Windows 11 26200, debug, at
66daa6c0:cargo test --workspace -- rdna2_ref --test-threads=4gave 47 passed, 0 failed, 1 ignored and 1 SKIPPED (no llvm-mc). Linux under Wine, CPU only:cargo checkwith and without--tests, and therdna2_reftests, at every commit; at the head, 47 passed, 0 failed, 1 ignored. The whole suite was not rerun at this head.AI use: Claude Code (Claude Opus 5.5) made the changes, ran the tests and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:04:56Z.
@CharlyRien, thank you for the review and for the 2,000-seed run. Every inline point is answered in its thread, and the changes are in head
66daa6c0.Reference rules: S_ABSDIFF, S_LOAD alignment, the zero sign and sNaN in min/max/med3, RCP/RSQ/SQRT flushing, OMOD and DX10_CLAMP under MODE, buffer bounds per OOB_SELECT, W out of range, CMP_CLASS_F16, FRACT(NaN), undecodable words and the 8-bit format shift are all fixed, each with a test that fails without its fix. V_CVT_F16_F32 keeps the high half, following LLVM. V_FMAC_LEGACY / V_FMA_LEGACY now stop as unsupported until measured. The LDS atomic tests no longer depend on lane order.
Test gaps: four new tests cover the rules no test used. The values were worked out by hand from the guide, and the field encodings were checked with llvm-mc. On the scalar side: s_absdiff, s_pack, s_subb_u32, s_cmp__u64, the 64-bit bfe and bitset, s_setreg/s_getreg of MODE with s_round_mode and s_denorm_mode, s_getpc/s_setpc and s_movrels/s_movreld. On the vector side: DPP16 row and bank masks below 15, FI = 1, row_ror, SDWA selects with all three dst_unused modes, v_movrel and v_swap_b32. Only S_ABSDIFF was wrong.
Your fuzz groups:
-Gis) and 4 (per-lane whole-wave section after an if/else or a loop).s_mul_i32as a signed multiply), 5/6 (direct split with one EXEC half empty), 7 (fma(+0, -4, +0)giving -0).What the fuzzer does with them: known mismatches are recognised by class (
KNOWNinfuzz.rs), not by seed. The classes are: a group's last wave with an empty upper half; -0 for +0 (2 and 7); a whole-wave section while lanes are elsewhere (4); and a direct split kernel with one EXEC half empty (5). Groups 3 and 6 have no class, so a long run still fails on them until they are fixed. The shrinker keeps a mismatch in its class, so a group 2 seed no longer shrinks into group 1.The new generator found one more shape in 100 GPU seeds. In HLSL split,
x - xof an infinity gives 0 instead of a NaN (seeds 3000003 and 3000004). This is a guess, not checked: the cause is likely the same fast-math as group 2. It has its own class until someone checks whether-Giscovers it.ds_bpermute: the description now cites 10.4.4 for the per-half rule. On a 64-lane GPU,
EXPECTEDhas no lines yet, so the native forms' first run prints its lines and skips (the forms test, the flip test and the GPU fuzz); it does not fail.Edited: we are not working on fixes for these groups after all; they are open for anyone to take. This pull request stays the test side only.
AI use: Claude Code (Claude Opus 5.5) made the changes, ran the tests and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:04:57Z.
@Foniass, thanks. Points 2 and 3 are in head
66daa6c0.EXPECTEDinforms.rsholds the outcomes per adapter: "CPU" for the lowering's interpreter, and "NVIDIA" for the split forms seen on the RTX 2070 SUPER, whose counts CharlyRien's RTX 3090 also gave at9ceea007. The fuzz'sKNOWN,REFUSALSandMIN_COMPARED_PERCENTare keyed the same way. On an adapter with no lines (AMD, Intel), the forms test, the flip test and the GPU fuzz print the lines and counts and skip instead of failing. On a pinned adapter, a pinned case whose known mismatch goes away still fails the forms test, which is what fyreic-dev asked for.Wave::runwith a 1,000-step budget. The llvm-mc check looks for llvm-mc, a listing or a words file before it builds the words. In a debug build under Wine, the two tests took 17.8 s and 23.5 s. They now take 0.01 s and 0.00 s.AI use: Claude Code (Claude Opus 5.5) made the changes, ran the tests and wrote this reply.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T22:06:14Z.
Follow-up review of
66daa6c0, sinced2293dcb(code reading only, not a merge-check;PR descriptionred) · 1 high, 1 medium, 1 nitIn short: Since
d2293dcbthe PR was reworked, not split. It is now 5,281 hand-written lines, none generated or test data. The known-mismatch lists are now keyed by adapter, an adapter without pinned outcomes prints its results and skips, and both slow CPU tests are fixed. The size still blocks it. One new problem: on an unpinned adapter the fuzzer still shrinks every mismatch on the GPU before it skips.High
Still too large to review as one PR; please split it into a stack (still open). It grew from 4,414 to 5,281 lines, more than six times the ~800 at which CONTRIBUTING.md asks for a split. The six commits still give a natural split, as
Stacked on #NPRs:asm.rs, with the llvm-mc decoder check as its own part;valu.rs,lanes.rs);mem.rs);float.rs,image.rs);run_instssplit inrecomp/lower.rs(forms.rs);fuzz.rs).The larger commits need halving again to get near ~400.
Medium
On an unpinned adapter the fuzzer shrinks every mismatch on the GPU, then skips.
fuzz_gpu(fuzz.rs~658), an unpinned adapter getson = "", so no mismatch has aKNOWNclass.wrong(~577) then callsreport, which runsshrink(~464). Each candidate program runs through the GPU form again, and theHLSL splitform compiles it with DXC each time.skip_test. On the maintainer's AMD batch GPU,gpu_forms()returns all six forms, so each mismatch costs a full shrink in a test that ends in a skip.Fix: shrink only on a pinned adapter, and otherwise print the verdict as it is.
Nit
KNOWN; one that goes away turns the test red". The code now has per-adapterEXPECTEDtables informs.rs, and mismatch classes infuzz.rs.UNBOUNDEDand not compared, andv_exp/v_logare not compared at all (mod.rs~155-172).9ceea007b, which is not a commit of this PR.Checked and fine
EXPECTED(forms.rs~719-796). With no entry,gpu_wave64_forms_agree_with_the_reference(~855),gpu_every_form_is_checked_against_every_flip(~907) andfuzz_gpuprint their results and skip. The fuzzer'sKNOWN(fuzz.rs~512) is now a set of classes that allow a mismatch, not seeds that require one.an_instruction_outside_the_model_stops_the_runran to 4,000,000 steps. It now has a budget of 1,000 (tests.rs~152-154).modelled_instructions_decode_as_llvm_disassembles_thembuiltmodelled_words()before looking for llvm-mc. It now looks first and skips before building them (tests.rs~194-215).Wave::step(mod.rs~309-344);OOB_SELECTrange checks (mem.rs~137-171);S_ABSDIFF_I32wrapping at 32 bits;v_cvt_f16_f32keeping the high 16 bits.rdna2_ref/, the only changes are still the#[cfg(test)]module line ingpu/mod.rsand therun_instssplit inrecomp/lower.rs's test module.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 Foniass on 2026-12-02T22:16:40Z.
Follow-up review of
3de8793f, since66daa6c0(code reading only, not a merge-check;PR descriptionred) · 1 high, 1 nitIn short: This push fixes the fuzzer point from my last review: on an adapter without pinned outcomes,
reportnow prints the mismatch with its listing and does not shrink it, so the form is not run again. A test counts the runs. The other five commits are unchanged. The size still blocks it.High
asm.rs; integer VALU and lanes; memory, LDS and groups of waves; f32 and images; the harness; the fuzzer), and the larger ones need halving again to get near ~400.Nit
KNOWNturning the test red and a ULP bound on transcendentals, and Tested names9ceea007b, which is not a commit of this PR.Checked and fine
report(fuzz.rs) returns the head line and the program's listing whenonis empty.an_unpinned_adapter_reports_a_mismatch_without_running_the_form_againchecks the form ran 0 times.66daa6c0(git range-diff).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 thehollowedone on 2026-12-02T22:26:29Z.
Independent NVIDIA check of head
3de8793f, test-merged cleanly into currentmain(078358a0).git diff --checkfound no whitespace errors.On Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (driver 621.35), and the installed
llvm-mc, I rancargo test --offline --locked -p xcl --lib rdna2_ref -- --nocapture --test-threads=4: 48 passed, 0 failed, 1 ignored, 0 skip notices. The ignored test is the opt-in pack census. The decoder-name check ran and passed; the forms and four flipped-rule controls passed on this GPU. Across the four GPU fuzz tests, HLSL split and direct split each compared 100/100 seeds; per-lane split compared 29/100 and refused the remaining 71, as the test reports. The listed known mismatches remained within their pinned classes.This adds RTX 3080 Ti coverage for the current head. I did not run the full workspace suite or a title, and this is not a merge-check. The existing review about PR size and description and the red description check still need resolution.
AI use: OpenAI Codex (GPT-6 Sol) prepared and ran this test and drafted the report.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T22:29:49Z.
@Foniass, thanks for both follow-ups. Head
3de8793fis unchanged since your second one; this reply answers both.reportprints the mismatch with the unshrunk program and does not run the form again; you confirmed this. Without the change, the new test counts 81 runs of the form, and with it 0.9ceea007blines no longer name a hash: they say what ran on this PR's first head, before the reviews, and that the whole suite was not rerun.KNOWNit mentions is the one infuzz.rs: classes of mismatch, not seeds.Tested at
3de8793f:rdna2_refon the RTX 2070 SUPER gave 48 passed, 0 failed, 1 ignored and 1 SKIPPED (no llvm-mc); the 100 fuzz seeds were compared as before (HLSL and direct split 100, per-lane split 29), with only known classes of mismatch. Under Wine on the CPU: 48 passed, 0 failed, 1 ignored.AI use: Claude Code (Claude Opus 5.5) made the change, ran the tests and wrote this reply.
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-12-02T22:36:26Z.
Source follow-up on head
3de8793f. My earlier RTX 3080 Ti run passed its existing tests, but I would not call the reference and fuzzer complete yet. These are two new, independently checked points; this is a focused source review, not a merge-check.The
V_SAD_U32reference panics on a valid wraparound result.valu.rs:124addscwith ordinaryu32+. The RDNA2 ISA'sV_SAD_U32rule produces a dword result. Fora = 0xffffffff,b = 0,c = 1, that result is0; the reference instead panics withattempt to add with overflowin the debug build. A focused regression failed on the unchanged head (0 passed, 1 failed) and passed after the one-linewrapping_addchange (1 passed, 0 failed). The new fuzz generator does not emit this opcode, so its passing seeds do not cover the case.Two known-mismatch classes can hide a different bug. In
fuzz.rs:552-570,section_with_lanes_offandhalf_exec_emptyignore theVerdictand accept any mismatch whenever the program has the matching shape.wrongthen suppresses that mismatch. Two synthetic injected-verdict regressions, one for CPU lowering and one for NVIDIA direct split, each failed on this head (0 passed, 1 failed). Please classify these known differences by their observed output location and value/signature, then assert that an unrelated differing output is reported. Otherwise a new arithmetic or lane error in the same generated program shape can pass the fuzz test.Candidate `V_SAD_U32` fix and focused regression
These were local, CPU-only checks of the exact PR head. I did not rerun the full workspace suite after the candidate fix. The existing size and description review remains separate. AI use: OpenAI Codex (GPT-6 Sol) traced the paths, ran the regressions, and drafted this report.
Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T22:48:48Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/fuzz.rs; line 544This class matches any word where the reference has 0 and the form 0x80000000, not only float words. In a kernel program the SGPRs are copied to v26-v37, and
Rng::wordgives 0x80000000 one time in 20. Example: v3 has 0 in lane 32 and 0x80000000 in lane 0, and the program doesv_readlane_b32 s5, v3, 32. A form that reads lane 0 (the Lane31 mistake) gives the first mismatch("v27 of lane 0", 0, 0x80000000), which counts as known on all three forms, and the seed's other wrong words are hidden with it. Floats only live in v13-v16 in these programs (fv(), andv()stops at v12), so the class could require the label to be v13-v16 in a kernel, or memory dword k with k % 28 in 12..=15 in compute.nan_as_zero(line 548) could take the same guard.Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T22:48:48Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/fuzz.rs; line 567With the EXEC choices at lines 409-415 (cases 2 and 3, and case 1 with a shift of 32 or more), about half of all kernel programs start with an empty half, so this entry accepts every direct-split mismatch on half of the kernel corpus. On the 3090 the bug is in the driver (summary above): the HLSL repro needs a dead
ifbefore the section and the section's readlane + groupshared exchange inside anif. Could the class require that shape, for example anItem::Waveinside anItem::Ifin a kernel with an empty half, and say in its text that it is a driver issue? Then a new direct-split bug in those programs would still show.Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T22:48:48Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/fuzz.rs; line 525Two classes from my fuzz comment are not here.
s_mul_i32as(uint)((int)a * (int)b)(recomp/emit.rs:1703, unchanged) gave 15 of my 8,000 HLSL-split seeds at9ceea007; and the compute nested if/else class of direct split (my group 6, 11 seeds) is not covered byhalf_exec_empty, which requires a kernel. SoXCL_FUZZ_WAVE64_SEEDS=2000on NVIDIA should still fail, while the description says "this pull request pins each as a known class". Either add the two classes or change that sentence. Thes_mul_i32fix itself is one line (multiply as uint) and belongs in a separate pull request.Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T22:48:48Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/mod.rs; line 356A NaN from float arithmetic gets taint
NAN, but the next float op that reads it getscomputed(NAN)=UNBOUNDED, so it is not compared at all. Example with v4 = 0x7FC00000 (one of the newFLOAT_EDGES):v_add_f32 v5, v4, v4givesNAN(checked: must be a NaN), thenv_mul_f32 v6, v5, 1.0givesUNBOUNDED, so a form that writes 0 to v6 is judged a match. NaN in, NaN out is fixed for add/mul/fma, and min/max/cmp of a NaN are exact. Could a float op treat aNANinput like an exact one (NaN result:NAN, other result: 0), and keepUNBOUNDEDfor integer ops that read NaN bits?Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T22:48:48Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/mod.rs; line 29With MODE 0x1F0 the reference ignores OMOD (f32 output denormals on), and XCL always applies it (
recomp/emit.rs:3166-3171, whatever MODE says). A compiler only emits OMOD when f32 denormals are flushed and IEEE is off (LLVMSIFoldOperands,isOMod/tryFoldOMod), so a real program with OMOD and no MODE write ran with output denormals off, and the reference would blame XCL for it. Example:v_add_f32 v10, v4, 0 mul:2with v4 = 1.5 and nos_denorm_mode: reference 1.5, XCL 3.0. No case or fuzz program hits this today ("exact float rules" setss_denorm_mode 0xC), but real programs would once they are compared. Since MODE at the start is an assumption, could a nonzero OMOD stop the run until the program has set the denormal mode itself?Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T22:48:48Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/mem.rs; line 57For S_BUFFER_LOAD the reply quotes
addr = (m_base + offset) & ~0x3, but the code readsbase + ((OFFSET + SOFFSET) & ~3)andloaddrops the low bits of that, which is(base & ~3) + ((OFFSET + SOFFSET) & ~3). With base 0x1002, OFFSET 0 and SOFFSET 2, the quoted rule reads 0x1004 and the code 0x1000. The test (base 0x1002, offset 2 + 2) gives 0x1004 both ways. Bases of S_BUFFER V#s are normally aligned, so this is minor;((base + off) & ~3) + 4 * kwould match the quote.Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T22:48:48Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/mod.rs; line 96The new fall-through check catches a gap after an instruction, but not one at offset 0: execution starts at
list[0]whatever its pc. Code[0xFFFFFFFF, s_mov_b32 s2, 1, s_endpgm]runs the move and ends normally. Checking thatlist[0].pc == 0(or faulting when it is not) would close it.Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T22:48:48Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/mem.rs; line 9Taint does not reach addresses or control flow: a global, buffer or LDS load takes the taint of the memory it reads, not of its address, and EXEC and SCC carry no taint. So after
v_rcp_f32 v3, v2andv_cvt_u32_f32 v4, v3(UNBOUNDED),global_load_dword v5, v4, s[...]gives v5 taint 0 and it is compared exactly, although a GPU within the bound can round v4 to the other integer and read another address. The same goes for av_cmpof a tainted value that feedss_and_saveexec. Nothing in the cases or the fuzz does this today. Either propagate the address taint to the loaded value (and a compare's taint to EXEC), or narrow the description's "anything computed from it is not compared".Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-02T22:48:48Z.
Review: COMMENTED
Thanks for the quick and thorough round. I read
3de8793f(base main5ad98adb) against each of my 20 comments: every fix is there, every test you cite exists and checks the rule in question, so all 20 threads can be resolved (GitHub does not let me resolve them here). I have not built or run this head yet; a 2,000-seed run on the RTX 3090 (driver 616.56) is queued. From the code, two classes from my fuzz comment are not infuzz.rs'sKNOWNand will fail a long run on NVIDIA:s_mul_i32emitted as a signed multiply (HLSL split; the description says each is pinned) and the compute nested if/else class of direct split (my group 6). Since that comment I measured group 5 further (RTX 3090, driver 616.56,d2293dcbplus env-gated local probes, WARP 1.0.23 with Agility SDK 1.621.0 as a second adapter): the shrunk program rewritten as plain HLSL and compiled by DXC (cs_6_6,-O3) is wrong on the 3090 and right on WARP from the same DXIL, so it looks like an NVIDIA driver miscompile, not XCL. Group 6 is a different thing:XCL_DXIL_NO_OPT=allfixes it on the 3090, and WARP crashes on those dispatches, so it is still open. The comments below are new and mostly about the new fuzz classes and the taint rules; the first two can hide real wave64 bugs.AI use: Claude Code (Claude Opus 5.5) checked the fixes and wrote this review; checked and posted by me.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T23:36:11Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/fuzz.rs; line 544Right: the class now also requires the word to be a float register.
float_wordinfuzz.rsaccepts v13-v16 in a kernel, and memory dword k with k % 28 in 12..=15 in compute.nan_as_zerotakes the same guard.a_float_class_holds_only_for_a_float_registerchecks that "v13 of lane 0" and dword 40 are accepted and that "v27 of lane 0" and dword 44 are not.In head
de05c50e.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T23:36:13Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/fuzz.rs; line 567Changed in
fuzz.rs.half_exec_emptynow requires a kernel with an empty EXEC half and a whole-wave section inside anif. It also requires the cause: with the program's sections taken out, the form must agree with the reference (sections_cause_it). A new direct-split bug in those programs is therefore reported. The class's text says it is the driver ("right on WARP"), from your measurement; the description says the same.In head
de05c50e.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T23:36:15Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/fuzz.rs; line 525I corrected the description instead of adding them as classes. Neither has a signature that would not hide other mismatches:
s_mul_i32is in every compute program's prologue, and group 6 has no narrow shape yet. The description now says that a long run on NVIDIA still fails on both, and records yourXCL_DXIL_NO_OPT=alland WARP results for group 6. Thes_mul_i32fix belongs in a separate pull request, as you say; this one stays on the test side.In head
de05c50e.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T23:36:16Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/mod.rs; line 356Changed in
mod.rs: a float instruction (or a float compare) now reads aNANinput as exact, so its result getsNANagain if it is a NaN and 0 if not. An integer instruction that reads the bits still getsUNBOUNDED. Your example isa_nan_from_float_arithmetic_is_exact_to_the_next_float_instruction: v_add of a NaN givesNAN, v_mul of that givesNAN, v_cvt_u32 of it gives 0 and v_and of it givesUNBOUNDED. It failed before the change.In head
de05c50e.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T23:36:18Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/mod.rs; line 29Agreed. A nonzero OMOD now stops the run until the program has written MODE (s_setreg, s_denorm_mode or s_round_mode), since the start value is an assumption (
float.rs,Wave::mode_set).omod_under_the_assumed_mode_stops_the_runis your v_add_f32 with mul:2 and no MODE write; it failed before. The two float tests that check OMOD under denormals now writes_denorm_mode 0xFfirst, and "exact float rules" already starts withs_denorm_mode 0xC.In head
de05c50e.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T23:36:20Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/mem.rs; line 57Fixed in
mem.rs: S_BUFFER_LOAD now reads((base + offset) & ~3) + 4 * k, as the quoted rule says. The test adds your case, base 0x1002 with OFFSET 0 and SOFFSET 2, which now reads 0x1004. It read 0x1000 before the change.In head
de05c50e.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T23:36:22Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/mod.rs; line 96Fixed in
mod.rs: a run whose first decoded instruction is not at offset 0 stops with a fault.execution_stops_at_a_word_that_does_not_decodenow also runs[0xFFFFFFFF, s_mov_b32 s2, 1, s_endpgm], which ran to the end before.In head
de05c50e.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T23:36:24Z.
Code review location:
crates/xcl/src/gpu/rdna2_ref/mem.rs; line 9I narrowed the description rather than propagating the taint. Nothing in the cases or the fuzz loads through a tainted address or branches on a tainted compare today. The description now says the taint does not reach addresses or control flow, and that such a load, or EXEC from such a compare, is compared exactly. If a case ever needs it, propagating the address's taint to the loaded value is the first step.
In head
de05c50e.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T23:36:28Z.
@thehollowedone, thank you; both points were right and are fixed in head
de05c50e.V_SAD_U32. I took your one-line fix: the add ofcnow wraps (valu.rs). The test issad_u32_wraps_at_the_dwordintests.rs. It runs v_sad_u32 with 0xffffffff, 0 and 1 and expects 0. It panicked with "attempt to add with overflow" in a debug build before the change and passes after it. It is credited to you in this reply. I checked the other VALU, SALU and lane rules for an unchecked+or*on 32-bit values. The others wrap, widen to i64/u64 first, or work on addresses in u64, so this was the only one.Classes that hid other mismatches.
section_with_lanes_offandhalf_exec_empty(fuzz.rs) now also require the cause. The form must agree with the reference once the program's whole-wave sections are taken out; a mismatch that stays without them is reported. The test isa_known_class_holds_only_for_the_mismatch_its_shape_causes. It finds a lowered program of the section shape and injects two fake verdicts. One differs only when the program has a section, and is still known. The other always differs in one word, and is reported bywrong. With the old shape-only class, the second fake verdict was accepted and the test failed. I don't run the forms a second time for the other classes: they check the first differing dword itself (its thread range, or -0 for +0 and a number for a NaN). After CharlyRien's comment in the same round, that dword must also be one of the float registers.One cost: with
XCL_FUZZ_WAVE64_SEEDS=5000, 3 of the 12 lowering mismatches are no longer classified (seeds 1646, 1002359, 1004544). Without its sections, each of those programs is refused by the lowering, so the cause cannot be confirmed and they are reported. The default 1,000 seeds have none.Tested at
de05c50e:rdna2_refon the RTX 2070 SUPER gave 53 passed, 0 failed, 1 ignored and 1 SKIPPED (no llvm-mc); every fuzz mismatch was of a known class. Under Wine on the CPU: 53 passed, 0 failed, 1 ignored. Each commit builds and passes on its own.AI use: Claude Code (Claude Opus 5.5) checked both points, made the changes, ran the tests and wrote this reply.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T23:37:20Z.
Follow-up review of
de05c50e, since3de8793f(code reading only, not a merge-check) · 1 highIn short: This push fixes several interpreter details:
v_sad_u32wraps at the dword;Each has a test, and the description now describes the current
KNOWNclasses and taint rules. The size still blocks it.High
asm.rs; integer VALU and lanes; memory, LDS and groups of waves; f32 and images; the harness; the fuzzer. The larger ones need halving again to get near ~400.Checked and fine
KNOWNholds classes of mismatch keyed by adapter, the taint of transcendentals is described as it is implemented, and the stale9ceea007bis gone.V_SAD_U32useswrapping_add(c), andsad_u32_wraps_at_the_dwordchecks a sum pastu32::MAX.((addr + off) & !3) + 4k. The test adds anS_BUFFER_LOAD_DWORDwithOFFSET0, and corrects the expected-value comment.Stop::Fault, with a test.mode_setis set by every MODE write.outputrefuses OMOD until then.taint_of(.., nan_exact)treatsNANtaint as exact only for float instructions and f32 compares.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.