sampler_source_census: fix V#/pointer/SMEM/v_mov dataflow and harden JSON I/O (SAMPLER-SOURCE-CENSUS-DATAFLOW-AND-IO) #1530
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1530"
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 ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T03:37:35Z.
What changed
tools/sampler_source_census.py:one_load_source): collect[source(t, seen) for t in base]and check agreement on the source origin ({g[0] for g in got}) while combiningany(g[1])andmax(g[2]), instead of requiring all four dwords to have identical(where, dyn, k)tuples. Previously, adding a static or dynamic offset to word 0 of a user V# dropped it toundetermined(V# from different sources).tools/sampler_source_census.py:one_load_source): recognize 3-tuple unary-folded zero constants (("const", 0, op)froms_not_b32/s_brev_b32) as a zero high word, and propagatedyn/kfrom a user high word instead of ignoring them.offset:IMMmodifier tracking (tools/sampler_source_census.py:analyse,one_load_source,one_load): parseoffset:Nfromins["mods"]so combinedsOFF offset:IMMloads countIMMinmax_pointer_constant(dynamic) andmax_static_offset(constant SGPR +offset:IMM).tools/sampler_source_census.py:step): do not treatv_mov_b32_sdwa,v_mov_b32_dpp, instructions with modifiers (clamp, etc.), or register operands withneg/abs/sextas lossless spill copies.tools/sampler_source_census.py:anchored,blocks_of,analyse,census): convert invalid hex inanchored()intohic.Skipinstead of crashing withValueError, handle empty instruction lists cleanly inblocks_of([])/analyse([], ...), and validate positive non-bool integers forlimitandjobsincensus().--jsonguards, atomic write, andOSErrorhandling (tools/sampler_source_census.py:main): refuse--jsontargeting a folder,index.json, anything insidedisasm, or any.dxbc/fssm/*.fssm/.sinput (viareport_paths.same_report_pathandos.path.samestatfor hardlinks); catchOSErrorfromcensus()with exit code 2; write--jsonatomically through a sibling temp file withfile_mode.published_mode,replace_retry.replace,allow_nan=False, and explicitnewline="\n".tests/test_sampler_source_census.py): added 7 synthetic unit/CLI regression tests covering every fix above.Claimed in the coordination issue as:
SAMPLER-SOURCE-CENSUS-DATAFLOW-AND-IO(https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7152027644)How it was tested
python3 -I -W error tests/test_sampler_source_census.py: 37/37 passed (0 warnings).python3 -I tests/test_text_write_line_endings.py: 3/3 passed.python3 -I scripts/check_no_game_data.py tools/sampler_source_census.py tests/test_sampler_source_census.py: passed.python3 -m compileall -q tools/sampler_source_census.py tests/test_sampler_source_census.py: passed.main:tools/sampler_source_census.py: all 7 new tests fail (FAILED (failures=6, errors=1)), all 30 baseline tests pass.Metadata
Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T03:37:50Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Imported from ubiquitarianism/leonida. Originally posted by klikso on 2026-11-25T17:40:32Z.
Ran on a real corpus, since the description's tests are synthetic: my own 1.0.2.1, the 26,503 listings that
make_game.pydisassembles (<work>/shaders/dxbc/disasm, llvm-mc 23.1.6,main3d4f66123), Windows 11, Python 3.13.python -I tools/sampler_source_census.py <work>/shaders/dxbc/disasm --json census.json --jobs 3, once withmainfe1553456's tool and once with this branch'stools/sampler_source_census.pyon the same tree.mainhas no commit to that file since this branch's base, so only the change differs.user_pointer, 174,796literal, 0user_sgprs, 0other_baseand 2,420undetermined.docs/d3d12_vulkan.md's SHADER-735 table, so this copy reproduces the published census as well.v_mov) moves an instruction between classes on 1.0.2.1, and the 0other_baseconclusion the doc draws from this tool holds with the branch too. The fixes guard cases this corpus doesn't have.main, 14 min 47 s with the branch (one run each,--jobs 3).python -I tests/test_sampler_source_census.pywith the branch's file: OK.Counts only; the listings and the JSON stay on my machine.
AI-assisted: yes (Claude Code; run on the machine above)
Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-28T11:26:48Z.
#1530 | head
a9413ce4d64cbf438cb92e60ca45323141aa0f8e|python3 -I tests/test_sampler_source_census.py -v| red: 37 run, 7 failures, 1 error | green: 37 run, 1 failure | Still failing after merge (same assertion on untouched main)One assertion remains red on the merged tree: SamplerSourceCensus.test_statistics_bound_what_the_classes_cannot_decide expects two user_pointer samples and gets one. The same assertion fails on untouched main (1 failure / 30 tests). The unmerged PR head passes 37/37. A repeat of the exact merge again fails 1/37. As a diagnostic control, restoring just tools/heap_index_census.py from the PR head on a disposable copy of the merge makes all 37 pass. Main commit
581283eedchanged how s_lshlK_add treats its first source as a scaled index and the second as a base. The second synthetic shader in this test puts the user value in the shifted source. The official merged result above uses the unmodified merge.Copied the PR tests onto clean main
4a54aedcb6b66525e0c9f72a6ea10263337c9141for the baseline, then merged that main into the recorded PR head and reran those files. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Unittest failure/error counts include subtests where applicable. AI-assisted with OpenAI Codex. Batch claim.Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-28T11:43:00Z.
Thanks @IlyassRS3! This PR passes on its own head, but after merging current main one assertion in
tests/test_sampler_source_census.pystill fails (one user-pointer sample where the test expects two), because main has since changed the heap-index census helper this census relies on (sodove's report above isolates it). Could you update it against current main? It will be merged once that test is green.AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.
Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T14:17:49Z.
Ready for testing: merges cleanly with
main3535eb5c4. Not inmainyet:git cherryfinds 1 commit(s) not there, and 12 of the 193 lines it adds are already present. No duplicate found: its claimSAMPLER-SOURCE-CENSUS-DATAFLOW-AND-IOappears in no other open pull request and in nomaincommit.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-11-29T15:40:59Z.
Independent run of #1530 (python -I, no build, no game; GPU not used).
a9413ce4d691bab934d7(PR merged into it locally withgit merge --no-ff, clean; onlytools/sampler_source_census.pyandtests/test_sampler_source_census.pytouched)Commands (one process each, from the repo root):
python -I tests/test_sampler_source_census.py, plustest_ci_registration.py,test_check_no_game_data.py,test_text_write_line_endings.py,test_tool_stdout_encoding.py,test_docs_repo_paths.py.tools/sampler_source_census.pyreverted to the pre-PR version (the file is unchanged on main since the PR's base) and the PR's test file kept: FAILED (failures=6, errors=1, 37 tests). Behaviour red, not a build/API one: the fix tests fail on an assertion (pointer high word reported undetermined instead of user pointer; SMEM inst_offset not counted in bounds, 0 != 0x7f004000; v_mov with SDWA/DPP/neg modifier treated as a lossless spill; V# with per-dword offset reported as different sources; invalid limit/jobs not rejected with ValueError; JSON guard / atomic write / OSError exit code 0 instead of 2), and one IndexError on an anchored invalid-hex / empty-block input.b1a3e93fd, which merges cleanly.)Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T18:31:12Z.
Tested
a9413ce4dmerged (no commit) withmain4755667f5: Python 3.12, Windows 11 10.0.26300, CPU only. Ran the PR's tests plus every test file that imports the changed tool.python -I tests/test_sampler_source_census.pygives 37 OK.tools/sampler_source_census.pyback tomain:FAILED (failures=6, errors=1).8db8335d2).AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T18:36:59Z.
Merging. Red/green verified on
a9413ce4dagainst currentmainby an agent other than the author (verdicts above), no conflict withmain, does not force a rebase of #2566, claim ID present. Main CI reds are pre-existing (translator-testsmesh,semantic-testsf16), not from this change. Merged by MoonEyes.AI-assisted (Claude Code).