Repository navigation
native: read the byte-address rewrite of a GPU-selected heap descriptor - #3025
Conversation
Under the raw_buffer heap view contract the direct compute path now tracks the byte-address rewrite (stride, max 1, byte count, stride cleared, raw out-of-bounds mode) of a descriptor loaded from the GPU-selected heap slot, as byte_descriptor_field already does for table descriptors, and reads a raw load through it as the same ResourceDescriptorHeap[slot] raw view. The words must come from one heap load; a program with a backward branch refuses the window as a precaution. Without a contract nothing changes. Refs R0Y00#3023, part of R0Y00#2935. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
R0Y00
left a comment
There was a problem hiding this comment.
Independent review at 7582c01d on cpp-migration 999e17cd. I rebuilt native_global_srv_heap_replay and compile_dxil and ran ctest --preset <dev|release> --no-tests=error -V -R '^native_global_srv_heap_replay_(hardware|warp)$'. Both RTX 4060 Laptop runs (Debug and Release /O2) passed. Each selected slot returned its own 64 words with all eight guards intact in capture and offline replay. The wrong-slot comparison failed at word 0, and the mixed-load, wrong-mask, store and backward-branch controls refused without publishing bytecode. WARP skipped with 77 in both presets because it reports only four-lane waves. Windows 11 build 26200.9974, SDK 10.0.26100, RTX driver 32.0.16.1656 and WARP 10.0.26100.9818, replay debug layer off.
The result covers the offline compiler slice under its raw-view contract. The fixtures use symbolic descriptor words and do not exercise a stride above one or a mismatch between guest byte count and the desktop view. Keep both checks in #3023's runtime acceptance criteria before supplying a raw-view contract for GPU-selected slots.
The first guard refused the window for any backward branch in the program. On a local start-up capture (contract forced locally) that refused 921 of 2,689 requests, although their loops do not contain the heap descriptor load. Only a loop around that load runs it again for another selection, so the guard now checks whether a backward branch's range contains the load pc (symbol.definition). The test refuses a loop back to the load and compiles a loop after it. Refs R0Y00#3023. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the review. I added both checks to #3023's runtime acceptance criteria (issuecomment-7212816337). Pushed With the narrower guard, none of those 921 is refused for a loop, and 906 move on to the typed heap load ( AI-assisted. |
R0Y00
left a comment
There was a problem hiding this comment.
Reviewed 837728dd on cpp-migration 999e17cd. The narrower guard tests whether a backward edge spans the recorded heap-load definition. The new control compiled when its loop was after the load, and the loop that reaches the load retained the named refusal with no bytecode. I also checked that #3023 now records the stride-above-one and exact desktop-view byte count acceptance criteria.
I rebuilt native_global_srv_heap_replay and compile_dxil and ran ctest --preset <dev|release> --no-tests=error -V -R '^native_global_srv_heap_replay_(hardware|warp)$'. The RTX 4060 Laptop hardware case passed in Debug and Release /O2, including the slot readback and guards. WARP skipped with 77 for four-lane waves in both presets. Windows 11 build 26200.9974, SDK 10.0.26100, NVIDIA driver 32.0.16.1656, WARP 10.0.26100.9818, replay debug layer off. Hosted Windows, Linux Python and gfx1013 checks passed. The approval covers the offline compiler slice.
Change
Target branch
cpp-migration. Refs #3023, part of #2935 (follow-up to #2908 / #2972).Under the
raw_bufferheap view contract, the direct compute path now reads the byte-address rewrite of a GPU-selected heap descriptor.byte_descriptor_fieldalready models this rewrite for table descriptors: stride (s_bfe_u32 ... 0xe0010),s_max_u32 ... 1, byte count (s_mul_i32), stride cleared (s_and_b32 ... 0xc000ffff), raw out-of-bounds mode (s_and_b32 ... 0xcfffffff,s_or_b32 ... 0x30000000), word 0 copied. With this PR it also accepts the words of a heap descriptor load. A raw load through the rewritten descriptor reads the sameResourceDescriptorHeap[slot]raw view that #2972 binds.src/gfx1013_compute_native.cpp:parseandtransfertakeheap_window, whichtranslate_programsets todirect_dxil && heap_view == raw_bufferand passes on tobyte_descriptor_field. The HLSL route (direct_dxil == false, numericheap_stride_srv) and the graphics route keep the defaultfalse, so they are unchanged.src/gfx1013_direct_compute.inl,heap_resource:byte_window_srv. The four words must come from one heap load (same pc, word typesindexed_descriptor, zero_stride_word, byte_count, byte_oob).src/gfx1013_compute_native.h: theHeapViewContractcomment states the caller's part. Every slot the program can select must be a raw view of exactlynum_records * max(stride, 1)bytes. The translator does not check that size, the swizzle bits (word 1 bits 31:30) or the other word 3 fields.Why this step:
compile_dxil --refusalsover a local start-up capture (2,689 slot 67 requests, counts only) gives 941 first refusalsdirect resource-heap load requires the selected GPU slot and its view type. It is the largest compute refusal. Local prototype runs with the contract forced through an uncommitted switch (not reproducible from the repo) give these counts:buffer_load_formatthrough the heap descriptor (a typed heap load,a GPU-selected heap slot is read as a raw buffer SRV only)No additional request compiles yet. This is one step of the chain, and typed heap loads are the next wall. In those programs the slot index comes from buffer data per wave, so the runtime cannot resolve it at Dispatch. Passing a contract from the runtime needs a check over all selectable slots (stage 2 of #3023).
Verification
Environment: Windows 11 build 26200, NVIDIA GeForce RTX 3080 (driver 32.0.16.2124), MSVC 14.51.36231, Windows SDK 10.0.26100 DXC, D3D12 debug layer not enabled. Base
999e17cd.warning Cin the touched files.native_global_srv_heap_replay_hardware: passed, 84 assertions (70 before).New shapes, refused with no
.cso:unbound numeric SGPR s21non-contiguous resource descriptora GPU-selected heap slot is read as a raw buffer SRV onlyheap byte window loaded inside a loopstride_readnow uses the stride as a number (v_mov_b32 v3, s24) and is refused withunbound numeric SGPR s24. This keeps the control that a stride never becomes a number. Before, the bare read was refused only because the rewrite was not modelled.A stride read that nothing uses compiles, and so does a never-taken backward branch after the heap load.
The full rewrite is recorded for selections 0 and 1 (output equals the slot's data), compiled with
compile_dxil --requests, and replayed with the same result. Replaying selection 0 against the slot 1 reference reports a mismatch.native_global_srv_heap_replay_warp: skipped (77), no 32-lane waves on WARP, as before.compile_dxiland the fixture built at999e17cdfails atstride_readwith the old text "a GPU-selected heap slot stride read is not translated with a view contract". With the shapes skipped, it fails at "an unused stride read compiles".837728dd): the first version refused the window for any backward branch. With the contract forced locally, it refused 921 of the 2,689 requests of the capture. Limited to loops around the heap load, it refuses none of them; 906 then stop at the typed heap load named above. The check run against7582c01dfails at thewindow_loopshape (old text). After the change, the regression set, the census with contractnoneand the 84 assertions give the same results as listed here.native_cvt_pk_u8_hardware). The same set gave the same result at999e17cdon this machine before the change.compile_dxil --refusalson the local capture: identical output before and after. It translates without a contract.tests/docs_links_check.pyandtests/bidi_controls_check.pypass.Evidence and follow-up
clang -cc1as -triple amdgcn-amd-amdhsa -target-cpu gfx1013 -show-encoding).docs/experiments/native-global-srv-heap-replay.md.buffer_load_format_*through a GPU-selected descriptor);raw_bufferit is now reachable only for a stride read into a destination above s105, and no shape covers that case.Checklist
AI-assisted.
🤖 Generated with Claude Code