Proposal: shader PRs state where instruction semantics come from (hardware or cited source), plus a hardware oracle tool #843
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-06T08:57:32Z.
@boykopovar a proposal for CONTRIBUTING, before I open a PR for it.
Problem
Shader PRs keep implementing instruction semantics from the ISA text or by analogy with a sibling op, and the result looks plausible but is wrong. Today alone:
s_setkill 0into a no-op ands_setkill 1(pluss_sethalt/s_sendmsghalt) into a per-invocationOpKill. On hardware,s_setkillends the wave for any immediate, ands_sethalt 1freezes it.v_interp_*as a multiply then an add. The hardware does a single rounding (straight to f16 for p2), and the PR matched only 101 of 2560 targeted rows. The rework fixes that, but invalid operations still give the wrong NaN.Both authors fixed their PRs within hours once they had measured data. Without it, review is guesswork: the ISA manual has been wrong more than once (#264:
v_div_scale_f32threshold,v_div_fmas_f32post-scale), and local drivers hide differences (RADV vs lavapipe vs NVIDIA).Proposal
tools/hw-oracle/, so anyone with an AMD RDNA2/RDNA3 GPU on Linux can measure an instruction in minutes. I'd send it as a separate PR if you agree with the idea.How I've been using it
I've used it for my shader PRs since 2026-10-03, on a laptop iGPU (Radeon 660M, RDNA2 gfx1035: same VALU/SALU/DS/MUBUF encodings as the PS5's gfx1013, apart from a few gfx10.1-only ops).
/dev/kfd(no root, no ROCm install: the runtime packages are extracted locally); a kernel template; arun.shthat assembles withclang -mcpu=gfx1035+ld.lld; a Pythonrun(body, rows)helper.tests/execution/test as expected values, so the test pins what the hardware does rather than what the code does.main, where the oracle disagreed with the existing translation. For example,s_buffer_loadoffset wrap (#604),v_permlane16with inactive sources (#606),s_setpc_b64arithmetic (#607), and SOPP branches per lane instead of per wave (#608). It also settled the cases the docs leave open: f16/f32 NaN rules, omod and clamp interplay, D16/format rounding, LDS atomics, f64 division steps.v_interp_*were measured this way, with M0 = 0 and the parameters written to LDS by hand. Ops that don't exist on gfx1035 (v_mul_lo_i32was removed in gfx10.3,s_dcache_discard) need gfx1013 or another source. Contributors without an AMD GPU can still cite sources under rule 1, or ask someone with one to measure.Happy to adapt the wording, or to drop the tool part if you'd rather not have it in the repo.
Imported from boykopovar/AnyPS5. Originally posted by ebosido444-ai on 2026-10-06T10:10:02Z.
Backing this as the author of several of today's shader and tooling PRs — rule 1 is worth adopting, and it is cheap: my PR bodies already carry exact sources (ISA section,
amdgpu_isa_rdna2.xml, LLVM/ACO files) plus explicit throw-lines for what the sources do not settle, and that structure visibly improved review. It would have caught a provenance error of mine exactly: I leaned on PPSSPP's PSP date-parser behaviour as evidence, and oneandonlydean's review pointed out that another console's HLE choice proves nothing about PS5libSceRtc. "Exact source" discipline generalises to "source from the right platform," and the rule makes that visible. Marking unverified bits in TechnicalDebt is the honest half I like most — it converts guessing from a hidden liability into a declared one.Small precision for the record, scoped to attested states (claims-reference-attested-states is worth folding into the rule's wording): the no-op/
OpKillprofile belongs to #771's iterations. #821's first pushed form decoded immediate0x02toS_ENDPGMand threwSUnsupportedOperationExceptionon the hiddenSSetkillCodeoperand for every other immediate; its landed form runs theSetkillCodearray in executabletests/for any immediate. Those forms, the quoted review states, and the PR bodies as first posted and as edited contain no-op/OpKillnowhere — but the branch's intermediate states were force-pushed away and the orphaned objects are gone, so a transient state resembling the #771 profile cannot be disproven retroactively. What your measurements then confirmed — any immediate ends the wave,s_sethaltfreezes — settled the ambiguities I had conservatively left throwing, which is itself an argument for the rule: had the bodies declared "unverified on hardware" up front, the contested cases would have been legible sooner.Two endorsements from the workflow side: pinning hardware-captured rows as expected values in
tests/execution/is the strongest part of the design — it turns the tests into silicon-anchored contracts rather than self-consistency checks. And the rule needs no GPU at all (I cannot run the oracle on my NVIDIA box, and citation-based compliance is what I do today). Happy to be the first test-bed of the CONTRIBUTING wording against my open PRs, or to read a draft — whatever is useful.Imported from boykopovar/AnyPS5. Originally posted by guimsolutions on 2026-10-06T11:33:01Z.
This proposal is directly relevant to a gfx1013/AGC ambiguity we have
currently reduced to a minimal case.
We have an exact serialized graphics request where:
The remaining unknown is not the arithmetic semantics of V_INTERP itself,
but the physical source of parameter-cache slot 0.
Would the proposed hw-oracle be extensible to a minimal graphics/raster
probe, rather than compute-only?
Specifically, it would be useful to test:
and read the resulting fragment value.
A gfx1013/Cyan Skillfish test would be ideal, but even knowing whether
the existing oracle infrastructure can submit a small graphics pipeline
would help.
We have exact register state, shader hashes and a sanitized reference
packet available.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-06T11:55:18Z.
The tool is now up as a draft, #871, so the idea can be judged on the code. A short summary of what it is:
oracle.c(~165 lines) loads a raw code object through the ROCm HSA runtime and dispatches it on/dev/kfd. No root needed, and only the HSA runtime from ROCm (any distro's package or/opt/rocm).template.swraps a few lines of assembly under test. Each lane gets 4 input dwords inv4-v7, andv10-v25are stored back. It works in wave32 or wave64, with 4 KiB of LDS and the FLOAT_MODE (IEEE, f32/f16 denormals) chosen per run.hw_oracle.pyassembles the body for the GPU it finds (clang+ld.lld), runs any number of rows, and returns or prints the outputs. Usage and limits are indocs/dev/HW_ORACLE.md.It stays a draft until you decide on #843. If you'd rather not have it in the repo, I'll close it, and rule 1 stands on its own.
@ebosido444-ai thanks. Agreed on "source from the right platform": I'll fold that into the rule's wording.
@guimsolutions it can't do that, unfortunately: it only dispatches compute kernels. The
v_interp_*measurements worked because in a compute wave the interp ops read their parameters from LDS atM0, so I wrote P0/P10/P20 there by hand. That checks the arithmetic, not where the values come from. Your question is the part it can't reach: what a PS reads in parameter slot 0 when the NGG stage ran withNO_PC_EXPORT=1and exported no param. Answering it needs a real graphics pipeline (NGG + PS,SPI_PS_INPUT_CNTL, rasterization). That is a different tool: driving PM4 directly through amdgpu/libdrm, or a Vulkan pipeline on RADV with hand-written ISA. It also needs to run on gfx1013 itself. My GPU is gfx1035, and the parameter-cache path is exactly the kind of thing that can change between gfx10.1 and gfx10.3. I don't plan to build that. If someone with a raster probe and a gfx1013 board (BC-250 / Cyan Skillfish) runs your sanitized packet, the result would be very useful to post here.Imported from boykopovar/AnyPS5. Originally posted by boykopovar on 2026-10-06T16:50:18Z.
I completely agree, it's a good idea, including the tool.
Imported from boykopovar/AnyPS5. Originally posted by queeeef on 2026-10-06T17:40:00Z.
+1 from the #697 side, the hardware rows were what made that PR correct. For the record, #697 is now up to date: b93e8f6 gives invalid operations 0xffc00000 / 0xfe00 with the measured NaN priority, and all six rows from your comment match. The oracle would also help people like me without an AMD GPU see the gap before review rather than after.
Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-06T20:30:47Z.
I have the oracle from #871 running on a Ryzen 5 7600X iGPU (Raphael, gfx1036, RDNA2): Fedora 44, distro
rocm-runtime7.1.1, clang/lld 22, noHSA_OVERRIDE_GFX_VERSIONneeded. If someone without an AMD GPU needs an instruction measured, tag me with the body and rows and I'll post the output. The same machine has an RTX 5070 Ti, so I can also run theagc_drivertests on NVIDIA and RADV side by side for a PR.Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-06T23:26:57Z.
Checked
main: both halves of this look implemented.docs/dev/HW_ORACLE.mdandtools/hw-oracle/are in the tree.CONTRIBUTING.mdnow requires shader PRs to say whether semantics come from hardware or a cited source, and links the oracle doc.Can this be closed, or is it still tracking something (e.g. the execution-test rows still to be pinned)? Not sure whether it is meant to stay open as the umbrella for the audit, so asking rather than assuming.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:26:13Z.
Both parts are on main: the hardware oracle (#871,
tools/hw-oracle/) and the CONTRIBUTING rule (#951). Closing; reopen if you want this to track the audit.