Scripts: harden gen_rdna2 CLI argument handling and output option #1494
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1504"
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 heditrigui on 2026-11-24T17:02:46Z.
Harden
scripts/gen_rdna2.pyCLI argument parsing, error diagnostics, and output path configuration:Tested
Not tested
AI use
Antigravity (Gemini 3.8 Flash (High)) designed the CLI argument handling and optional output destination, implemented unit tests in scripts/test_gen_rdna2.py, ran the test suite, and verified PR conventions.
Imported from ivall/xcl. Originally posted by nnonno91 on 2026-11-24T17:10:02Z.
Independent Windows check of
3608a7aa744bf5d9b8ce9413d58b639ee1e6fc39using the full AMD RDNA 2 XML.Tested
amdgpu_isa_rdna2.xml(release 2026-02-20, schema 1.1.1, SHA-256d671ecbc36543674ab59e9b2feffd56718fd2137e7ad913c314f2e2508b9f4f7), I ranpython -I scripts/gen_rdna2.py <xml> <output>on baseb7aa9f3bd212088e0d927439284dc5ed325ce3c7and the PR. The PR’s custom output used a new directory and a filename with spaces. I also ranpython -I <copied-script> <xml>from outside its temporary project tree to exercise the default output.git hash-object --no-filtersmatched the trackedrdna2_spec.rsblobe91c5c623da8ad154be57e17cc1e884d8d77b090. AMD GPUOpen XML sourcepython -B -m unittest discover -s scripts -p 'test_*.py' -vpassed all 26 tests.cargo build --workspace --lockedandcargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-outputpassed with 770 passed, 0 failed, 41 ignored, and noSKIPPEDGPU lines. The bundled title test passed.Not tested
Retail titles, release builds, and other operating systems.
AI use
OpenAI Codex (GPT-6 family, exact variant unavailable) ran the checks and drafted this report.
Imported from ivall/xcl. Originally posted by gut0to on 2026-11-24T18:52:42Z.
Review: COMMENTED
The focused script tests are useful. CONTRIBUTING.md also requires the full workspace GPU suite for each PR, with pass/fail/ignored counts and skipped-test names; this description reports only the Python tests. Please add the full-suite result before merge. AI-assisted review; I checked the Tested section against the guide.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T18:53:43Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
Imported from ivall/xcl. Originally posted by RavenCurseBurg on 2026-11-25T17:06:08Z.
On
3608a7aa744bf5d9b8ce9413d58b639ee1e6fc39,python -I scripts/gen_rdna2.py input.xml out.rsrejected a UTF-16 ISA file that the parent accepted. I encoded the same synthetic ISA (including a non-ASCII copyright character) as UTF-8, UTF-8 with BOM, UTF-16LE with BOM and UTF-16BE with BOM. The parent generated identical Rust for all four. This head succeeded for the UTF-8 files and exited 1 for both UTF-16 files before writing output.Fix and regression test. The CLI passes the path to ElementTree so the XML reader can honor the encoding. The new CLI test failed on the original head and passed with the fix. All four encodings then produced the same 1,808 bytes as the parent (SHA-256
40a6cef572f2521a7ba78ef84a382f942699f853b98fe18c4c1abcae743f18e2). All 27 Python tests passed withpython -B -m unittest discover -s scripts -p "test_*.py".Windows 11 26100.9711, i7-13700, RTX 4060, Python 3.14.3. Synthetic ISA only in this check; no full AMD XML, Rust build, GPU or retail run. OpenAI Codex (GPT-6) wrote the patch and ran the checks.
Follow-up on the review at
3608a7aa744b. Tested candidate cbdc8a4a2. Removing onlyS_BRANCH’sInstructionEncodingsfrom the PR’s XML fixture reproduced the successful incomplete output. The candidate returned 1, namedS_BRANCHandInstructionEncodings, and preserved the previous output bytes. The complete fixture still passed. All 27 script tests passed.Command on the candidate:
python -B -m unittest discover -s scripts -p "test_*.py". Windows 11 build 26100, Core i7-13700, Python 3.14.3. OpenAI Codex (GPT-6) prepared the patch and ran the tests with synthetic inputs. I did not run the full Rust/GPU suite.Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T09:56:59Z.
Review: COMMENTED
On
3608a7a, the new optionalInstructionEncodingshandling can silently drop an instruction from generated output. I copied this PR's own synthetic XML fixture, removed onlyS_BRANCH'sInstructionEncodingselement, and ran the generator against a preseeded output sentinel. The unmodified fixture emits three instructions. With the one-element mutation, this head exited 0 and replaced the output with a two-instruction table missingS_BRANCH; the PR base and current main exited 1 and preserved the sentinel. A structurally absent encoding table is malformed input, so success here can publish an incomplete generated table.Could the parser require
InstructionEncodingsfor each instruction before writing output, with an error naming that instruction? A regression using the mutated synthetic fixture and an existing output sentinel would cover both the exit status and preservation of the prior file. This was an exact-head Python-only differential, not a full SDK regeneration or GPU run.Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-12-01T02:33:56Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:57:18Z.
Triage (#1607) – head
3608a7aNo open or merged PR makes the same change. #2612 (reject non-RDNA2 input) and #2674 (strip whitespace in instruction flags) touch the same script for other reasons and will conflict with this refactor.
Points in the diff: scripts/gen_rdna2.py:generate now treats a missing MicrocodeFormat/BitLayout/Operands/InstructionFlags as empty and still writes a table, so a malformed spec yields a silently incomplete rdna2_spec.rs instead of an error, which is the opposite of the hardening the title describes. Reading the XML as text and calling ET.fromstring (instead of ET.parse on the file) also stops honouring the file's declared encoding and fails on a UTF-8 BOM.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.