Repository navigation
Conversation
gut0to
left a comment
There was a problem hiding this comment.
AI-assisted review (GPT-6): I verified the failure path in the generated 64-bit compare-exchange loop.
| let u = format!("{t}_U[{icoord}]"); | ||
| let cas64 = |new: String| { | ||
| format!( | ||
| "uint64_t {t}_c = {u}; [allow_uav_condition] for (uint {t}_i = 0u; {t}_i < 4096u; {t}_i++) {{ uint64_t {t}_n = {new}; uint64_t {t}_p = 0; InterlockedCompareExchange({u}, {t}_c, {t}_n, {t}_p); if ({t}_p == {t}_c) break; {t}_c = {t}_p; }} {t}_old = {t}_c;" |
There was a problem hiding this comment.
Could this retry until the compare-exchange succeeds? If all 4096 attempts lose under contention, the loop exits without applying the atomic operation but still reports _c as the old value. That silently drops updates for 64-bit smin, smax, inc, or dec. Please handle exhaustion as a failure or keep retrying. AI-assisted review: I checked the generated loop and its failure path.
|
Checked on NVIDIA at head Tested
Compared with #1533 (same issue, opened earlier; both pass the test above here):
Not tested: the whole suite, AMD, a device without the caps, a retail run. AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this comment. |
ec4c343 to
d9138ac
Compare
|
Thanks @gut0to and @upipibi — updated in \d9138ac\ to use native \RWTexture<int64_t>\ \InterlockedMin/\InterlockedMax\ directly for 64-bit \smin\ and \smax\ (no CAS loop needed at all for those two). For \inc\ and \dec\ (which have no HLSL wrap-at-limit intrinsic), the 4096-iteration bounded CAS loop matches the existing |
|
Test report for Tested
Not tested
AI use: Claude Code (Claude Opus 5.5) ran the commands and wrote this report; I checked it before posting. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
Adapt xcl-dev#1541 and the signed views and contention fixtures from xcl-dev#1533. Key translation caches on the device capability. Five independent operations failed on the baseline and passed on the RTX 5070. Co-authored-by: enderrr9 <178652333+enderrr9@users.noreply.github.com> Assisted-by: OpenCode (Gemini 4 Neon) Assisted-by: T3 Code (gpt-6.2-astra)
|
Thanks for the 64-bit atomics work. I read the diff at ec4c343 and rechecked d9138ac (not run); the line below is unchanged. In Suggestion: keep the caches and add the capability bit to the keys instead, i.e. a field in AI use: Claude Code (Claude Opus 5.5) read the diff; not run. Checked by the user before posting. |
|
Two contributors checked independently and found that #1533 #1551 solves the same problem (for #1485) in a different way: #1607, group D9. You may want to compare them with the other author and agree on one, or say in the PR why both are needed. This is a hint, not a request from the maintainers; nobody from the project has adopted #1607 so far. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table. |
…h cap gating The MIMG image atomic emitter ignored DMASK, silently lowering 64-bit image atomics (DMASK 0x3 for add/sub/min/max/and/or/xor/swap/inc/dec, DMASK 0xF for cmpswap/fcmpswap) as 32-bit atomics on the low dword only, losing carries, ordering u64 values by their low 32 bits, and ignoring VDATA[1] / VDATA[2:3]. Decode 32-bit vs 64-bit width from DMASK (rejecting invalid masks), gate 64-bit typed image atomics on `Options::int64_typed_atomic` (queried from `D3D12_OPTIONS9::AtomicInt64OnTypedResourceSupported` and `D3D12_OPTIONS11::AtomicInt64OnDescriptorHeapResourceSupported`), and emit SM 6.6 `RWTexture*<uint64_t>` Interlocked* / 64-bit CAS loops with full 64-bit GLC return unpacking into VDATA[0:1]. When the adapter lacks these capabilities, 64-bit image atomics are cleanly refused rather than mistranslated as 32-bit. The capability is part of the caches' keys instead of a reason to bypass them: a field of the in-memory `ShaderKey`, and an identity of its own for the translations on disk of a device without it (a capable device's identity, and so its existing entries, is unchanged). Without that, a device lacking the capability translated every program again at each start (review of xcl-dev#1541). The device is asked once, not per translation. Fixes xcl-dev#1485. Assisted-by: OpenCode (Claude Fable 5.2)
d9138ac to
a4f7834
Compare
|
@KainanP you are right:
Suite on this head: 977 passed, 0 failed, 45 ignored. Smoke for Not tested: a device that lacks the capability. I have none here, so the cache behaviour on one is covered by the unit tests only. On the #1607 hint (group D9, #1533 and #1551): the description now says what differs. This PR refuses a program that uses 64-bit image atomics where the device lacks them; the other two always emit the 64-bit form. I have not run either of them, so I am not claiming more than that. Also corrected in the description: it listed a change in AI use: OpenCode, Claude Fable 5.2 made the change, ran the tests and wrote this comment. |
…h cap gating The MIMG image atomic emitter ignored DMASK, silently lowering 64-bit image atomics (DMASK 0x3 for add/sub/min/max/and/or/xor/swap/inc/dec, DMASK 0xF for cmpswap/fcmpswap) as 32-bit atomics on the low dword only, losing carries, ordering u64 values by their low 32 bits, and ignoring VDATA[1] / VDATA[2:3]. Decode 32-bit vs 64-bit width from DMASK (rejecting invalid masks), gate 64-bit typed image atomics on `Options::int64_typed_atomic` (queried from `D3D12_OPTIONS9::AtomicInt64OnTypedResourceSupported` and `D3D12_OPTIONS11::AtomicInt64OnDescriptorHeapResourceSupported`), and emit SM 6.6 `RWTexture*<uint64_t>` Interlocked* / 64-bit CAS loops with full 64-bit GLC return unpacking into VDATA[0:1]. When the adapter lacks these capabilities, 64-bit image atomics are cleanly refused rather than mistranslated as 32-bit. The capability is part of the caches' keys instead of a reason to bypass them: a field of the in-memory `ShaderKey`, and an identity of its own for the translations on disk of a device without it (a capable device's identity, and so its existing entries, is unchanged). Without that, a device lacking the capability translated every program again at each start (review of xcl-dev#1541). The device is asked once, not per translation. Fixes xcl-dev#1485. Assisted-by: OpenCode (Claude Fable 5.2) (The mesh-shader path's own cache key, added on main since the last rebase, carries the same capability.)
a4f7834 to
9e1e7d3
Compare
|
Rebased onto |
|
Re-checked the rebased head AI-assisted (Claude Code). |
Fixes #1485.
Em::mimgincrates/xcl/src/gpu/recomp/emit.rsignoredDMASKonIMAGE_ATOMIC_*instructions and always emitted 32-bitRWTexture<uint>/RWTexture<int>atomics onVDATA[0]. On RDNA2 (per LLVMSIISelLowering),DMASK == 0x3(or0xFforcmpswap/fcmpswap) selects 64-bit image atomics operating onVDATA[0:1](andVDATA[2:3]as compare value forcmpswap), so 64-bit carries, upper-dword comparisons, andGLC64-bit return values were silently truncated to 32 bits.This adds 64-bit MIMG image atomic translation using SM 6.6
RWTexture<uint64_t>/RWTexture<int64_t>typed 64-bit atomics (InterlockedAdd,InterlockedAnd,InterlockedOr,InterlockedXor,InterlockedExchange,InterlockedMin,InterlockedMax,InterlockedCompareExchange, plus bounded CAS loops matchingrmw64forinc/dec), gated onD3D12_FEATURE_DATA_D3D12_OPTIONS9::AtomicInt64OnTypedResourceSupported && D3D12_FEATURE_DATA_D3D12_OPTIONS11::AtomicInt64OnDescriptorHeapResourceSupported. Adapters without those capabilities cleanly refuse 64-bit image atomics instead of failing at pipeline creation or silently truncating to 32 bits, and invalidDMASKvalues are also refused.Since the review (@KainanP): a device without the capability no longer bypasses the shader caches. The capability is part of their keys instead — a field of the in-memory
ShaderKey, and an identity of its own for the translations on disk (translated::identity_for_caps). A capable device's identity is unchanged, so its existing entries stay valid. The device is asked once, not for every translation. The mesh-shader path's own cache key, added onmainsince the first version, carries the same field.#1533 and #1551 fix the same issue (#1607, group D9). The difference that is left: this PR asks the device first and refuses a program that uses 64-bit image atomics where the capabilities are missing; the other two always emit the 64-bit form. Merging any one of the three makes the others conflict in the same
mimgarms.What is in it
crates/xcl/src/gpu/recomp/mod.rs: addint64_typed_atomic: booltoOptions(defaulttruefor standalone translation; adapter-probed in runtime and GPU test runner).crates/xcl/src/gpu/recomp/emit.rs: distinguish 32-bit vs 64-bitIMAGE_ATOMIC_*byDMASK(0x1/0x3vs0x3/0xF), refuse invalidDMASKor missingint64_typed_atomiccapability, and emit SM 6.6 64-bit typed UAV atomics (RWTexture<int64_t>directInterlockedMin/InterlockedMaxforsmin/smax,RWTexture<uint64_t>for the rest) withGLC64-bit writeback.crates/xcl/src/gpu/recomp/pso.rs: probeOPTIONS9/OPTIONS11on the runtime device (once) and passint64_typed_atomicinto the recompiler'sOptions; the capability inShaderKeyand in the disk identity (identity_for_caps), for the compute and the mesh path; unit testa_device_without_int64_typed_atomics_has_its_own_disk_entries, and the changed-key case inshader_cache_checks_context_and_blob_bytes.crates/xcl/src/gpu/recomp/runner.rs: probe the test adapter and exposeint64_typed_atomic_supported().crates/xcl/src/gpu/recomp/tests.rs: addgpu_image_atomics_64_bittesting capability refusal, invalidDMASKrefusal, and GPU execution of 64-bitadd(withGLC),umax,smin,cmpswap(withGLC,DMASK 0xF), andincacross a 32-bit carry.Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 995 passed, 0 failed, 45 ignored (SKIPPED: the wave64 / direct-DXIL per-lane tests that need 64-lane hardware or a semantics mode this adapter refuses,no heap windows, andcannot disable the driver cache (Windows Developer Mode is required))cargo test -p xcl --lib -- gpu::recomp::pso image_atomic: 16 passed, 0 failed, 1 ignored (gpu_image_atomics_64_bitran on the GPU; this adapter has both capabilities)Regression run
main (
80f4819, clean tree, no local changes):PR (
9e1e7d3, clean tree, no local changes):(Two earlier runs of this head, straight after the suite, came out at 1373 and 1284 frames with the last windows at 1–2 presents and 24–26 GB of commit. The same
mainbinary before and after them ran at 60 frames per window, so I put that down to the machine rather than the change, and the pair above is from the same state one after the other.)Not tested
AtomicInt64OnTypedResourceSupported/AtomicInt64OnDescriptorHeapResourceSupported: the refusal is tested at translation level and the cache keys in unit tests, but no such device ran the title or the suiteXCL_DIRECT_DXIL=1) for these instructions: this PR changes the HLSL path onlyAI use
smin/smaxto nativeint64_tInterlockedMin/InterlockedMaxand moved the capability into the cache keys per review feedback, wrote the tests, rebased onto80f4819, ran the test suite and thescripts/smoke.ps1runs, and drafted this PR description.