Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/design.md

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions runtime/test/shaders/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ def not_found_message(build, missing):
"cs_w32_partial_scmp", "cs_w32_partial_permute", "cs_exec_const", "cs_w32_mask_imm", "cs_w32_int_ext",
"cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", "cs_w32_sincos", "cs_lds_b64_cmpst", "cs_lds_xchg64_ext", "cs_lds_atomics_ext", "cs_w32_wrxchg2_ext", "cs_w32_wrxchg2st64", "cs_w32_andn2_exec",
"cs_mask_vgpr_exec", "cs_w32_buffer_sub16", "cs_w32_buffer_store_sub", "cs_w32_fcmpswap", "cs_w32_permlane_fi",
"cs_w32_exec_computed")
"cs_w32_exec_computed", "cs_exec_copy")
# Wave32 lane-mask dumps: their EXEC/VCC masks and lane selects cover 32 lanes, so a device whose widest subgroup is
# narrower (Mesa llvmpipe: 8) can't produce their words. They are skipped there, as ps_bitmask_perm is. They run with
# 32 lanes requested (WAVE32_LANE_ENV), as run_gpu_tests.py does: a device with a range like 8..32 (Intel ANV) may
# otherwise pick a narrower size and return different words (#774).
WAVE32_LANE_ENV = {"VKC_SUBGROUP_SIZE": "32"}
WAVE32_LANE_DUMPS = ("cs_wqm_w32", "cs_w32_lane_wrap", "cs_w32_permute", "cs_bpermute32", "cs_w32_partial_scmp", "cs_w32_partial_permute", "cs_exec_const",
"cs_w32_mask_imm", "cs_lds_b64_cmpst", "cs_lds_xchg64_ext", "cs_lds_atomics_ext", "cs_w32_wrxchg2_ext", "cs_w32_wrxchg2st64", "cs_w32_andn2_exec", "cs_mask_vgpr_exec", "cs_w32_permlane_fi",
"cs_w32_exec_computed")
"cs_w32_exec_computed", "cs_exec_copy")
CS_DPP = [("cs_dpp", [1, 0, 3, 2, 5, 4, 7, 6]),
("cs_dpp_row", [0, 0, 1, 2, 3, 4, 5, 6]),
("cs_dpp_mask", [1, 0, 3, 2, 0xeeeeeeee, 0xeeeeeeee, 0xeeeeeeee, 0xeeeeeeee]),
Expand Down Expand Up @@ -210,7 +210,11 @@ def not_found_message(build, missing):
("cs_barrier_loop", [128, 96, 64, 32, 128, 96, 64, 0xEEEEEEEE]),
# SHADER-21 part 2: a mask copied to a VGPR with v_mov_b32 respects EXEC (inactive lanes keep the old VGPR)
("cs_mask_vgpr_exec", [0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
0xDEADBEEF, 0xDEADBEEF, 0xDEADBEEF, 0xDEADBEEF])]
0xDEADBEEF, 0xDEADBEEF, 0xDEADBEEF, 0xDEADBEEF]),
# EXEC restored through an SGPR copy keeps the narrowing's identity: the mask word still
# gathers (cs_exec_copy.asm header); out[1] is exec_lo's own word, 0xFFFFFFFF
("cs_exec_copy", [0xAAAAAAAA, 0xFFFFFFFF, 0xAAAAAAAA, 0,
0xAAAAAAAA, 0xFFFFFFFF, 0xAAAAAAAA, 1])]
# num_records bounds check (cs_bounds.asm): one thread, so no 64-wide subgroup requirement.
# The SMEM and raw MUBUF rules measured on an RX 6800 (derivations in each .asm header): one thread too.
# Never run cs_smem_sload_neg with a translator that zero-extends the s_load immediate: it reads 4 GiB past the heap.
Expand Down
40 changes: 40 additions & 0 deletions runtime/test/shaders/cs_exec_copy.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
; regen_fixtures: this source has a translator fixture in tests/semantic/fixtures/disasm
; EXEC restored through an SGPR copy keeps the narrowing's identity (mask-regs EXEC tracking, #1397 review):
; s7 = 0xffffffff comes from v_readfirstlane_b32, so the translator can't fold it; s_mov_b32 exec_lo, s7 is an
; EXEC write the analysis can only name as an unknown narrowing. s8 = the odd-lane mask is written under it,
; s4 = exec_lo / exec_lo = s4 round-trips EXEC through an SGPR unchanged, and the mask-word read must still
; gather — lanes return the wave's mask word, not this lane's 0 / ~0 bit, exactly as s_mov_b32 exec_lo, -1 gives.
; Before the fix the copy lost the narrowing's tag, the restore minted a fresh one, mask_exec_sigs coverage
; failed and every lane stored its own bit (0 or ~0) instead of 0xAAAAAAAA.
; Per lane (stride 16 bytes): out[0] = s8's mask word after the SGPR round-trip (0xAAAAAAAA),
; out[1] = exec_lo's word (0xFFFFFFFF: EXEC really is all-ones), out[2] = the same mask word after the
; literal -1 restore, out[3] = the lane id.
; Lane 0 stores words 0..3, lane 1 words 4..7 (checked by the dump's first eight words).
; group: 32,1,1
; Run: VKC_SUBGROUP_SIZE=32 vk_compute_test cs_exec_copy.spv 1 dump -> out[0..7] = aaaaaaaa ffffffff aaaaaaaa 0 aaaaaaaa ffffffff aaaaaaaa 1
; mattr: +wavefrontsize32,-wavefrontsize64
v_mov_b32_e32 v7, -1
v_readfirstlane_b32 s7, v7
s_mov_b32 exec_lo, s7
v_and_b32 v1, 1, v0
v_cmp_ne_u32_e64 s8, v1, 0
s_mov_b32 s4, exec_lo
s_mov_b32 exec_lo, s4
v_mov_b32_e32 v2, s8
v_mov_b32_e32 v4, exec_lo
s_mov_b32 exec_lo, -1
v_mov_b32_e32 v5, s8
v_lshlrev_b32_e32 v3, 4, v0
v_mov_b32_e32 v20, v2
v_mov_b32_e32 v21, v3
buffer_store_dword v20, v21, s[0:3], 0 offen
v_mov_b32_e32 v20, v4
v_add_nc_u32_e32 v21, 4, v3
buffer_store_dword v20, v21, s[0:3], 0 offen
v_mov_b32_e32 v20, v5
v_add_nc_u32_e32 v21, 8, v3
buffer_store_dword v20, v21, s[0:3], 0 offen
v_mov_b32_e32 v20, v0
v_add_nc_u32_e32 v21, 12, v3
buffer_store_dword v20, v21, s[0:3], 0 offen
s_endpgm
10 changes: 7 additions & 3 deletions scripts/run_gpu_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1212,8 +1212,8 @@ def run_suite(a, work: str) -> int:
"cs_w64x_lds_war", "cs_w64x_partial", "cs_w64x_sbarrier", "cs_w64x_load_ballot_load",
"cs_w64x_mask_reuse", "cs_w64x_mask_reuse2", "cs_w64x_chain_barrier", "cs_barrier_divergent",
"cs_bpermute32", "cs_w64x_partial_scmp", "cs_w64x_partial_swizzle", "cs_w32_partial_scmp", "cs_w32_partial_permute", "cs_barrier_early_end",
"cs_barrier_loop", "cs_w64x_andn2_exec", "cs_w64x_saveexec_b64", "cs_w64x_cmp_sdst", "cs_lds_b64_cmpst", "cs_lds_xchg64_ext", "cs_lds_atomics_ext", "cs_w32_wrxchg2_ext", "cs_w32_wrxchg2st64", "cs_w32_andn2_exec",
"cs_mask_vgpr_exec", "cs_w32_exec_computed", "cs_w64_exec_computed"):
"cs_barrier_loop", "cs_w64x_andn2_exec", "cs_w64x_saveexec_b64", "cs_w64x_cmp_sdst", "cs_lds_b64_cmpst", "cs_lds_xchg64_ext", "cs_lds_atomics_ext", "cs_w32_wrxchg2_ext", "cs_w32_wrxchg2st64", "cs_w32_andn2_exec",
"cs_mask_vgpr_exec", "cs_w32_exec_computed", "cs_w64_exec_computed", "cs_exec_copy"):
cs_dump_wants = {
"cs_store": [0x400080FF, 0xE00003FF, 0x3C004000, 0xEEEEEEEE, 0x40003C00, 0xBC003800, 0x40FF8000, 0x3FF00000],
# base + soffset + imm (cs_smem_soffset_imm.asm); out[4..7] are seeds the shader leaves alone
Expand Down Expand Up @@ -1331,6 +1331,10 @@ def run_suite(a, work: str) -> int:
# inactive lanes keep the old VGPR (cs_mask_vgpr_exec.asm)
"cs_mask_vgpr_exec": [0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
0xDEADBEEF, 0xDEADBEEF, 0xDEADBEEF, 0xDEADBEEF],
# EXEC round-tripped through an SGPR copy keeps its narrowing's identity: the mask
# word gathers as the literal -1 restore does (cs_exec_copy.asm header)
"cs_exec_copy": [0xAAAAAAAA, 0xFFFFFFFF, 0xAAAAAAAA, 0,
0xAAAAAAAA, 0xFFFFFFFF, 0xAAAAAAAA, 1],
}
want = cs_dump_wants[name]
# Every dump but cs_store / cs_smem_soffset_imm / cs_w32_lane_wrap / cs_movrelsd_2 / cs_w32_permute /
Expand All @@ -1353,7 +1357,7 @@ def run_suite(a, work: str) -> int:
"cs_lds_b64_cmpst", "cs_lds_xchg64_ext", "cs_lds_atomics_ext", "cs_w32_wrxchg2_ext", "cs_w32_wrxchg2st64", "cs_exec_const", "cs_w32_mask_imm", "cs_mask_vgpr_exec",
"cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8",
"cs_dpp_ops", "cs_dpp_bound", "cs_dpp_bank", "cs_dpp_fi", "cs_dpp_cmp", "cs_w32_andn2_exec",
"cs_w32_exec_computed") and not emulated and not partial
"cs_w32_exec_computed", "cs_exec_copy") and not emulated and not partial
if partial:
cs_env = dict(os.environ, VKC_SUBGROUP_SIZE="32" if emulated else "64")
if name in WAVE32_LANE_DUMPS: # 32 lanes even without index.json, as check.py requests (#774)
Expand Down
3 changes: 3 additions & 0 deletions tests/semantic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ instruction family per file; the list below describes some of them, not every fi
(MoltenVK) would inline it into a short-circuiting `&&`/`||` or a ternary's arm, for 11 DPP16/DPP8 forms with
and without a lane off in EXEC, using a model of SPIRV-Cross's single-use forwarding (its own tests cover the
model). It also runs the same programs in `spirv_wave_interp.py` against a plain-Python DPP reference.
- `test_wave_mask_eager.py` (SHADER-WAVEMASK-EAGER) does the same for the whole-wave mask gather: `v_mbcnt`,
`s_bcnt1` and `s_ff1` of a compare mask, of VCC and of EXEC, read while EXEC is narrowed, leave no subgroup op in
a ternary's arm, in a compute, a vertex and a pixel shader, and `v_mbcnt` counts the lanes that are off.

Limits: single lane (or lanes in lockstep, one instruction per lane per round, that exchange values only through
`OpGroupNonUniformShuffle`, `Ballot`, `Any`, `All` and `BitwiseOr` Reduce), control flow followed one branch at a time (the fragment-exit discard test, the compute
Expand Down
26 changes: 26 additions & 0 deletions tests/semantic/fixtures/disasm/cs_exec_copy.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
; cs_exec_copy test fixture generated by tests/semantic/regen_fixtures.py from runtime/test/shaders/cs_exec_copy.asm
v_mov_b32_e32 v7, -1
v_readfirstlane_b32 s7, v7
s_mov_b32 exec_lo, s7
v_and_b32 v1, 1, v0
v_cmp_ne_u32_e64 s8, v1, 0
s_mov_b32 s4, exec_lo
s_mov_b32 exec_lo, s4
v_mov_b32_e32 v2, s8
v_mov_b32_e32 v4, exec_lo
s_mov_b32 exec_lo, -1
v_mov_b32_e32 v5, s8
v_lshlrev_b32_e32 v3, 4, v0
v_mov_b32_e32 v20, v2
v_mov_b32_e32 v21, v3
buffer_store_dword v20, v21, s[0:3], 0 offen
v_mov_b32_e32 v20, v4
v_add_nc_u32_e32 v21, 4, v3
buffer_store_dword v20, v21, s[0:3], 0 offen
v_mov_b32_e32 v20, v5
v_add_nc_u32_e32 v21, 8, v3
buffer_store_dword v20, v21, s[0:3], 0 offen
v_mov_b32_e32 v20, v0
v_add_nc_u32_e32 v21, 12, v3
buffer_store_dword v20, v21, s[0:3], 0 offen
s_endpgm
Loading
Loading