Repository navigation
tests: wave reductions and lane-spilled masks under --wave64-emulate, and the emulated CPU model runs the LDS min/max/sub atomics (TEST-W64-EMU-WAVE-REDUCE) - #1381
Open
milk4sale wants to merge 1 commit into
Conversation
…(TEST-W64-EMU-WAVE-REDUCE) run_emulated_workgroup, the CPU model that runs --wave64-emulate output on all 64 lanes, executed only the OR, add, AND, XOR and exchange atomics: a program with ds_min_u32 stopped at "unsupported op OpAtomicUMin". It now runs OpAtomicUMin, UMax, SMin, SMax and ISub, in a branch of its own below the existing one. tests/semantic/test_wave64_emulate_wave_reduce.py uses it for two sequences a compiler emits for a wave64 and that need both 32-lane halves to agree: - a reduction over the wave (EXEC widened, the identity for lanes that were off, four DPP steps per 16-lane row, v_permlanex16_b32, v_readlane_b32 of lanes 0 and 63) that the first active lane alone commits with ds_or_b32 or ds_min_u32; a ds_add_u32 counter shows exactly one lane ran each commit - a 64-bit lane mask kept in two lanes of a VGPR with v_writelane_b32 and read back with v_readlane_b32 after its SGPRs were reused - ds_min_u32, ds_max_u32, ds_min_i32, ds_max_i32 and ds_sub_u32 from all 64 lanes of one wave Each program is translated without and with --wave64-emulate and run on 64 lanes, natively and emulated; both must match a plain-Python reference in every lane. The translator is right for all of it: this is coverage. Four planted translator faults each fail the new file and pass again when removed: LDS atomics not ordered before a later LDS read, v_readlane_b32 selecting lane & 31 in a wave64, v_permlanex16_b32 reading its own row half, a parked mask reloaded by a lane shuffle. Without the interpreter change the reduction test stops at the NotImplementedError above. scripts/run_semantic_tests.py tests/semantic: 475 files, 6199 tests, 0 files failed. AI-assisted. No game files. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Contributor
|
Reviewed aad0d61: coverage-only change (emulated interpreter + new wave64-emulate semantic test). Ran the new file, AI-assisted review. Recommendation: Merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claimed in the coordination issue as: TEST-W64-EMU-WAVE-REDUCE (#14 (comment))
What and why
run_emulated_workgroupintests/semantic/test_wave64_emulate_opt.pyis the CPU model that runs--wave64-emulateoutput on all 64 lanes of a workgroup. It executed only the OR, add, AND, XOR and exchange atomics. A wave64 program withds_min_u32stopped atNotImplementedError: unsupported op OpAtomicUMin, so nothing that uses the LDS min, max or subtract instructions could be checked under emulation on the CPU. It now also runsOpAtomicUMin,UMax,SMin,SMaxandISub. The new branch sits below the existing one, so it does not touch the lines that the open pull requests on this function change (#1110 and #850).tests/semantic/test_wave64_emulate_wave_reduce.py(new, hand-written, made-up values) uses it for two sequences a compiler emits for a wave64, which under emulation only come out right when the two 32-lane halves agree on every scalar:s_or_saveexec_b64 ..., -1, lanes that were off get the identity throughv_cndmask_b32, four DPP steps reduce each 16-lane row (quad_perm[1,0,3,2] and [2,3,0,1],row_half_mirror,row_mirror),v_permlanex16_b32joins the two rows of each half,v_readlane_b32of lane 0 is folded into every lane andv_readlane_b32of lane 63 is then the wave's result. EXEC is narrowed to the first lane that was on (s_ff1_i32_b64,s_lshl_b64 ..., 1, sN,s_and_b64 execors_and_saveexec_b64) and that lane doesds_or_b32for an OR andds_min_u32for an unsigned MIN. A counter raised byds_add_u32beside each commit shows that exactly one lane ran it, which an idempotent OR or MIN would hide. Seven EXEC ranges: both halves, the whole wave, each half alone, one lane in the high half, lane 0 alone, and the two lanes either side of the half boundary.v_writelane_b32of each half of the pair, the SGPRs reused for another mask and for numbers,v_readlane_b32back, thens_mov_b64 execandv_cndmask_b32on the reloaded pair. Six cases.ds_min_u32,ds_max_u32,ds_min_i32,ds_max_i32andds_sub_u32, from all 64 lanes of one wave, with lane values that tell signed from unsigned.Each program is translated twice, without and with
--wave64-emulate, and run on 64 lanes: natively byspirv_mini_interp.run_workgroupas one 64-wide subgroup, emulated byrun_emulated_workgroup. Both must give every lane the words of a plain-Python reference.The translator turns out to be right for both sequences and for the five atomics, natively and emulated: this pull request is coverage, not a fix.
Tested
python -I tests/semantic/test_wave64_emulate_wave_reduce.py: 5 tests pass (Python 3.14, Linux), onmain28a32e190plus this commit.NotImplementedError: unsupported op OpAtomicUMinin the emulated run.x_memory_order(and its mirror inwave64_emulate_opt.py), so no order barrier before a later LDS read: 14 subtests fail, in the reduction test and the atomics test;v_readlane_b32selecting lane & 31 in a wave64: 20 subtests of the reduction test fail;v_permlanex16_b32reading its own row half: 20 subtests of the reduction test fail;python -I scripts/run_semantic_tests.py tests/semantic: 475 files, 6,199 tests, 0 files failed.test_wave64_emulate_opt.py(rdna2spirv: wave64 emulation resets shared words with OpAtomicStore (SHADER-W64-SINK-RACE-CARRY) #1110 and rdna2spirv: 64-bit buffer addresses without Int64, so shaders run without shaderInt64 (SHADER-423) #850 with a line offset, shader: omit native subgroup votes for dead scalar conditions #1272, wave64_emulate_opt: flow-sensitive must-be-zero proof in _exec_writes_stay_inactive #793 and wave64_emulate_opt: ds_append and ds_consume always barrier under --wave64-emulate #106 without), and the five new tests also pass on the head of rdna2spirv: a lane mask read as a number is the wave's mask word (SHADER-MASK-AS-DATA) #1043 (68b964e42), which changes how a lane mask is read as a number.python -m compileall -q make_game.py tools tests,python -I make_game.py --help,python -I scripts/check_no_game_data.pyon both files,python -I tests/test_text_write_line_endings.py,git diff --check.python -I tests/test_ci_registration.pyfails here as it does onmainwithout this commit, ontests/semantic/test_sub_co_same_operand.py(tests: the CI registration scan counts the tests a TestCase inherits from a class of its module (TEST-CI-REG-LOCAL-MIXIN) #1365 has the fix).translator-testsis red onmainfor another reason that tests: the pytest helper takes a text-only sample's lines as its listing, as run_gpu_tests.py does (TEST-TRANSLATE-TEXT-ONLY) #1375 addresses. Neither comes from this change.Not run: Python 3.12 (the version CI installs), Windows and macOS. No GPU run: the programs run in the two CPU interpreters only, and no GPU fixture is added.
GPUs tested: n/a (two Python test files; no shader, fixture or runtime code)
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (No translator change.)🤖 Generated with Claude Code