[Bug] Fix SPIR-V dominance of the adstack heap stride loads.#806
Conversation
…V ids dominate sibling branch push sites.
ea0f597 to
fe617bf
Compare
|
Genesis PR #2842 (29e2c22e5) x quadrants PR #806 (fe617bffe), with the Genesis-side Metal gradient skip lifted. MacBook Pro: MacBook Pro: The 2 skips are the fp64 arms, which Metal does not support. |
|
@codex review |
|
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|
Production CI: |
|
ok to merge |
|
Note: no need for Genesis benchmarks, because spir-v specific, and benchmarks don't exercise spir-v. |
Issue: #805
The reverse-mode collapse reported in #805 is not an Apple compiler uniformity bug:
get_ad_stack_metadata_stride_(float|int)memoize the stride OpLoad at their first call site, so when the first f32 heap access of a task sits inside one arm of a runtimeif, every access in the sibling arm reuses an SSA id that does not dominate it.spirv-valrejects the module (section 2.16), but SPIRV-Cross does not validate and emits the reused id as a plain uninitialized MSL variable, so the per-thread heap baserow_id * stridemultiplies a correct per-lanerow_idby a garbage stride (typically 0) and every thread of the dispatch races on the same heap row. The fix seeds both memoized stride loads at the task entry block (preload_ad_stack_metadata_strides, called from eachgenerate_*_kernel, gated on the pre-pass adstack count so adstack-free tasks do not bind the metadata buffer).Brief Summary
copilot:summary
Walkthrough
copilot:walkthrough