Repository navigation
compute: carry descriptor spills through v_writelane_b32 / v_readlane_b32 - #3161
Conversation
…_b32 Titles spill buffer descriptors, table pointers and unknown entry SGPRs to fixed lanes of a VGPR and read them back with v_readlane_b32 at the same constant lane. The analysis now keeps the scalar symbol per VGPR and guest lane: a symbolic v_writelane_b32 emits nothing, and the matching v_readlane_b32 restores the symbol in the destination SGPR. A write to another lane keeps the other lanes; a CFG join with a different symbol, a VGPR lane index, any other read of that VGPR, or any other write to it is refused. Numeric spills are lowered as before. native_lane_spill_descriptor_hardware spills a buffer descriptor to lanes 0..3 next to numeric lanes, clobbers the SGPRs, refills them and loads through the descriptor; five controls cover the refusals. Closes R0Y00#3150. AI-assisted.
dfaaa11 to
9a8c347
Compare
|
LGTM. The refactoring of |
pigalot
left a comment
There was a problem hiding this comment.
I reviewed 9a8c3478 merged over main 2b7ebf18. The merge is clean (tree ce82c8af) and git diff --cached --check is clean.
What I traced.
- Analysis: with a constant lane,
v_writelane_b32records a non-numeric, non-indexed, definition-free SGPR symbol under (VGPR, guest lane) and emits nothing. Any other source erases that key.v_readlane_b32of the same key restores the symbol into its SGPR. At a join, a key whose symbol differs, or is present on only one side, becomesnullopt, and a later readlane of it is refused. Both join orders are handled: thereset()loop covers keys present inin, and theemplace(..., nullopt)loop covers keys present only inafter. - Emitter guard:
read()andwrite()refuse any VGPR access to a register whose before-state holds a spill key. The one exception is the lane write itself (lane_write).read_storageis used only by the readlane/writelane lowering andwrite_active. Every VGPR store goes throughwrite(), soclear_vector_spillsis a second line of defence, not the guard. That matches the PR's note on its third mutation. - Operand helper:
constant32moved to file scope with the same nine float words, andoperand()now uses it. The emitted constants are unchanged. - Scope of the new transfer: it runs only when
parseis called withgraphand notgraphics. The only such caller is thedirect_dxilcompute path.
What I ran. I built compile_dxil native_store_replay in dev and release, then ran
python .agentic\scripts\with_gpu_lock.py ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^(native_lane_spill_descriptor|native_lane_access|native_dpp[a-z0-9_]*|native_gather[a-z0-9_]*)_hardware$'
ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^(native_lane_spill_descriptor_warp|native_direct_container)$'dev: 8/8 hardware tests pass.native_lane_spill_descriptor_hardwarematched all 192 descriptor-spill and numeric-spill words and the guards.release: the new test,native_lane_access_hardwareandnative_direct_containerpass.- Skips:
native_lane_spill_descriptor_warpskips (77) in both presets, so the five compile controls ran but the WARP readback didn't. - Negative control: on
main2dde49a8, compiling the fixture's positive program refuses it at+0x38: unbound numeric SGPR s32, the first descriptor spill.
Mutants. I rebuilt compile_dxil native_store_replay in dev for each, then ran the new test (WARP for the compile controls, hardware for the readback):
| Mutant | Result |
|---|---|
join keeps a conflicting symbol (drop the !(other->second == value) term) |
killed (join control compiles) |
read() symbolic-lane refusal removed |
killed (valu) |
write() symbolic-lane refusal removed |
killed (overwrite) |
SGPR-lane has_spill refusal removed |
killed (sgpr_selector) |
| transfer refills from the next lane | killed (hardware readback) |
one-sided join key not added (emplace(..., nullopt) removed) |
survives |
numeric v_writelane_b32 does not erase the key |
survives |
identity_spill also carries indexed_descriptor |
survives |
the refill also emits the physical waveReadLaneAt |
survives (equivalent here: descriptor uses go through the symbol) |
Restored and rebuilt afterwards; git diff --quiet is clean.
I then compiled four extra programs built from the test's own helpers.
- One-sided joins: one path spills the descriptor to lanes 0..3 and the other writes numeric values there or writes nothing, in both branch orders. All four are refused on this head with
symbolic VGPR lane read has conflicting incoming values. Under the one-sided-join mutant three of them are still refused, later, asunproven resource descriptor s32, so that mutant moves the refusal but doesn't produce wrong code here. - Numeric overwrite: a program that spills the descriptor, then writes numeric values to the same four lanes, then refills, is refused on this head (
unproven resource descriptor s32). Under the no-erase mutant it compiles, restoring the overwritten descriptor.
Non-blocking. "A write to the same lane replaces it" is implemented correctly, but no test pins it. A sixth control in native_lane_spill_descriptor_check.py would kill that mutant: a numeric v_writelane_b32 over a symbolic lane, followed by the refill and the load, expected to be refused. The indexed-descriptor exclusion is likewise unpinned.
Verdict: approve on 9a8c3478.
Environment: NVIDIA GeForce RTX 5090 driver 610.88, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Windows SDK 10.0.28000.0 DXC, Python 3.12.10, wave32, debug layer off. WARP variant skipped (77).
CI: Build and test on Windows passes on 9a8c3478.
This reply was AI-assisted.
Fixes #3150. Part of #2935. Target branch
main. Follows #2940 (#2950), which lowered numeric SGPR spills through VGPR lanes.Change (
src/gfx1013_compute_native.cpp,src/gfx1013_direct_compute.inl):v_writelane_b32with a constant lane and a non-numeric scalar source records the source symbol and emits nothing. That covers a descriptor dword, a table or root address, and an unbound value.v_readlane_b32of the same VGPR and constant lane restores the symbol in its destination SGPR and emits nothing.constant32moves fromDirectComputeto file scope so the analysis can use it.native_store_replaygains a--direct-warpmode for the WARP variant of the new test. This touches the same device-creation lines as tests: honor hardware adapter selection in native Compute replay #3155; I will rebase on whichever lands first.Tests. The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, on
main80668b97plus this commit.native_lane_spill_descriptor_hardware(new) passed.v_readlane_b32and load through the refilled descriptor.compile_dxilrefuses five controls:native_lane_spill_descriptor_warpskips (77) on this machine.native_lane_access_hardware,native_wave_request_hardware,native_direct_container, thenative_dpp*tests and thenative_gather*tests pass, 16 tests in all, two of them WARP skips.Measured on a local capture (counts and instruction shape only) with
compile_dxil --jobs 8 gfx1013-direct-cs@36 --requestsonmain80668b97.41 of 2,689 compute requests stopped first at a
v_writelane_b32with "unbound numeric SGPR". With this change, 40 of them pass every spill and stop later:s_or_saveexec_b32image_sample_lzon a 3D image, sampler at s88 (5) or s104 (1)v_permlanex16_b32The last one stops at a
v_fma_f32with an unbound SGPR source.The compiled count stays at 403, and no request that compiled before stops compiling. The requests of one start-up run give the same result: 416 before and after, and the same 41.
AI-assisted.