Repository navigation
Keep the permlane FI/BOUND_CTRL subgroup operations convergent on MoltenVK (fixes #5895) - #6322
Open
autowert66 wants to merge 1 commit into
Open
autowert66 wants to merge 1 commit into
autowert66 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5895. Claim: #6089 (comment)
Problem. The FI=0 / BOUND_CTRL handling of
v_permlane16_b32/v_permlanex16_b32(SHADER-74,71d8f8685) applied its result with a scalarOpSelect— firstok ? value : old-or-zero, then dst()'sactive ? … : old. MoltenVK's SPIRV-Cross lowers scalar selects to short-circuiting Metal ternaries, moving the ballot and both shuffles into divergent control flow; thevaluearm then wins, and the FI=0 lanes read the off source lane's value instead of keeping the old one (or zero). Measured on Apple M1 Max / MoltenVK 1.4.2, and on a fresh MoltenVKmainbuild at SPIRV-Crossaa217aeb— which includes all four revisionsdocs/testing.mdcites for the other MoltenVK fixes, among them5c372ffb"control dependent expressions don't end up in a ternary":cs_w32_permlane_fifails without[0..7] = 4 4 4 1 52 52 52 49, want1000 0 4 1 1000 0 52 49. KosmicKrisp and the CPU model pass. It is the same driver shape #932 fixed fords_bpermute.Change. The FI=0 path on a native subgroup now redirects absent source lanes to the calling lane (as
ds_lane_readdoes), fetches the value and the source lane's activity bit through the redirected index, and combines with bitwise masks —ok ? value : oldbecomesvalue & mask | old & ~mask,ok ? value : 0becomesvalue & mask— and the destination write uses dst()'seagermasks, so the ballot and both shuffles run before lane predication. FI=1 and--wave64-emulateare unchanged (no subgroup op reaches MSL from the emulated path; its tests pin that).Verification, Apple M1 Max (32-core GPU), macOS 27.2.1, llvm-mc 23.1.6, SPIRV-Tools v2026.4:
cs_w32_permlane_fi, MoltenVK 1.4.24 4 4 1 52 52 52 491000 0 4 1 1000 0 52 49cs_w32_permlane_fi, MoltenVKmain@ SPIRV-Crossaa217aebcs_w32_permlane_fi, KosmicKrisp (Homebrewmesa26.3.1)tests/semantic/test_valu_permlane16.py,test_permlane_fi.pytests/semanticdiscoverrun_gpu_tests.py, MoltenVK 1.4.2,main561b65a83+ this changecs_fma_fused,ps_ssharp, the fiveps_vcmp*); no other test changedrun_gpu_tests.py, KosmicKrispcs_bvh,cs_bvh32,ps_cndmask_sign_mods,ps_valu16_mad_sel) — unchangedcrosslane_fuzz.py, seed 1, 50 programs, wave32 native, MoltenVK 1.4.2, standard model--permlane-fetch-inactive(which models the off-lane fetch as FI=1) the fixed GPU now correctly diverges from that modelAI-assisted (OpenCode / DeepSeek V4.1 Flash + GLM-5.3): the agents wrote the change, ran the suites and fuzzers sandboxed on the hardware above, and wrote this PR.