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). |
|
Tested Independent Windows run for PR #1541 at clean detached
& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test {
& 'L:/XclTooling/verify-pr1523-1362129-t3-cf2e05e7/target/debug/build/xcl/77aca8ccb20e299f/out/xcl-77aca8ccb20e299f.exe' --exact gpu::recomp::tests::gpu_image_atomics_64_bit --nocapture --test-threads=1
}Libtest reported 1 passed, 0 failed, 0 ignored, with 970 filtered out and 0.15 s elapsed. The two CPU translation assertions passed (capability disabled and invalid DMASK rejected). The fixture then reported 1 GPU skip with A separate Windows SDK 10.0.26100.0 D3D12 feature probe identified the gate on this adapter. Both queries returned Not tested Live 64-bit atomic results, device cache behavior, direct DXIL, other adapters, the full suite, and title smoke runs. AI use T3 Code / Codex (gpt-6.2-sol) verified the checkout, ran the checked-in fixture and the standalone feature probe, and wrote this report. |
|
@JJAutoCompare thank you — that is the first run of this test on a device without the capability, and it behaves as the PR says it should: the two CPU assertions pass and the GPU part skips with One thing this PR needs before it can move: |
…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.) (On the current main, the mimg emitter's atomics take the width from DMASK through one dispatch, which then keeps the mw32 arm main extracted for the operations without an int view.)
9e1e7d3 to
99d80ad
Compare
|
The merge onto current Two things that changed in the process:
Suite: 1156 passed, 0 failed, 46 ignored. Smoke blocks for |
…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.) (On the current main, the mimg emitter's atomics take the width from DMASK through one dispatch, which then keeps the mw32 arm main extracted for the operations without an int view.)
99d80ad to
130815d
Compare
|
Merged again, onto Head
One caveat on the treadmill: |
|
Independent Windows run on 130815d. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC, DXC 1.8.2502.11, debug. On the exact revision, With this revision merged locally into 426a5a7, the same build and test commands reported 1,245 passed, 0 failed, 46 ignored. Both runs had 25 runtime skip notices included in Cargo's pass count. I also fed the integrated HLSL path LLVM MC 23.1.6 gfx1030 encodings for 64-bit Synthetic HLSL-path coverage only. AI-assisted. Codex (GPT-6, exact variant unavailable) wrote the fixture, ran the tests, and drafted this report. |
|
AMD run, plus an RTX 3060: Head
Not tested: the direct DXIL path ( |
|
Thank you — that closes the AMD gap: gpu_image_atomics_64_bit runs and passes on an RX 9070 XT with native wave64, and on an RTX 3060, with no skip on either, so both adapters report AtomicInt64OnTypedResourceSupported and the descriptor-heap capability. I added that to Tested and dropped AMD from Not tested; the two failures in your run are the #2115 fuzz seeds and are the same on main. Still untested here: an adapter without the capabilities (the Arc A770 report covers the translation-level refusal only) and the direct DXIL path. AI use: OpenCode, Claude Fable 5.2. |
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 matchingrmw32forinc/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, which the rerouted direct entries keep too). A capable device's identity is unchanged, so its existing entries stay valid. The device is asked once, not for every translation.On the current
main: themimgatomics were refactored while this PR waited (onermw32arm for the operations without an int view), and the disk cache now checks that a stored DXIL is a container. The width decode feeds a single dispatch that keeps thatrmw32arm for the 32-bit case and adds the 64-bit one beside it, and every atomic'sResourceDescriptorHeap[...]handle is made insideif (and(act, ok))ÔÇö whatmain's newmimg_view_and_sampler_heap_indices_are_guardedtest requires.#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:atomic_widthfromDMASK(cmpswap/fcmpswap:0x332-bit,0xF64-bit; the rest:0x132-bit,0x364-bit), refusal of anything else or of the 64-bit form without the capability, and the SM 6.6 64-bit typed UAV atomics withGLC64-bit writeback; the existingrmw32arm serves the 32-bit operations that have no int view.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:gpu_image_atomics_64_bitÔÇö capability refusal, invalidDMASKrefusal, and GPU execution of 64-bitadd(withGLC),umax,smin,cmpswap(withGLC,DMASK 0xF), andincacross a 32-bit carry. It skips withdirect DXIL: no 64-bit image atomicsunderXCL_DIRECT_DXIL=1, since the direct translator lowersmimgitself and this PR does not change it.Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1: 1173 passed, 2 failed, 26 ignored. The two failures aregpu::recomp::pso::shader_cache_tests::rerouted_disk_entries_follow_the_direct_translatorandhle::d3d12x::device_x::tests::pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa; both fail the same way on unmodifiedmaina7ec0dbon this machine (checked with the same command), so they are not from this change.cargo test -p xcl --lib -- gpu_image_atomics_64_bit: 1 passed (the 64-bit GPU run; this adapter has both capabilities)gpu::dxil::lower_image::heap_bounds_tests::mimg_view_and_sampler_heap_indices_are_guarded: passescargo test -p xcl --lib -- a_device_without_int64_typed_atomics_has_its_own_disk_entries: 1 passedgpu_image_atomics_64_biton an RX 9070 XT (RDNA4, native wave64) and an RTX 3060: it runs, with no skip on either (both report the capabilities), and passes on both; the two failures in theirgpu::run are the DXIL fuzz tests: fuzz_validate_and_gpu_1 fails on AMD (seed 722 and others, RDNA2-4), so the default suite is red there #2115 fuzz seeds, the same onmainOPTIONS9.AtomicInt64OnTypedResourceSupported = 0,OPTIONS11.AtomicInt64OnDescriptorHeapResourceSupported = 1): both CPU assertions passed and the GPU part reportedno int64 typed image atomics, as designed.Regression run
main (
a7ec0db, clean tree, no local changes):PR (
130815d, clean tree, no local changes):Not tested
AtomicInt64OnTypedResourceSupported/AtomicInt64OnDescriptorHeapResourceSupported(the Arc A770 report above covers the translation-level refusal and the test's skip only)XCL_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, merged the change intomain's refactoredmimgarms and heap guard, wrote the tests, ran the test suite and thescripts/smoke.ps1runs, and drafted this PR description.