Repository navigation
Conversation
Bit 20 of .sa dword 4 now sets ComputeRequest::wave32 (set: wave32, clear: wave64). The direct DXIL route of translate_compute compiles a wave64 request with more than 32 threads per group through the existing wave64 path, as translate_compute_container does for a stage without wave32. A wave64 group of at most 32 threads stays on the wave32 model, as before: its one guest wave has lanes 0..31 only. The model still does not write the zero high word that a wave64 compare stores in an SGPR pair destination. The legacy HLSL profile and the container route are unchanged. The bit's meaning is an inference from captured requests (see docs/experiments/native-slot67-wave-size.md). Source-built fixtures that relied on the wave32 default now set the bit. A new check compiles one v_mbcnt_lo/v_mbcnt_hi program as wave64 with 64- and 32-thread groups and as wave32, and compares the lane indices with a CPU reference on hardware. AI-assisted.
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.
…ler revision Native compute manifests written by compile_dxil now end with 'native <revision>' (src/native_compute_output.h, revision 1). The stand-in refuses a native manifest with another revision, or an unmarked manifest without a <key>.cs.hlsl sidecar (a native output from before this change), with a 'rebuild it' reason, and retries it after a second like an absent manifest. compile_dxil --watch treats both as pending and rebuilds them. Unmarked outputs with a .cs.hlsl sidecar are the Python translator's and are used as before, so request keys keep revision 28cs. AI-assisted.
…g Python bytecode in --watch A native compute publish now removes <key>.cs.hlsl, so a rebuilt pair is never read as a Python output. In --watch, an unmarked manifest with a .cs.hlsl sidecar goes on to the usual bytecode check instead of being skipped, so a Python output with incomplete bytecode is still rebuilt. The doc names the one case left undetected (a directory an earlier compile_dxil republished over Python outputs) and that the reload of a refused manifest is not covered by a test. AI-assisted.
|
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 |
Fixes #2999 (it needs closing by hand, since the base is not the default branch). Part of #2935. Target branch
main.Change (
src/shader_compute_request.*,src/gfx1013_compute_native.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.28cs, so existing Python caches keep their keys. The key hashes the request parts, which do not change.--requestsremoves and rebuilds every output, the frontend cache is keyed on a hash of the compiler sources, and the in-process route translates again in each process.compile_dxil --watchand the stand-in's reader do reuse a<key>.txtand<key>.cs.csopublished by an earlier build. After updating, rerun--requestsinto that directory or delete those files.docs/experiments/native-slot67-wave-size.md.Tests. The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, on
cpp-migratione0d83759plus this commit.native_slot67_wave_size_hardwarepassed. The samev_mbcnt_lo/v_mbcnt_hiprogram is built as three requests, and the stored lane indices match a CPU reference with every other buffer word untouched:tid % 64tid % 32tid % 32ctest -R "native_|startup_compute|startup_shader_cache_rekey": 275 of 276 passed. 4 WARP cases skip (77) as before.native_scalar_lds_hardwarefails with "native compute PSO creation failed" on this adapter; it fails the same way one0d83759without this change. This PR only sets the bit in that file's fixtures.Mutation checks, run by hand; each fails the new check:
Measured on a local capture (counts and instruction shape only) with
compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests, before and after:AI-assisted.