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

Open
opened 2026-11-26 04:53:05 +00:00 by github-bot · 1 comment
Owner

@⁠pvfreis on GitHub · 2026-11-24 15:41 UTC · original

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.

**@⁠pvfreis** on GitHub · 2026-11-24 15:41 UTC · [original](https://github.com/xcl-dev/xcl/issues/1409) 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:53:05 +00:00
Author
Owner

@⁠tiagonogueiraa-bit on GitHub · 2026-11-24 15:42 UTC · original

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).

**@⁠tiagonogueiraa-bit** on GitHub · 2026-11-24 15:42 UTC · [original](https://github.com/xcl-dev/xcl/issues/1409#issuecomment-7136484125) 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).
This discussion has been locked. Commenting is limited to contributors.
No description provided.