Repository navigation
shader: read the wave size of slot 67 compute requests from .sa - #3006
Conversation
R0Y00
left a comment
There was a problem hiding this comment.
The cold-cache lane-index fixture verifies the new wave-size decoding. Issue #2999 also calls for rebuilding cached translations on update. The PR documents that --watch and the stand-in can still reuse the old <key>.txt / <key>.cs.cso, so a warm native cache can keep running the old wave32 result for a wave64 request. Please add an upgrade control that prepopulates the old output, then show that the updated consumer refreshes or rejects that output. A native output compatibility check could preserve legacy Python request keys while doing this.
|
Thanks, done in the new commits, without changing request keys. The branch also merges Native output revision. Stand-in. Before reading bindings or bytecode:
One case stays undetected: a directory where an earlier Upgrade controls:
On the RTX 5080 and WARP, after the merge,
One interaction to handle on merge: the portable fixture of #2975 writes a hand-made manifest without a AI-assisted. |
KelboLive
left a comment
There was a problem hiding this comment.
PR #3006 by @Leyukaka — shader: read the wave size of slot 67 compute requests from .sa
What works
- Clean extraction of bit 20 from sa[18] with correct little-endian dword mapping (byte 18 is d4[2], bit 4 of that byte = global bit 20)
- Default wave32=true preserves backwards compatibility: old .sa files without the bit still get wave32 behavior
- Wave64 with <=32 threads stays on wave32 model: good fallback since lane 0..31 is valid either way
- The known difference (wave64 compare/carry-out writes zero to high word of SGPR pair) is documented transparently
- Key revision stays 28cs: Python caches preserved, no key hash changes needed
- native_compute_output.h provides a clean versioning mechanism for native translations
- Manifest retry mechanism (incompatible/unmarked -> retry after 1 second) supports live rebuilds
- native_compute_output_revision bump to 1 is correct for the new version scheme
- Test covers all three cases: bit clear/64 threads, bit set/64 threads, bit clear/32 threads
- Mutation checks (ignore bit, invert bit, drop 32-thread rule) all correctly fail
- 275/276 tests pass; 4 WARP skips, 1 adapter limitation unrelated to this change
- compile_dxil --watch test properly handles old manifests, unmarked manifests, and new manifests
- 15 test files updated to set the wave32 bit in their fixtures
Issues
- sa[18] index is fragile: if .sa file structure changes (e.g., dword 4 offset shifts), this silently reads the wrong bit. Consider adding a comment with the full bit position: sa dword 4 bit 20 = sa[18] bit 4 in little-endian.
- The native_compute_output parser uses a simple line-based search which could match partial lines (e.g., "nativex" would match the substring check). The line != "native" guard helps but substr(0,7) check on "native " should also verify the char at position 7 is a digit or the line ends after position 7.
- load_compute_translation sets tr.retry_manifest_at in the incompatible case but the caller needs to know the retry is for manifest version, not just absence. The comment in the struct was updated to "absent and stale manifests can become ready later" which is good.
- The wave64 threads > 32 check in gfx1013_direct_compute.inl is duplicated logic: the same check appears in both translation paths (direct DXIL and container). Moving to a single decision point would be cleaner.
Recommendations
- Add a static_assert on sizeof(sa) == 28 or sa.size() == 28 in read_compute_request to catch malformed files early.
- In native_compute_output, add a check that line[7] is a digit: if (line.size() == 7 || !isdigit(line[7])) return incompatible.
- Consider adding a debug assertion in translate_program: assert(wave64 || threads <= 32) to catch any edge cases where threads > 32 but wave64 is false on a direct_dxil path.
- The 15 fixture files updated should include a note in each file linking back to the capture analysis (#2999).
Overall
Well-executed inference-driven addition. The bit extraction is correct, the wave32 model fallback for small groups is a good safety net, and the manifest versioning provides a clean path forward for future native translation changes. The key question for merge readiness is whether the capture analysis in #2999 has sufficient evidence to confirm bit 20 as the wave size marker.
R0Y00
left a comment
There was a problem hiding this comment.
Independent Release /O2 on exact head 5c49bbe38b803d13bdaccfd4e2584cc91aaffc34, Windows 11 build 26200.9974 and SDK 10.0.26100. I built startup_stream_consumer d3d12_xs_shim compile_dxil native_store_replay and ran native_compile_dxil_watch, native_startup_request_cache_controls, startup_compute_dispatch_(warp|hardware) and native_slot67_wave_size_hardware: 5 passed, no skips. WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 matched all 320 dispatch words for the current and Python-style manifests, preserving sentinels in the stale cases. RTX also matched 128/128/64 lane indices for the three slot-67 cases. The marker keeps the existing request key, but the .cs.hlsl heuristic still cannot identify an old native output over a prior Python publication; the documented one-time --requests rebuild still applies to mixed directories. Please keep the reported #2975 sidecar rename with whichever PR lands second.
|
Retargeted to |
…build stale native outputs Port of R0Y00#3006 onto main. Bit 20 of .sa dword 4 now sets ComputeRequest::wave32 (set: wave32, clear: wave64). The direct DXIL route compiles a wave64 request with more than 32 threads per group through the existing wave64 path; a wave64 group of at most 32 threads stays on the wave32 model. Request keys and the revision-29 / revision-28 archive handling are unchanged. Native compute manifests end with 'native <revision>' (src/native_compute_output.h). The stand-in refuses a native manifest from another revision, or an unmarked one without the Python translator's <key>.cs.hlsl, and looks again on the ManifestRetry schedule of an absent manifest. compile_dxil --watch rebuilds both, and a native publish removes a leftover <key>.cs.hlsl. Source-built fixtures that relied on the wave32 default now set the bit, and fixtures that copy a Python translation also copy its sidecar. AI-assisted.
|
Rebuilt on current
One fixture added on On this head (RTX 5080 and WARP, Release), AI-assisted. |
pigalot
left a comment
There was a problem hiding this comment.
I tried to review e7a1e90f over current main 63fd6ea8. The trial merge (git merge-tree --write-tree origin/main review/3006) conflicts in one hunk of src/gfx1013_compute_native.cpp, just after the 0xc00 root-flag check. Since this PR's base 8cf9be9b, #3140 (673a9f2c) has turned the one-line if body there into a block that also sets initial[next + 1] = {Symbol::Type::table, compute_sampler_heap};. This PR replaces the const bool wave64 = stage && !stage->wave32; line that follows it. The resolution should keep #3140's block as it is, followed by this PR's comment and new wave64 expression. The other files merge cleanly.
One interaction to recheck after the rebase: #3180 (63fd6ea8) gates the wave32 VCC SMEM limit on !wave64. With this PR, wave64 requests over 32 threads would then keep the 106-SGPR limit. That is the intended behaviour. I haven't run it.
I'll review it once it is updated with main.
This reply was AI-assisted.
|
One addition to my comment on This reply was AI-assisted. |
|
Rebased on
15 test files now set the bit, down from 17, because Tests.
Measured on the 882 untranslated compute requests ranked in #3224, with
The Tests and Measured sections of the description still describe the first version on AI-assisted. |
…build stale native outputs Port of R0Y00#3006 onto main. Bit 20 of .sa dword 4 now sets ComputeRequest::wave32 (set: wave32, clear: wave64). The direct DXIL route compiles a wave64 request with more than 32 threads per group through the existing wave64 path; a wave64 group of at most 32 threads stays on the wave32 model. Request keys and the revision-29 / revision-28 archive handling are unchanged. Native compute manifests end with 'native <revision>' (src/native_compute_output.h). The stand-in refuses a native manifest from another revision, or an unmarked one without the Python translator's <key>.cs.hlsl, and looks again on the ManifestRetry schedule of an absent manifest. compile_dxil --watch rebuilds both, and a native publish removes a leftover <key>.cs.hlsl. Source-built fixtures that relied on the wave32 default now set the bit, and fixtures that copy a Python translation also copy its sidecar. AI-assisted.
|
Rechecked 7e018ff against main 350785e after #3227. The only merge conflict is the final compute manifest writer in direct_compute_cache.cpp. Keep main's program.stride_srvs loop before the SRV/UAV/sampler lines, then append the existing native revision line. The new native_descriptor_scc_check.py exact manifest list also needs its final native 1 line. I tried just those two changes locally on the existing PR. Windows 11 26200.9974, RTX 4060 Laptop 32.0.16.1656, Release /O2: native_descriptor_scc_hardware, startup_compute_descriptor_scc_hardware, native_compile_dxil_watch and native_slot67_wave_size_hardware all passed. Please carry those two changes in the existing PR on current main so CI and independent review can evaluate the new head. The reported #3224 compile counts remain separate from GPU readback. |
…build stale native outputs Port of R0Y00#3006 onto main. Bit 20 of .sa dword 4 now sets ComputeRequest::wave32 (set: wave32, clear: wave64). The direct DXIL route compiles a wave64 request with more than 32 threads per group through the existing wave64 path; a wave64 group of at most 32 threads stays on the wave32 model. Request keys and the revision-29 / revision-28 archive handling are unchanged. Native compute manifests end with 'native <revision>' (src/native_compute_output.h). The stand-in refuses a native manifest from another revision, or an unmarked one without the Python translator's <key>.cs.hlsl, and looks again on the ManifestRetry schedule of an absent manifest. compile_dxil --watch rebuilds both, and a native publish removes a leftover <key>.cs.hlsl. Source-built fixtures that relied on the wave32 default now set the bit, and fixtures that copy a Python translation also copy its sidecar. AI-assisted.
|
Rebased again on
After the change, AI-assisted. |
R0Y00
left a comment
There was a problem hiding this comment.
Independent review of ecd2646 integrated on main 86beae9, tree 3ab5553ad668f49086d4d81da40819b70dc725b8. The .sa bit selects the direct DXIL wave model for larger groups; stable request keys still load previous raw requests. Version-tagged native manifests and the watcher prevent stale DXIL reuse, and Python manifests with the existing sidecar are still accepted. The descriptor SCC entry is preserved. The small-group high-half limitation is documented and is outside this change.
Debug and Release /O2 each had six passes and three wave32 capability skips, no failures. Hardware verified the new wave-size reference, both descriptor SCC routes, native Dispatch and the legacy/retry controls. WARP was inbox 10.0.26100.9818. Windows 11 26200.9974, RTX 4060 Laptop driver 32.0.16.1656.
ctest --preset dev --no-tests=error --output-on-failure -j 1 -R '^(native_(slot67_wave_size_hardware|descriptor_scc_(warp|hardware)|compile_dxil_watch)|startup_(compute_descriptor_scc_(warp|hardware)|compute_dispatch_native_(warp|hardware)|manifest_retry))$'This validates source-built requests and cache migration. The shader census totals are contributor measurements and do not establish title rendering.
) * compute: accept EXEC as a 64-bit scalar operand in direct compute EXEC (126) is accepted as the even source pair of s_bcnt0/s_bcnt1, s_ff0/s_ff1 and s_flbit *_b64, and as the s_bfm_b64 destination. In the wave64 model each host half holds both EXEC words: both are set at entry, lane-mask writers publish both through the exchange, and scalar writes are identical in both halves; VCC has no such guarantee and stays refused as a source and as the s_bfm_b64 destination. New test native_wave64_exec_salu (wave64 64 and 128 threads, wave32 32): a sparse EXEC count, s_bfm_b64 exec, 16, 0 and exec, 32, 32, with three refusal controls. Depends on #3006 for the wave64 model. * docs: describe EXEC as a 64-bit SALU source and s_bfm_b64 destination native-direct-salu-bitscan64 lists EXEC as a valid S0 and explains why its source refusal control now uses exec_hi; native-salu64-ops lists s_bfm_b64 into EXEC, keeps the s_cselect_b64 / s_not_b64 EXEC destination refusal, and adds the native_wave64_exec_salu_hardware command.
Since R0Y00#3006 the runtime's compute loader also looks for <key>.cs.hlsl when the key's .txt has no native line, and refuses the translation without it. List it as a compute translation file, optional like mesh86's .ps.cso, since the loader does not read the .txt. Pin it beside the runtime's unmarked-manifest check.
…nd, load_data) (#3119) * tooling: refuse a patch manifest nested too deeply for tomllib * tooling: define the shader patch kind, checked for shape only * tooling: gate a patch manifest on input bytes the caller already read * tooling: check the shader revision's form, not the runtime's current number * tooling: a shader patch names its files by bare file name * tests: pin the shader patch files to what the runtime reads * tests: set the recursion limit in the patch manifest nesting case * docs: list the shader patch mutations and controls * docs: record the patch manifest loader measurements * tests: pin patch manifest geometry, trailing text, empty bytes and the CLI's OSError Four memory patches in descending RVA, three adjacent and one at RVA 0, load; a one-byte overlap is refused in either order. A hash or key with trailing text and an empty bytes are refused, the bound patch is compared field by field, and a missing input file reaches the CLI as a diagnostic. Each kills one of the eight mutations that survived the fixture. * docs: list the patch manifest cases and mutations added for the fixture audit * tests: give the side-by-side patches ids out of step with their addresses A sort of the spans by id instead of by address passed the fixture, because the accept case listed ids that followed the addresses. Use ids that follow neither the addresses nor their reverse, and list the mutation. * loader: refuse Windows-invalid manifest file names (#3119) * loader: accept the .cs.hlsl a compute key may need (#3119) Since #3006 the runtime's compute loader also looks for <key>.cs.hlsl when the key's .txt has no native line, and refuses the translation without it. List it as a compute translation file, optional like mesh86's .ps.cso, since the loader does not read the .txt. Pin it beside the runtime's unmarked-manifest check.
Fixes #2999. Part of #2935. Target branch
main.Change (
src/shader_compute_request.*,src/gfx1013_compute_native.cpp,src/native_compute_output.h,src/direct_compute_cache.cpp,src/startup_stubs/d3d12_compute_dispatch.inl,tools/startup/compile_dxil.cpp):read_compute_requestsetsComputeRequest::wave32from bit 20 of.sadword 4: set means wave32, clear means wave64. A.sathat is not 28 bytes is still refused, as before.translate_computecompiles a wave64 request through the wave64 path thattranslate_compute_containeralready uses for a stage withoutwave32.v_mbcnt_hiadds nothing for its lanes. One known difference remains: a wave64 compare or carry-out also writes zero to the high word of an SGPR pair destination, and the wave32 model leaves that word as it was.29cs, as onmain, and revision-28 archives are still read. The bit's meaning is an inference from captured data, explained in shader: read the wave size of slot 67 compute requests (bit 20 of .sa dword 4) instead of assuming wave32 #2999 and indocs/experiments/native-slot67-wave-size.md.Native output revision. A native compute manifest now ends with
native <revision>, fromnative_compute_output_revisioninsrc/native_compute_output.h.<key>.cs.hlsl, which is a native output from before this change.ManifestRetryschedule of an absent manifest: 1 s, doubling up to 32 s.<key>.cs.hlslis a Python output and is used as before.compile_dxil --watchrebuilds stale native outputs. An unmarked output with a sidecar goes on to the usual bytecode check.<key>.cs.hlsl.compile_dxilalready republished a Python-translated key. That directory needs one--requestsrerun.Fixtures.
native_dpp_row_check.py, added onmainsince the first version.startup_compute_root_srv_dispatch_check.pynow copies the Python sidecar along with the manifest and bytecode in its bad-manifest cases.Tests. The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, on
main8cf9be9bplus this commit.ctest -R "native_|startup_compute|startup_shader_cache_rekey|compile_dxil|startup_manifest_retry"passed 344 of 345, with five WARP capability skips (77).native_scalar_lds_hardwarefails with "native compute PSO creation failed", as it does onmainwithout this change.native_slot67_wave_size_hardwarebuilds the samev_mbcnt_lo/v_mbcnt_hiprogram as three requests. The stored lane indices match a CPU reference, with every other buffer word untouched:tid % 64tid % 32tid % 32native_compile_dxil_watch,startup_compute_dispatch_warp/_hardwareandnative_startup_request_cache_checkcover the stale-output paths. I described them in the earlier comment.Mutation checks, run by hand on the earlier
cpp-migrationhead and not rerun on this one:--watchkeep it, skipping the bytecode check for a Python output, and keeping the.cs.hlslon a native publish.Measured on a local capture (counts and instruction shape only), on
cpp-migratione0d83759before this was rebuilt onmain, withcompile_dxil --jobs 8 gfx1013-direct-cs@36 --requests. I have not re-measured onmain, which has gained lowerings since.AI-assisted.