Repository navigation
Shaders: narrow divergent scalar state detection - #14
mohammadallami75-ops wants to merge 4 commits into
Conversation
Keep the maintainer's joined-mask lowering, preserve the distinct scalar-state detection, and retain both regression sets. AI-assisted.
|
Updated this branch to I ran the same synthetic shaders and compared GPU readback against a CPU reference on an RTX 2080 SUPER (driver 621.01, host Wave32). Counts are for one adapter run.
The four portable control cases also matched on WARP. All 44 focused tests passed, and the shader suite finished with 173 passed and 1 ignored. The asset policy passed. The workspace run had one loader fixture failure because the portable linker rejected the MSVC delay-load option. Both loader fixture tests passed with the equivalent option in a separate scratch checkout. For any offline title comparison, the relevant pair is now AI-assisted. |
r4tedx
left a comment
There was a problem hiding this comment.
Review of 7d97aa8 (thanks for the update). The code looks sound to me, and I'm not merging yet. Two checks are still open.
What I checked:
- The joined-mask rule is unchanged (
lower.rs:621-638). The new detector skips mask phis, including exit masks grown from zero, andan_exit_mask_grown_from_zero_does_not_count_as_scalar_statecovers that. - Splitting the mask-read check out of
wholegives the samereads_wholeas before. The flag reaches the console-structure pass (mod.rs:365), and the per-lane fallback clears it, so every lowering pass makes the same choice. - Tests: the base has 35 split tests and this PR has 44. None were removed.
Runs, all one at a time with --test-threads=1, synthetic only, no title data, no hardware adapter:
cargo test -p victory-shader --lib emit::split_testswith no hardware adapter listed (CI-like): 44 passed, 0 failed. The 4 per-lane cases print "WARP: per-lane readback exact", and the console-flow cases skip.- With WARP standing in for every adapter: the same 31 base failures as on
c734600, plus 3 from the new console-flow cases. That's expected, because WARP has 4 lanes and those cases need a 32-lane adapter. cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
Open before merge:
- The offline before/after count (
c734600vs7d97aa8, 32-32 and 32-64), which you asked for. I'll post it here when it's done. - A 32-lane hardware run of the three new console-flow tests (both scalar-counter loop tests and
disjoint_branch_paths_update_the_same_scalar_in_order). So far only your RTX 2080 SUPER has run them. If a tester can run them on another 32-lane card, that would cover it. - Merge risk: the base
shader/wave-per-groupdoesn't have1aade1f(implicit-derivative sample guard) or7147671(recursion guard on a mask copied dword by dword). This PR sends more programs into the console flow, so I'll bring those into the base first.
Nit, optional: lower.rs:619 wants_console_flow |= scalar_console_flow ignores no_console_flow. On a 32-lane host with a multi-wave LDS group, this makes a console-flow attempt that is bound to fail before the per-lane fallback. The output is still right (divergent_scalar_state_uses_console_flow_per_wave asserts the fallback), but it costs translate time. Gating it on no_console_flow.is_none() would avoid that.
Scope note for the description: Wave32 programs and non-compute stages keep the old lowering, and so does a probe that hits the diagram size limit. That's safe, just narrower than "every scalar that survives divergence".
AI-assisted
Run the new scalar readback fixtures under the existing GPU test lock. The fixtures all open WARP and could otherwise overlap each other and the VALU and waterfall tests, which already use the lock to avoid access violations during parallel runs. AI-assisted.
|
Thanks for the review. I followed up on the parallel Windows test crash in I updated the description to reflect the narrower scope. The follow-up only touches the test harness, so the offline comparison is still AI-assisted. |
r4tedx
left a comment
There was a problem hiding this comment.
Thanks. d21eb16 looks right. It takes the same valu_tests::ONE_AT_A_TIME static the VALU and waterfall fixtures take, with the same poison handling. Nothing on the call path takes it a second time, and only test code changes. Each fixture builds its own Host and Validator, so this is the known concurrent-WARP crash (valu_tests.rs:166-171), not a hidden defect.
Two things are needed before this can merge:
- Conflict with the base.
shader/wave-per-groupis now at6551f22(#17).git merge-treereports a conflict at the end ofsplit_tests.rs, where both sides add tests. Keeping both sides resolves it. - The new fixtures ignore
VICTORY_WARP=1.per_lane_scalar_casecallsadapters().unwrap_or_default()andHost::on(split_tests.rs:1480), and those open hardware adapters whatever the variable says. After the merge, please switch it to the base'shardware_adapters(), as d96a6cb did for the other split tests. Until then we can't run these fixtures here: our tests are on the software adapter only for now.
Still open from the earlier review: the offline count c734600 vs the head at 32-32 and 32-64, a 32-lane run of the three console-flow tests, and 1aade1f/7147671 going into the base first.
AI-assisted.
Part 2 of the scalar-state review. The base is
shader/wave-per-groupatc734600, which carries r4tedx’s broadened mask handling and the fixtures from #13.Shader change
The detector identifies Wave64 compute shaders where a scalar updated in divergent control flow is read after the paths rejoin. Eligible shaders use console flow to preserve the wave-wide scalar value. Wave32 programs, non-compute stages and analysis that exceeds the diagram size limit keep their existing lowering. Unsupported console-flow cases can fall back to per-lane lowering.
Windows CI follow-up
The previous CI run stopped with an access violation in the shader test process. The four new portable scalar fixtures ran WARP outside the lock already shared by the VALU and waterfall tests.
d21eb16takes the same lock for their readbacks. Shader translation is identical to7d97aa8.Synthetic verification
c734600versusd21eb16at32-32and32-64. A second physical Wave32 adapter run is still open. The reviewer also plans to bring two existing translator safeguards into the base before merge. Game rendering and frame rate remain unmeasured.AI-assisted.