Repository navigation
compute: lower root-UAV global DWORD stores in the direct path - #3333
Conversation
Leyukaka
left a comment
There was a problem hiding this comment.
Reviewed e519c57e by its diff. The lowering of the four store widths, the EXEC write mask, the signed 12-bit offset and the refusals (no saddr, lds, flat/scratch, sub-DWORD, atomics) look correct. Three test gaps, a rebase point and a scope note:
- Multi-DWORD wrap guard is not exercised. In the store test the only guarded access is a single-DWORD store and load at vaddr
0xfffffff4offset 16; the widewraploads innative_global_load_check.pyall have their first DWORD out of range. Soconst int last_offset = offset;(dropping(count - 1) * 4, diff:284) would pass. Fix: an x4 (or x2) access whose first DWORD passes the guard and whose last would wrap; confirm it fails with the guard narrowed. - No in-range value is read through
u0. The only UAV load is the guarded one, stored toLOAD_SLOTand compared to 0; in-range loads are only checked through the root SRV. For example the load's handle classunsigned(uav)(diff:279) is not checked by a readback. Fix: after the stores ands_waitcnt,global_load_dworda DWORD a lane stored and store it to a free slot. - UAV register allocation. Each program has one binding, so
const unsigned reg = analysis.srv++;(diff:272) still yieldsu0. Fix: a fixture with a root SRV and a root UAV, expectingt0andu0. - Rebase.
mainaddedpacked_d16_x_uavandindexed_raw_srvafterfloat3_texture_uav, anddecode()'s bound is nowindexed_raw_srv(src/direct_compute_cache.cpp:138).root_buffer_uavhas to go after them, the bound has to follow, and the names list needspacked_d16_x_uavandindexed_raw_srvadded beforeroot_buffer_uav, otherwise kind 25 prints asroot_buffer_uavand 27 asunknown. - Scope. The compute manifest and the native dispatch path have no case for
root_buffer_uav(as forroot_buffer_srv), so programs that reach it move to aUAV kind root_buffer_uavrefusal rather than run. Worth stating in the body that this is translation only.
Request changes for 1-4.
e519c57 to
22e7405
Compare
|
@Leyukaka Thanks for the review. All three test gaps are covered now, and the branch is rebased onto current main (head
Windows test PC (RTX 4070 Ti plus WARP), AI-Assisted |
Leyukaka
left a comment
There was a problem hiding this comment.
Re-reviewed at a910514a (rebased onto 8ecd30fe) by git range-diff against e519c57e. This replaces my earlier review.
Fixed: 2 (after s_mov_b32 exec_lo, -1 and s_waitcnt, each lane reloads the DWORD at 48N through u0 and stores it to 6400+4N; the UAV load is no longer readonly), 3 (the SRV(t0), SRV(t1), UAV(u0) program must report t0 root=0, t1 root=1, u0 root=2), 4 (enum order, decode bound and names list, src/direct_compute_cache.cpp:138, :897) and 5 (scope stated in docs/experiments/native-direct-global-store.md).
Point 1 is only partly fixed. The x4 store at offset 16 is there, but wide_wrap_bound() searches the whole dxc -dumpbin text for 4294967267|-29|4294967268|-28. X4_BASE = 0xffffffe4 is 4294967268, which is -28 as an i32, one of the accepted values. The v_add_nc_u32 v24, 0xffffffe4, v24 that builds the address is emitted as an add with that constant, so the dump can match on the address add whatever bound the guard compares against, and const int last_offset = offset; may still pass. This is by reading, not measured.
Fix: match only the compare line (for example icmp ule i32 %\S+, -29 or icmp ult i32 %\S+, -28), or use a base that is not an accepted value; add add i32 %a, -28 to the samples that must not match; and post the matching dump line for the head and for the last_offset = offset mutant.
Small: with ule the mutant's bound is 2^32-1-16 = 4294967279, i.e. -17; -16 is its ult form. The comments and the doc say -16.
git merge-tree --write-tree onto origin/main 212d4b5f: clean.
a910514 to
2da1cc4
Compare
Leyukaka
left a comment
There was a problem hiding this comment.
Head 2da1cc4c, rebased onto main 77d1ba4d. Diff and source reading only, nothing built or run.
git range-diff against a910514a: commits 2-4 are unchanged, commit 1 differs only by the rebase over heap_typed_srv (root_buffer_uav stays last in the enum, the decode bound and the names list, src/direct_compute_cache.cpp:138, :900-901). 2da1cc4c is new (doc and test, +21/-10).
Point 1 is fixed in the code. wide_wrap_bound() (tests/native_global_store_check.py:145-153) now matches only icmp ule i32 %x, -29 or icmp ult i32 %x, -28 (or their unsigned spellings). The samples that must not match (:261-262) include add i32 %a, -28, icmp ule i32 %a, -17, icmp ult i32 %a, -16 and the bare constants. By reading: the guard is emitted as ule against 0xffffffff - last_offset (src/gfx1013_direct_compute.inl:636-638), the x4 at offset 16 is the only access in the program with a last offset of 28, and with last_offset = offset no guard compares against -29.
The -16/-17 wording is corrected in the docstring (:38), the comments and docs/experiments/native-direct-global-store.md:42-44.
Still missing, as asked on a910514a:
- the matching
dxc -dumpbinline for this head and for thelast_offset = offsetmutant; - a run on
2da1cc4c. The last posted run is ona910514a, and PR CI does not runnative_global_store_*(not in theprtest filter, notests/checks/python-linuxentry), so the matcher samples inencodingsdo not run there either.ctest --preset dev -j 1 -R "^native_global_"on this head would cover it.
I will approve once those are posted.
git merge-tree --write-tree onto origin/main 77d1ba4d: clean.
|
Review of head MUST
SHOULD
NIT
AI-assisted. |
Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
2da1cc4 to
6128c25
Compare
|
Re-review of the delta 2da1cc4 → 6128c25, rebased onto main af1cab5 (read-only, on Linux; no build or run here). MUST 1 is resolved. Leyukaka's open request and SHOULD 3 still hold this PR, so I'm not merging it. Resolved
Still open
NIT 4 (the reason change for a raw root-UAV This comment was AI-assisted. |
|
Run on head
Output of
Not covered:
This answers the head-run part of my request. The dumpbin lines are still open. |
|
Windows test PC ( This is the remaining At this head, unmodified, the compare
The same dump also has other Local mutant, not committed. Only
This does not change SHOULD 3. Nothing was committed or pushed. AI-Assisted |
Leyukaka
left a comment
There was a problem hiding this comment.
Head 6128c25a, diff only. This replaces my change request.
Delta from 2da1cc4c by git range-diff: commits 2-5 unchanged, commit 1 differs only by the rebase over #3389, and 6128c25a points the static_assert at ComputeViewKind::root_buffer_uav (src/direct_compute_cache.cpp:903).
The dxc -dumpbin lines posted by the author answer my last open point: at the head the matched compare is icmp ule i32 %t306, -29 and the add i32 -28, %t153 is not matched; with last_offset = offset the compare becomes -17 and native_global_store_hardware fails with x4 wrap guard does not cover the last dword. That is the author's measurement, I did not reproduce the dump or the mutant; it is consistent with 0xffffffff - last_offset (-29 = -1 - (16 + 12)).
Still open, not blocking for me: the SHOULD from the other review, docs/experiments/native-direct-global-store.md:22-23 names only UAV kind root_buffer_uav and not the in-process view kind 28 is not bound for a natively translated program.
|
Re-check at head Resolved
Left as a follow-up (not blocking)
With 0 MUSTs, no change request standing and CI green, I'm merging at This comment was AI-assisted. |
Part of #3224: the "direct global memory supports only DWORD loads with a scalar address pair" refusal (9 shaders, 19,528 untranslated dispatches in Not-Saii's census at
8007a539).What this covers. The census lists only the refusal text, not the opcodes per shader. At
8007a539,global_load_dwordthroughx4with a scalar address pair already passed the decoder, so my working assumption is that these keys fail on global stores. That is inferred, not checked against the 9 keys. If someone with those requests can rerun the census on this branch, that would confirm how many it actually recovers.Now lowered (direct compute path)
global_store_dword,dwordx2,dwordx3,dwordx4in thesaddrform, when the address is an unadvanced root UAV plus a 32-bit VGPR offset.glc,slcanddlcare accepted, and so is a signed immediate that's a multiple of 4.global_load_dwordthroughx4. Out-of-range stores are skipped and out-of-range loads return 0.Still refused, with a clear reason
The
offform (VGPR address pair), FLAT and scratch, an LDS result, byte and short ops, atomics,saddr127, a store through a root that isn't a UAV, an unaligned immediate, a data range pastv255, a mismatched or advanced SGPR pair, and scalar ALU on the root pair.Tests
tests/native_global_store_check.py(encodings plus negative controls) andtests/native_store_replay.cpp, registered asnative_global_store_encodings/native_global_store_hardware. Thenative_global_load_hardwarefixture now expects the root-SRV store refusal string.e519c57e,ctest -j 1with the audio device tests excluded:native_global_store_hardwareandnative_global_load_hardwarepassed twice each,native_passed 351/351 (332 passed, 19 WARP-only skips), andstartup_gfx2hlsl_passed 387/387.AI-assisted (Cursor)