Repository navigation
runtime: bind indexed atomic UAVs in the direct compute runtime path - #3417
Conversation
Publish ComputeViewKind::indexed_atomic_uav in format_compute_runtime_manifest
as 'uav <register> atomic table <parameter> <byte>' for a single 4-byte view,
and bind it in the startup dispatch path from a slot-19 token view, with the
view's {stride, count} as root constants at b(register + 1), matching
NativeComputePipeline. Hardware-descriptor atomics and unsupported token
shapes stay refused by name. Refs R0Y00#3224, R0Y00#2935
…ithout wave32 WIN-VERIFY round 1: on hardware, three negative-control UAV descs were invalid for D3D12 CreateUnorderedAccessView on the 1280-byte buffer (a 4096-byte structured stride, a RAW-flagged R32_UINT view, a 1284-byte view), so slot 19 removed the device before the dispatch could refuse them. Keep every negative view creatable: the 4096-stride view now runs on the 16 MiB + 64 KiB committed buffer, the unaligned view uses WORDS - 1 elements, and the two uncreatable shapes stay out (a RAW view needs R32_TYPELESS; a view past the end of its buffer cannot be created). controls() now checks every negative view fits its buffer and that the two uncreatable shapes fail that check. On WARP, the --shader-wave32 gate exited 77, skipping the published raw/structured/typed runs even though only the native translator needs 32-lane waves: main() no longer probes wave32, and native_check() probes it directly so a skip there does not discard the published results. Refs R0Y00#3224, R0Y00#2935
…ed atomic UAV check
Leyukaka
left a comment
There was a problem hiding this comment.
Reviewed 10d7d41b by reading the diff against main 212d4b5f. No local build or run. git merge-tree against main is clean.
Formatter (src/direct_compute_cache.cpp:990-996): indexed_atomic_uav is published only with array_count == 1 and required_bytes == 4, which is the width the translator always records for the binding (src/gfx1013_direct_compute.inl:456-457). Other shapes fall through to view_shape, so an array refuses as UAV kind indexed_atomic_uav array (:911), as the new case expects.
Runtime (src/startup_stubs/d3d12_compute_dispatch.inl):
- The root signature matches what the program reads. The translator reads b0 (
gfx1013_direct_compute.inl:323) and, per indexed atomic,{stride, count}from b(register + 1) (:460-468); it creates no other CBV handle.create_translated_rootadds one 2-value constants parameter per atomic UAV atShaderRegister = register + 1after the view table (translated_sampler_bindings.h:146-152), the same asNativeComputePipeline(src/native_compute_pipeline.cpp:92-97). The register is the UAV index, which equals the manifest register because eachuavline must havei == tr.uavs.size()(:229-230); the in-process path has the same check onshader_register. - Sizes: at most 8 UAVs (
:275,:378), so at most 2 + 8 + 1 = 11 parameters (parameters[11]) and a root cost of at most 32 + 1 + 16 + 1 = 50 DWORDs. - Binding (
:864-871,:889-901): the token view goes throughnative_buffer_store_viewfrommain(src/native_buffer_store_view.h:17-54, unchanged here). That accepts rawR32_TYPELESS, structured with a stride that is a multiple of 4 and at most 2048, or typedR32_UINT/R32_SINT, rejects counters, a range outside the resource and a start that is not 16-byte aligned, then rewrites the view to rawR32_TYPELESS. A hardware descriptor refuses before the hardware path (:898-901). The constants are set in UAV order withatomic_parameter++(:1069-1074), the same ordercreate_compute_pipelinebuilt (:117-119). - The op set (add/sub/and/or/xor/smin/smax/umin/umax/swap/cmpswap) is what
buffer_atomicalready lowers onmain(gfx1013_direct_compute.inl:443-452). This PR only adds the binding.
Tests: no test, tool or doc on main expects UAV kind indexed_atomic_uav from compile_dxil. Reading the tests against the code:
native_compute_manifest_reasons: dropping thearray_countorrequired_bytescondition fails a new case. Dropping the clause fails the accept block.startup_compute_indexed_atomic_uav_*: the three positive shapes write different dwords (raw0..31, stride 80,8,..,248, typed0,4,..,124), so a wrong stride constant or a wrong rewrite fails. Dropping the slot-19 refusal failsdispatch-records32. Wrong parameter indices or a wrongShaderRegisterfail the positive runs.
Not covered:
countis never the deciding bound: the largest index is 124 and the smallest count is 160. Settingatomic_countto~0uat:894passes every test. A smallerNumElementsalone may not catch it either, since the rewritten raw view has the same extent. Suggestion: an index that wraps under the multiply, which is what the count test guards (gfx1013_direct_compute.inl:461), for example stride 8 with index0x20000000 + lane, expecting an untouched output.- Only u0 is atomic, with no other UAV, so
push_back(i)->push_back(0)at:119survives. Suggestion: a mixed layout, for example u0 raw and u1 atomic, which reads b2. - The 4096-stride negative runs on
dispatch-uav-token-large, which views a committed buffer while the readback is of the placed output buffer, so its "untouched output" check does not read the buffer it views. The refusal text still pins that case. - CI does not run these tests. PR CI uses the
prpresets, whose build targets include neithercompile_dxilnorstartup_stream_consumerand whose filter matches none of the new tests. The new controls are not intests/checks/python-linux. The evidence is the log in the description, where_warpskips with 77 and only_hardwaredispatches. - Wording: the comments at
:587and:1067say "parameter 2 + its UAV index". The code uses 2 + the rank among atomic UAVs, which is correct. The description still saysmain()no longer probes--shader-wave32; at this head it does (test:256), and the re-probe innative_checkcannot skip.
Overlap: #3398 rewrites the same classification block in translate_compute_natively and conflicts here; whichever lands second adds atomic to output and to supported. The tests/native_compute_manifest_reasons.cpp changes merge cleanly with #3427 and #3398.
Approve 10d7d41b.
tedin7
left a comment
There was a problem hiding this comment.
Reviewed 10d7d41b7740bb176e1cf6c5360cf6e3c9c92a2f:
Running the PR's tests on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) failed in both Debug and Release:
ctest --preset dev -R '^(startup_compute_indexed_atomic_uav_|native_compute_manifest_reasons$)' --parallel 3 --no-tests=error --output-on-failure: 1/4 passed, 3 failed (native_compute_manifest_reasonspassed;startup_compute_indexed_atomic_uav_controls,startup_compute_indexed_atomic_uav_warp, andstartup_compute_indexed_atomic_uav_hardwareall failed incompile_dxilwithno_manifest input=req_f05f4f5cbdd73cc3.c67 unsupported startup runtime manifest bindings: UAV kind indexed_atomic_uav).ctest --preset release -R '^(startup_compute_indexed_atomic_uav_|native_compute_manifest_reasons$)' --parallel 3 --no-tests=error --output-on-failure: 1/4 passed, 3 failed (same failure).
AI-assisted; commands listed were executed locally.
Leyukaka
left a comment
There was a problem hiding this comment.
Re-checked head 10d7d41b against the report above, by reading only; nothing built or run. Our approval stays until the cause is known.
- compile_dxil has no kind list of its own: it prefixes the reason returned by
format_compute_runtime_manifest(tools/startup/compile_dxil.cpp:328-329,:1561). - The reported text is what the formatter at the base
0614f68cemits for this binding. Without the branch this PR adds, a one-elementindexed_atomic_uavreachesrefuse(view_shape("UAV", b)), which gives exactlyUAV kind indexed_atomic_uav. - At this head,
src/direct_compute_cache.cpp:990-996publishes that kind whenarray_count == 1 && required_bytes == 4. With one element, the same text can then only come fromrequired_bytes != 4. The translator creates this kind in one place, with 4 bytes (src/gfx1013_direct_compute.inl:456-457). native_compute_manifest_reasonslinks the samex2w_shader_compilerlibrary as compile_dxil (CMakeLists.txt:31-32,tests/cmake/native_compute_manifest_reasons.cmake:5-6). Its new block (tests/native_compute_manifest_reasons.cpp:128-143) requiresuav 0 atomic table 1 32for exactly that shape, and the report shows it passing.
So either the translated binding is not 4 bytes, or the compile_dxil that ran was not built from this head. Two things would settle it:
- the
u0 root=... bytes=... min_size=...line compile_dxil prints for the request the failing test publishes (tools/startup/compile_dxil.cpp:137-138; the failing assert inpublish()includes its stdout); - whether compile_dxil was rebuilt at
10d7d41b. The full SHA quoted in the report (10d7d41b7740...) is not this head's (10d7d41b77d4...).
Separately, the PR now conflicts with main (41babe6e), in src/startup_stubs/d3d12_compute_dispatch.inl only. At the in-process slot setup, #3409 added slots.back().requires_identity_dst_sel = view.requires_identity_dst_sel; where this PR adds if (atomic) slots.back().atomic = true;. The two lines set different fields; keeping both resolves it.
CI does not run these 4 tests: PR CI uses the pr test preset, whose filter has neither startup_compute_indexed_atomic_uav_* nor native_compute_manifest_reasons.
|
Taking this over since there has been no activity for 2 h; will hand back if you resume. Plan: merge |
|
Review of MUST
SHOULD
What I tried: I cross-built AI-assisted. |
|
The merge of You can take it back at any time: say so here and #3454 gets closed. |
compute: indexed atomic UAV dispatch (takeover of #3417)
Refs #3224, #2935
ComputeViewKind::indexed_atomic_uavpreviously had no runtime manifest, socompile_dxilreportedcompiled, no runtime manifest: UAV kind indexed_atomic_uavand the dispatch path never bound it. This change publishes and binds it in the direct compute runtime path.src/direct_compute_cache.cpp:format_compute_runtime_manifestpublishes a single 4-byte view asuav <register> atomic table <parameter> <byte>. Any other shape (descriptor array,required_bytes != 4) stays refused by name asUAV kind indexed_atomic_uav.src/startup_stubs/d3d12_compute_dispatch.inl: parses theatomicline and builds a root signature with one extra 32-bit-constants parameter per indexed atomic UAV, after the view table and in UAV order, withShaderRegister = uav register + 1and two values, matchingNativeComputePipeline. The in-process native translation classifies the binding as an output the same way.native_buffer_store_viewcheck derives{stride, count}from that view (structured stride multiple of 4 and at most 2048, rawR32_TYPELESS, typedR32_UINT/R32_SINT) and rewrites it to the rawR32_TYPELESSview the atomic operates on; failures refuse asan indexed atomic output view has an unsupported stride or range. A hardware-descriptor atomic refuses asan indexed atomic output needs a slot-19 token view.src/startup_stubs/translated_sampler_bindings.h:create_translated_roottakes the atomic UAV registers (defaulted, other callers unchanged); the sampler-heap table follows the atomic parameters.tests/startup_compute_indexed_atomic_uav_check.py(_controls,_warp,_hardware,SKIP_RETURN_CODE 77) publishes the synthetic program throughcompile_dxil, dispatches it through the stand-in list (raw, structured stride-8 and typedR32_UINTtoken views, each with its own addressed dwords), checks four token shapes and a hardware descriptor that must each refuse with their own reason and leave the output untouched, and checks the native in-process translation of the same program.tests/native_compute_manifest_reasons.cppgains the accept case and the array/required_bytesrefusals. Contract documented indocs/experiments/compute-indexed-atomic-uav.md.WIN-VERIFY round 1 (
9895ec1c):native_compute_manifest_reasons,native_compute_manifest_reasons_requestsandstartup_compute_indexed_atomic_uav_controlspassed;_warpskipped (77);_hardwarefailed after the raw bound run passed, withdevice removed(DXGI_ERROR_DEVICE_HUNG) in slot 19. Three negative-control UAV descs were invalid for D3D12CreateUnorderedAccessViewon the 1280-byte buffer (a 4096-byte structured stride, a RAW-flaggedR32_UINTview, a 1284-byte view), so the device was removed before the dispatch could refuse them; and the--shader-wave32gate inmain()exited 77 on WARP, skipping the published runs even though only the native translator needs 32-lane waves.Fix in this head (
fa269a85): every negative view is now creatable in D3D12 on its buffer — the 4096-stride view runs on the 16 MiB + 64 KiB committed buffer (dispatch-uav-token-large), the unaligned view usesWORDS - 1elements, and the two uncreatable shapes (RAW with a non-R32_TYPELESSformat, a view past the end of its buffer) stay out.controls()now checks every negative view fits its buffer and that the two uncreatable shapes fail that check.main()no longer probes--shader-wave32;native_check()probes it directly so a skip there does not discard the published results.Linux verification (this host has no Windows toolchain, so the GPU tests are pending below):
python -B tests/startup_compute_indexed_atomic_uav_check.py: controls pass (program encoding, table loads,idxenatomic, per-shape expectations, token views, creatable negative views).python -B tests/form_coverage_check.py,tests/docs_links_check.py,tests/bidi_controls_check.py: pass.py_compileon the touched Python file: pass./tmp(clearedidxen, raw stride 1 to 4, structured stride 8 to 16, mutated refusal reason, droppedglcfrom the expected decode, reintroduced the 1284-byte unaligned view): each fails the controls, unmutated base passes.d3d12_compute_dispatch.inl.Windows Verification (10d7d41)