Shaders: translations made with XCL_SAFE_BARRIER=0 are cached and reused by later runs #1399

Closed
opened 2026-11-24 15:41:58 +00:00 by pvfreis · 2 comments
pvfreis commented 2026-11-24 15:41:58 +00:00 (Migrated from github.com)
Contributor

Imported from ivall/xcl. Originally posted by pvfreis on 2026-11-24T15:41:58Z.


On main (930e8b4), XCL_SAFE_BARRIER=0 (0c02b87) changes the HLSL the recompiler emits for s_barrier in multi-wave compute programs (emit.rs:553), but it is not in cache_allowed's list of variables that turn the translation caches off (pso.rs:448-451), and the cache key (ShaderKey, and the file name and header in translated) does not include it. So a run, or xcl shaders --precompile, with XCL_SAFE_BARRIER=0 stores those programs' DXIL with the plain group barrier, and later runs without the variable load it before any translation, so the early-exit-safe barrier of 0c02b87 is silently missing for them. In the other order, XCL_SAFE_BARRIER=0 has no effect on programs already in the cache. Either way it lasts as long as those cache files are used (same translator sources and DXC).

Run on main (local tests, not for upstream; no GPU needed): translating a 128-thread compute program with S_BARRIER gives HLSL with xcl_s_barrier(); with the variable unset and without it with XCL_SAFE_BARRIER=0, and the assertion !cache_allowed(Stage::Compute, |n| n == "XCL_SAFE_BARRIER") fails. The cache round trip itself was read, not run.

Suggested fix: add "XCL_SAFE_BARRIER" to the list in cache_allowed and to shader_cache_bypasses_debug_overrides (pso.rs:907). #1284 (XCL_LOOP_BUDGET), #245 (XCL_CS_PAD_ALL, XCL_NO_CS_PAD) and #613 (XCL_DXC_ARGS) add names to the same list and test, so a fix touches the same lines.

Found by reading the code and confirmed with local tests on main by Claude Code (Claude Opus 5.5 found it, Claude Sonnet 5.5 ran the tests, Claude Fable 5.2 re-checked it); checked by a person before posting.

<!-- greyfinch-sync:ivall/xcl:issue:6585602323 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/1409). Originally posted by [pvfreis](https://github.com/pvfreis) on 2026-11-24T15:41:58Z. --- On `main` (`930e8b4`), `XCL_SAFE_BARRIER=0` (0c02b87) changes the HLSL the recompiler emits for `s_barrier` in multi-wave compute programs (`emit.rs:553`), but it is not in `cache_allowed`'s list of variables that turn the translation caches off (`pso.rs:448-451`), and the cache key (`ShaderKey`, and the file name and header in `translated`) does not include it. So a run, or `xcl shaders --precompile`, with `XCL_SAFE_BARRIER=0` stores those programs' DXIL with the plain group barrier, and later runs without the variable load it before any translation, so the early-exit-safe barrier of 0c02b87 is silently missing for them. In the other order, `XCL_SAFE_BARRIER=0` has no effect on programs already in the cache. Either way it lasts as long as those cache files are used (same translator sources and DXC). **Run on `main`** (local tests, not for upstream; no GPU needed): translating a 128-thread compute program with `S_BARRIER` gives HLSL with `xcl_s_barrier();` with the variable unset and without it with `XCL_SAFE_BARRIER=0`, and the assertion `!cache_allowed(Stage::Compute, |n| n == "XCL_SAFE_BARRIER")` fails. The cache round trip itself was read, not run. **Suggested fix:** add `"XCL_SAFE_BARRIER"` to the list in `cache_allowed` and to `shader_cache_bypasses_debug_overrides` (`pso.rs:907`). #1284 (`XCL_LOOP_BUDGET`), #245 (`XCL_CS_PAD_ALL`, `XCL_NO_CS_PAD`) and #613 (`XCL_DXC_ARGS`) add names to the same list and test, so a fix touches the same lines. Found by reading the code and confirmed with local tests on `main` by Claude Code (Claude Opus 5.5 found it, Claude Sonnet 5.5 ran the tests, Claude Fable 5.2 re-checked it); checked by a person before posting.
tiagonogueiraa-bit commented 2026-11-24 16:07:12 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by tiagonogueiraa-bit on 2026-11-24T15:42:45Z.


claiming: XCL_SAFE_BARRIER goes into cache_allowed's list, and shader_cache_bypasses_debug_overrides gets an assertion for it that fails on main. PR shortly.

Written with Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7136484125 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/issues/1409#issuecomment-7136484125). Originally posted by [tiagonogueiraa-bit](https://github.com/tiagonogueiraa-bit) on 2026-11-24T15:42:45Z. --- claiming: `XCL_SAFE_BARRIER` goes into `cache_allowed`'s list, and `shader_cache_bypasses_debug_overrides` gets an assertion for it that fails on main. PR shortly. Written with Claude Code (Claude Opus 5.5).
pvfreis commented 2026-12-03 01:04:59 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by pvfreis on 2026-12-03T01:04:59Z.


Fixed on main by 0d0a45213 ("Recompiler: no translated disk cache while XCL_SAFE_BARRIER is set"): XCL_SAFE_BARRIER is now in cache_allowed's list (gpu/recomp/pso.rs), so a run with it set neither reads nor writes the translated disk cache. Closing.

<!-- greyfinch-sync:ivall/xcl:comment:7363929666 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/1409#issuecomment-7363929666). Originally posted by [pvfreis](https://github.com/pvfreis) on 2026-12-03T01:04:59Z. --- Fixed on main by 0d0a45213 ("Recompiler: no translated disk cache while XCL_SAFE_BARRIER is set"): `XCL_SAFE_BARRIER` is now in `cache_allowed`'s list (`gpu/recomp/pso.rs`), so a run with it set neither reads nor writes the translated disk cache. Closing.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl#1399
No description provided.