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
23 changes: 23 additions & 0 deletions docs/shader_validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,29 @@ masks, in wave32 and wave64, and in multi-wave groups. The Intel mismatches went
(50/50 native and 100/100 emulated for seeds 1 to 3). `ds_bpermute` (SHADER-31, #253) matches the model on gfx1150
too, including "an off source lane reads 0" in both wave sizes.

#### Hand-written LDS atomic fixtures (rows 321, 322, 324)

The last three DS families that had no fixed GPU check now have hand-derived fixtures, so a regression names one op
instead of a fuzz seed:

- `cs_w32_lds_mskor.asm`: `ds_mskor_b32` and `ds_mskor_rtn_b32`. DATA2 bits outside DATA are ORed in, which is why
`0x11223344` with mask `0x0000FFFF` and DATA2 `0x00000008` ends at `0x11220008`, not `0x11223348`; `0xFFFF0000`
with mask `0x00FF00FF` and DATA2 `0x00000001` ends at `0xFF000001`.
- `cs_w32_lds_atomics_incdec.asm` / `cs_w32_lds_atomics_rtn.asm`: `ds_inc_u32`, `ds_dec_u32` and `ds_rsub_u32`,
with and without return, at the `M == DATA`, `M > DATA`, `M == 0` and `M == 1` boundaries, the `DATA - M` wrap,
and the pre-op word each `_rtn_` form returns.
- `cs_w32_lds_minmax_f32.asm`: `ds_min_f32`, `ds_max_f32` and the returning forms with a qNaN in either operand,
`-0`/`+0`, and `+inf`/`-inf`.
- `cs_w32_lds_wrxchg_b64.asm`: `ds_wrxchg_rtn_b64` and `ds_wrxchg2_rtn_b64` with `offset0:1`/`offset1:2` (unit 8):
the old 64 bits, the two old pairs in vdst order, and the words written.
- `cs_w32_lds_wrxchg2st64_b64.asm`: `ds_wrxchg2st64_rtn_b64` with offsets 1 and 2 at 0x200 and 0x400 (unit 512),
plus markers at 8 and 16 so a `*8` address cannot pass.

All six ran on the RDNA2 iGPU of a Ryzen 5 9600X (`gfx1036`, RADV Mesa 27.0.0-devel, Vulkan 1.4.363) and returned
exactly the eight words in each header, through both `runtime/test/shaders/check.py` and
`scripts/run_gpu_tests.py`. `tests/semantic/test_batch5_gpu_fixtures.py` runs the same words through
`spirv_mini_interp`. No translator mismatch appeared, so there was nothing to minimise.

### Memory instructions (`tools/mem_diff.py`, FUZZ-5)

`cpu_ref.py` has no memory model, so memory instructions get their own runner. `tools/mem_diff.py`
Expand Down
20 changes: 18 additions & 2 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_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_w32_lds_mskor", "cs_w32_lds_atomics_incdec", "cs_w32_lds_atomics_rtn", "cs_w32_lds_minmax_f32", "cs_w32_lds_wrxchg_b64", "cs_w32_lds_wrxchg2st64_b64")
# 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_andn2_exec", "cs_mask_vgpr_exec", "cs_w32_permlane_fi",
"cs_w32_exec_computed")
"cs_w32_exec_computed", "cs_w32_lds_mskor", "cs_w32_lds_atomics_incdec", "cs_w32_lds_atomics_rtn", "cs_w32_lds_minmax_f32", "cs_w32_lds_wrxchg_b64", "cs_w32_lds_wrxchg2st64_b64")
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 @@ -167,6 +167,22 @@ def not_found_message(build, missing):
# ds_mskor, ds_and/xor_b64, ds_add_rtn_f32, ds_inc/dec/rsub_u32 (cs_lds_atomics_ext.asm header)
("cs_lds_atomics_ext", [0xF0F11234, 0xAB34CD78, 0x12345678, 0xF0F00F0F,
0xA5A55A5A, 0x00AA00AA, 0x7FB00000, 0xFE090700]),
# ds_mskor_b32 / ds_mskor_rtn_b32, DATA2 bits outside DATA ORed in (cs_w32_lds_mskor.asm header)
("cs_w32_lds_mskor", [0x11223344, 0x11220008, 0xFFFF0000, 0xFF000001,
0xDEADBEEF, 0x5F5F5F5F, 0xFEEDFACE, 0x12345678]),
# ds_inc/dec/rsub_u32 boundaries, DATA = 5 (cs_w32_lds_atomics_incdec.asm header)
("cs_w32_lds_atomics_incdec", [5, 0, 0, 5, 0, 4, 5, 0xFFFFFFFE]),
# the same ops' _rtn_ forms return the pre-op word (cs_w32_lds_atomics_rtn.asm header)
("cs_w32_lds_atomics_rtn", [4, 5, 0, 5, 7, 0xFFFFFFFE, 5, 0]),
# ds_min/max_f32 with NaN, +-0 and +-inf (cs_w32_lds_minmax_f32.asm header)
("cs_w32_lds_minmax_f32", [0x80000000, 0x00000000, 0x3F800000, 0x3F800000,
0x7FC00000, 0x3F800000, 0x3F800000, 0x3F800000]),
# ds_wrxchg_rtn_b64 and ds_wrxchg2_rtn_b64 (cs_w32_lds_wrxchg_b64.asm header)
("cs_w32_lds_wrxchg_b64", [0x11111111, 0x88888888, 0x22222222, 0x44444444,
0x33333333, 0xCCCCCCCC, 0xDDDDDDDD, 0xEEEEEEEE]),
# ds_wrxchg2st64_rtn_b64, the 512-byte offsets (cs_w32_lds_wrxchg2st64_b64.asm header)
("cs_w32_lds_wrxchg2st64_b64", [0x11111111, 0x44444444, 0x55555555, 0x88888888,
0x33333333, 0x77777777, 0xAAAAAAAA, 0xEEEEEEEE]),
# constant EXEC: each lane takes its own bit (Intel got 16-bit constants wrong for lanes 16-31)
("cs_exec_const", [16, 8, 2, 16, 0, 16]),
# a constant lane mask (saveexec, wrexec, s_and/s_not/s_mov_b64 into EXEC or VCC) gives lane L its bit L,
Expand Down
99 changes: 99 additions & 0 deletions runtime/test/shaders/cs_w32_lds_atomics_incdec.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
; regen_fixtures: this source has a translator fixture in tests/semantic/fixtures/disasm
; ds_inc_u32 / ds_dec_u32 / ds_rsub_u32, the non-returning 32-bit LDS atomics (RDNA2 ISA, DS).
; Only lane 0 runs the atomics. DATA = 5.
; ds_inc_u32: M = (M >= DATA) ? 0 : M + 1 (unsigned)
; ds_dec_u32: M = (M == 0 || M > DATA) ? DATA : M - 1 (unsigned)
; ds_rsub_u32: M = DATA - M (32-bit wrapping)
;
; Seeds and results (M before -> M after):
; M[0] = 4 = DATA-1 inc -> 5, the last value before the wrap
; M[4] = 5 = DATA inc -> 0, M >= DATA wraps to 0
; M[8] = 6 > DATA inc -> 0
; M[12] = 0 dec -> 5, M == 0 wraps to DATA
; M[16] = 1 dec -> 0
; M[20] = 5 = DATA dec -> 4, the last value before the wrap
; M[24] = 6 > DATA dec -> 5, M > DATA wraps to DATA
; M[28] = 7 rsub -> 5 - 7 = 0xFFFFFFFE (wraps)
;
; group: 32,1,1
; Run: vk_compute_test cs_w32_lds_atomics_incdec.spv 1 dump
; -> out[0..7] = 5 0 0 5 0 4 5 0xFFFFFFFE
; mattr: +wavefrontsize32,-wavefrontsize64
v_mov_b32_e32 v1, 0
v_mov_b32_e32 v2, 4
ds_write_b32 v1, v2
v_mov_b32_e32 v1, 4
v_mov_b32_e32 v2, 5
ds_write_b32 v1, v2
v_mov_b32_e32 v1, 8
v_mov_b32_e32 v2, 6
ds_write_b32 v1, v2
v_mov_b32_e32 v2, 0
v_mov_b32_e32 v1, 12
ds_write_b32 v1, v2
v_mov_b32_e32 v1, 16
v_mov_b32_e32 v2, 1
ds_write_b32 v1, v2
v_mov_b32_e32 v1, 20
v_mov_b32_e32 v2, 5
ds_write_b32 v1, v2
v_mov_b32_e32 v1, 24
v_mov_b32_e32 v2, 6
ds_write_b32 v1, v2
v_mov_b32_e32 v1, 28
v_mov_b32_e32 v2, 7
ds_write_b32 v1, v2
s_waitcnt lgkmcnt(0)
v_cmpx_eq_u32_e32 0, v0
v_mov_b32_e32 v3, 5
v_mov_b32_e32 v1, 0
ds_inc_u32 v1, v3
v_mov_b32_e32 v1, 4
ds_inc_u32 v1, v3
v_mov_b32_e32 v1, 8
ds_inc_u32 v1, v3
v_mov_b32_e32 v1, 12
ds_dec_u32 v1, v3
v_mov_b32_e32 v1, 16
ds_dec_u32 v1, v3
v_mov_b32_e32 v1, 20
ds_dec_u32 v1, v3
v_mov_b32_e32 v1, 24
ds_dec_u32 v1, v3
v_mov_b32_e32 v1, 28
ds_rsub_u32 v1, v3
s_waitcnt lgkmcnt(0)
v_mov_b32_e32 v1, 0
ds_read_b32 v10, v1
v_mov_b32_e32 v1, 4
ds_read_b32 v11, v1
v_mov_b32_e32 v1, 8
ds_read_b32 v12, v1
v_mov_b32_e32 v1, 12
ds_read_b32 v13, v1
v_mov_b32_e32 v1, 16
ds_read_b32 v14, v1
v_mov_b32_e32 v1, 20
ds_read_b32 v15, v1
v_mov_b32_e32 v1, 24
ds_read_b32 v16, v1
v_mov_b32_e32 v1, 28
ds_read_b32 v17, v1
s_waitcnt lgkmcnt(0)
v_mov_b32_e32 v21, 0
buffer_store_dword v10, v21, s[0:3], 0 offen
v_mov_b32_e32 v21, 4
buffer_store_dword v11, v21, s[0:3], 0 offen
v_mov_b32_e32 v21, 8
buffer_store_dword v12, v21, s[0:3], 0 offen
v_mov_b32_e32 v21, 12
buffer_store_dword v13, v21, s[0:3], 0 offen
v_mov_b32_e32 v21, 16
buffer_store_dword v14, v21, s[0:3], 0 offen
v_mov_b32_e32 v21, 20
buffer_store_dword v15, v21, s[0:3], 0 offen
v_mov_b32_e32 v21, 24
buffer_store_dword v16, v21, s[0:3], 0 offen
v_mov_b32_e32 v21, 28
buffer_store_dword v17, v21, s[0:3], 0 offen
s_endpgm
69 changes: 69 additions & 0 deletions runtime/test/shaders/cs_w32_lds_atomics_rtn.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
; regen_fixtures: this source has a translator fixture in tests/semantic/fixtures/disasm
; ds_inc_rtn_u32 / ds_dec_rtn_u32 / ds_rsub_rtn_u32 (RDNA2 ISA, DS): the _rtn_ forms return the
; pre-op word in vdst. Only lane 0 runs the atomics, so each old value is exactly the seed.
; ds_inc_rtn_u32: vdst = M, M = (M >= DATA) ? 0 : M + 1
; ds_dec_rtn_u32: vdst = M, M = (M == 0 || M > DATA) ? DATA : M - 1
; ds_rsub_rtn_u32: vdst = M, M = DATA - M (wrapping)
; DATA = 5.
;
; M[0] = 4 = DATA-1 inc_rtn -> old 4, new 5
; M[4] = 0 dec_rtn -> old 0, new 5 (M == 0 wraps to DATA)
; M[8] = 7 rsub_rtn -> old 7, new 5 - 7 = 0xFFFFFFFE (wraps)
; M[12] = 5 = DATA inc_rtn -> old 5, new 0 (M >= DATA)
;
; out[0..7] = 4 5 0 5 7 0xFFFFFFFE 5 0
;
; group: 32,1,1
; Run: vk_compute_test cs_w32_lds_atomics_rtn.spv 1 dump
; -> out[0..7] = 0x00000004 0x00000005 0x00000000 0x00000005 0x00000007 0xFFFFFFFE 0x00000005 0x00000000
; mattr: +wavefrontsize32,-wavefrontsize64
v_mov_b32_e32 v1, 0
v_mov_b32_e32 v2, 4
ds_write_b32 v1, v2
v_mov_b32_e32 v1, 4
v_mov_b32_e32 v2, 0
ds_write_b32 v1, v2
v_mov_b32_e32 v1, 8
v_mov_b32_e32 v2, 7
ds_write_b32 v1, v2
v_mov_b32_e32 v1, 12
v_mov_b32_e32 v2, 5
ds_write_b32 v1, v2
s_waitcnt lgkmcnt(0)
v_cmpx_eq_u32_e32 0, v0
v_mov_b32_e32 v3, 5
v_mov_b32_e32 v1, 0
ds_inc_rtn_u32 v5, v1, v3
v_mov_b32_e32 v1, 4
ds_dec_rtn_u32 v6, v1, v3
v_mov_b32_e32 v1, 8
ds_rsub_rtn_u32 v7, v1, v3
v_mov_b32_e32 v1, 12
ds_inc_rtn_u32 v8, v1, v3
s_waitcnt lgkmcnt(0)
v_mov_b32_e32 v1, 0
ds_read_b32 v10, v1
v_mov_b32_e32 v1, 4
ds_read_b32 v11, v1
v_mov_b32_e32 v1, 8
ds_read_b32 v12, v1
v_mov_b32_e32 v1, 12
ds_read_b32 v13, v1
s_waitcnt lgkmcnt(0)
v_mov_b32_e32 v21, 0
buffer_store_dword v5, v21, s[0:3], 0 offen
v_mov_b32_e32 v21, 4
buffer_store_dword v10, v21, s[0:3], 0 offen
v_mov_b32_e32 v21, 8
buffer_store_dword v6, v21, s[0:3], 0 offen
v_mov_b32_e32 v21, 12
buffer_store_dword v11, v21, s[0:3], 0 offen
v_mov_b32_e32 v21, 16
buffer_store_dword v7, v21, s[0:3], 0 offen
v_mov_b32_e32 v21, 20
buffer_store_dword v12, v21, s[0:3], 0 offen
v_mov_b32_e32 v21, 24
buffer_store_dword v8, v21, s[0:3], 0 offen
v_mov_b32_e32 v21, 28
buffer_store_dword v13, v21, s[0:3], 0 offen
s_endpgm
88 changes: 88 additions & 0 deletions runtime/test/shaders/cs_w32_lds_minmax_f32.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
; regen_fixtures: this source has a translator fixture in tests/semantic/fixtures/disasm
; ds_min_f32 / ds_max_f32 / ds_min_rtn_f32 / ds_max_rtn_f32 (RDNA2 ISA, DS), 512 B LDS, only lane 0.
; GLSL.std.450 NMin / NMax: one NaN operand gives the other operand, -0.0 ranks below +0.0, and an
; infinity is an ordinary operand (the other one wins when it is finite and on the right side).
;
; M[0] = +0.0 (0x00000000) min_f32 DATA -0.0 (0x80000000) -> -0.0
; M[4] = -0.0 (0x80000000) max_f32 DATA +0.0 (0x00000000) -> +0.0
; M[8] = +inf (0x7F800000) min_f32 DATA 1.0 (0x3F800000) -> 1.0
; M[12] = -inf (0xFF800000) max_f32 DATA 1.0 (0x3F800000) -> 1.0
; M[16] = qNaN (0x7FC00000) min_rtn_f32 DATA 1.0 -> old 0x7FC00000, new 1.0
; M[20] = 1.0 (0x3F800000) max_rtn_f32 DATA qNaN -> old 0x3F800000, new 1.0 (NaN loses)
;
; out[0] M[0] after 0x80000000 out[1] M[4] after 0x00000000
; out[2] M[8] after 0x3F800000 out[3] M[12] after 0x3F800000
; out[4] min_rtn old 0x7FC00000 out[5] M[16] after 0x3F800000
; out[6] max_rtn old 0x3F800000 out[7] M[20] after 0x3F800000
;
; group: 32,1,1
; Run: vk_compute_test cs_w32_lds_minmax_f32.spv 1 dump
; -> out[0..7] = 0x80000000 0x00000000 0x3F800000 0x3F800000 0x7FC00000 0x3F800000 0x3F800000 0x3F800000
; mattr: +wavefrontsize32,-wavefrontsize64
v_mov_b32_e32 v1, 0
v_mov_b32_e32 v2, 0
ds_write_b32 v1, v2
v_mov_b32_e32 v1, 4
v_mov_b32_e32 v2, 0x80000000
ds_write_b32 v1, v2
v_mov_b32_e32 v1, 8
v_mov_b32_e32 v2, 0x7f800000
ds_write_b32 v1, v2
v_mov_b32_e32 v1, 12
v_mov_b32_e32 v2, 0xff800000
ds_write_b32 v1, v2
v_mov_b32_e32 v1, 16
v_mov_b32_e32 v2, 0x7fc00000
ds_write_b32 v1, v2
v_mov_b32_e32 v1, 20
v_mov_b32_e32 v2, 0x3f800000
ds_write_b32 v1, v2
s_waitcnt lgkmcnt(0)
v_cmpx_eq_u32_e32 0, v0
v_mov_b32_e32 v1, 0
v_mov_b32_e32 v3, 0x80000000
ds_min_f32 v1, v3
v_mov_b32_e32 v1, 4
v_mov_b32_e32 v3, 0
ds_max_f32 v1, v3
v_mov_b32_e32 v1, 8
v_mov_b32_e32 v3, 0x3f800000
ds_min_f32 v1, v3
v_mov_b32_e32 v1, 12
ds_max_f32 v1, v3
v_mov_b32_e32 v1, 16
ds_min_rtn_f32 v5, v1, v3
v_mov_b32_e32 v1, 20
v_mov_b32_e32 v3, 0x7fc00000
ds_max_rtn_f32 v6, v1, v3
s_waitcnt lgkmcnt(0)
v_mov_b32_e32 v1, 0
ds_read_b32 v10, v1
v_mov_b32_e32 v1, 4
ds_read_b32 v11, v1
v_mov_b32_e32 v1, 8
ds_read_b32 v12, v1
v_mov_b32_e32 v1, 12
ds_read_b32 v13, v1
v_mov_b32_e32 v1, 16
ds_read_b32 v14, v1
v_mov_b32_e32 v1, 20
ds_read_b32 v15, v1
s_waitcnt lgkmcnt(0)
v_mov_b32_e32 v21, 0
buffer_store_dword v10, v21, s[0:3], 0 offen
v_mov_b32_e32 v21, 4
buffer_store_dword v11, v21, s[0:3], 0 offen
v_mov_b32_e32 v21, 8
buffer_store_dword v12, v21, s[0:3], 0 offen
v_mov_b32_e32 v21, 12
buffer_store_dword v13, v21, s[0:3], 0 offen
v_mov_b32_e32 v21, 16
buffer_store_dword v5, v21, s[0:3], 0 offen
v_mov_b32_e32 v21, 20
buffer_store_dword v14, v21, s[0:3], 0 offen
v_mov_b32_e32 v21, 24
buffer_store_dword v6, v21, s[0:3], 0 offen
v_mov_b32_e32 v21, 28
buffer_store_dword v15, v21, s[0:3], 0 offen
s_endpgm
Loading
Loading