diff --git a/docs/shader_validation.md b/docs/shader_validation.md index ac33debfaf..36e1827a54 100644 --- a/docs/shader_validation.md +++ b/docs/shader_validation.md @@ -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` diff --git a/runtime/test/shaders/check.py b/runtime/test/shaders/check.py index f0ddf2f315..cd47a09670 100644 --- a/runtime/test/shaders/check.py +++ b/runtime/test/shaders/check.py @@ -110,7 +110,7 @@ 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 @@ -118,7 +118,7 @@ def not_found_message(build, missing): 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]), @@ -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, diff --git a/runtime/test/shaders/cs_w32_lds_atomics_incdec.asm b/runtime/test/shaders/cs_w32_lds_atomics_incdec.asm new file mode 100644 index 0000000000..da8e98601a --- /dev/null +++ b/runtime/test/shaders/cs_w32_lds_atomics_incdec.asm @@ -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 diff --git a/runtime/test/shaders/cs_w32_lds_atomics_rtn.asm b/runtime/test/shaders/cs_w32_lds_atomics_rtn.asm new file mode 100644 index 0000000000..3f95f072df --- /dev/null +++ b/runtime/test/shaders/cs_w32_lds_atomics_rtn.asm @@ -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 diff --git a/runtime/test/shaders/cs_w32_lds_minmax_f32.asm b/runtime/test/shaders/cs_w32_lds_minmax_f32.asm new file mode 100644 index 0000000000..91237fa1ad --- /dev/null +++ b/runtime/test/shaders/cs_w32_lds_minmax_f32.asm @@ -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 diff --git a/runtime/test/shaders/cs_w32_lds_mskor.asm b/runtime/test/shaders/cs_w32_lds_mskor.asm new file mode 100644 index 0000000000..6dda9ab9d8 --- /dev/null +++ b/runtime/test/shaders/cs_w32_lds_mskor.asm @@ -0,0 +1,89 @@ +; regen_fixtures: this source has a translator fixture in tests/semantic/fixtures/disasm +; ds_mskor_b32 / ds_mskor_rtn_b32 (RDNA2 ISA, "Data Share Instructions"), LDS 512 B, only lane 0 runs. +; tmp = M[A]; M[A] = (tmp & ~DATA) | DATA2; the _rtn_ form returns tmp in vdst. +; DATA is the mask, DATA2 is ORed in raw: bits outside DATA are ORed too, it is not a masked insert. +; +; Seeds (all lanes write the same words): +; M[0] = 0x11223344 M[4] = 0xFFFF0000 M[8] = 0x0F0F0F0F M[12] = 0xCAFEBABE +; Lane 0 then runs: +; ds_mskor_rtn_b32 v5, v1, v3, v4 at 0, DATA 0x0000FFFF, DATA2 0x00000008 +; old = 0x11223344, new = (0x11223344 & 0xFFFF0000) | 0x00000008 = 0x11220008 +; (bit 3 is outside DATA, so it comes from DATA2 alone) +; ds_mskor_rtn_b32 v6, v1, v3, v4 offset:4 at 4, DATA 0x00FF00FF, DATA2 0x00000001 +; old = 0xFFFF0000, new = (0xFFFF0000 & 0xFF00FF00) | 0x00000001 = 0xFF000001 +; ds_mskor_b32 v1, v3, v4 at 8, DATA 0xF0F0F0F0, DATA2 0x50505050 +; new = (0x0F0F0F0F & 0x0F0F0F0F) | 0x50505050 = 0x5F5F5F5F +; (DATA2 bits 4 and 6 are outside DATA and are ORed in) +; ds_mskor_b32 v1, v3, v4 at 12, DATA 0xFFFFFFFF, DATA2 0x12345678 +; new = (0xCAFEBABE & 0) | 0x12345678 = 0x12345678 +; The non-returning form has no vdst: v7 (0xDEADBEEF) and v8 (0xFEEDFACE) keep their values. +; Under EXEC only lane 0 runs the four atomics, so the two atomics each one expands to cannot +; interleave with another lane's. +; +; out[0] rtn old 0 0x11223344 out[1] M[0] after 0x11220008 +; out[2] rtn old 4 0xFFFF0000 out[3] M[4] after 0xFF000001 +; out[4] v7 preserved 0xDEADBEEF out[5] M[8] after 0x5F5F5F5F +; out[6] v8 preserved 0xFEEDFACE out[7] M[12] after 0x12345678 +; +; group: 32,1,1 +; Run: vk_compute_test cs_w32_lds_mskor.spv 1 dump +; -> out[0..7] = 0x11223344 0x11220008 0xFFFF0000 0xFF000001 0xDEADBEEF 0x5F5F5F5F 0xFEEDFACE 0x12345678 +; mattr: +wavefrontsize32,-wavefrontsize64 +v_mov_b32_e32 v1, 0 +v_mov_b32_e32 v2, 0x11223344 +ds_write_b32 v1, v2 +v_mov_b32_e32 v1, 4 +v_mov_b32_e32 v2, 0xffff0000 +ds_write_b32 v1, v2 +v_mov_b32_e32 v1, 8 +v_mov_b32_e32 v2, 0x0f0f0f0f +ds_write_b32 v1, v2 +v_mov_b32_e32 v1, 12 +v_mov_b32_e32 v2, 0xcafebabe +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, 0x0000ffff +v_mov_b32_e32 v4, 0x00000008 +ds_mskor_rtn_b32 v5, v1, v3, v4 +v_mov_b32_e32 v3, 0x00ff00ff +v_mov_b32_e32 v4, 0x00000001 +ds_mskor_rtn_b32 v6, v1, v3, v4 offset:4 +v_mov_b32_e32 v7, 0xdeadbeef +v_mov_b32_e32 v1, 8 +v_mov_b32_e32 v3, 0xf0f0f0f0 +v_mov_b32_e32 v4, 0x50505050 +ds_mskor_b32 v1, v3, v4 +v_mov_b32_e32 v8, 0xfeedface +v_mov_b32_e32 v1, 12 +v_mov_b32_e32 v3, 0xffffffff +v_mov_b32_e32 v4, 0x12345678 +ds_mskor_b32 v1, v3, v4 +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 diff --git a/runtime/test/shaders/cs_w32_lds_wrxchg2st64_b64.asm b/runtime/test/shaders/cs_w32_lds_wrxchg2st64_b64.asm new file mode 100644 index 0000000000..175b787865 --- /dev/null +++ b/runtime/test/shaders/cs_w32_lds_wrxchg2st64_b64.asm @@ -0,0 +1,71 @@ +; regen_fixtures: this source has a translator fixture in tests/semantic/fixtures/disasm +; ds_wrxchg2st64_rtn_b64 (RDNA2 ISA, DS), 2 KiB LDS (RSRC2 0x20088), only lane 0 runs. +; The st64 form addresses its two elements at vaddr + offset0/offset1 * 512 bytes (64 pairs per step), +; as ds_write2st64_b64 addresses them. vdst is four VGPRs: vdst[0:1] = old at offset0, +; vdst[2:3] = old at offset1; each exchanged dword is one 32-bit OpAtomicExchange. +; +; Seeds: +; M[0x200] = 0x44444444:11111111 M[0x400] = 0x88888888:55555555 +; M[8] = 0xDEADBEEF M[16] = 0xFEEDFACE (markers: a *8 offset would hit these) +; Lane 0: +; ds_wrxchg2st64_rtn_b64 v[10:13], v1, v[4:5], v[6:7] offset0:1 offset1:2, base 0 +; DATA 0x77777777:33333333 at 0x200, 0xEEEEEEEE:AAAAAAAA at 0x400 +; -> v10/v11 = 0x11111111 / 0x44444444, v12/v13 = 0x55555555 / 0x88888888 +; -> M[0x200] = 0x77777777:33333333, M[0x400] = 0xEEEEEEEE:AAAAAAAA +; +; out[0..7] = 0x11111111 0x44444444 0x55555555 0x88888888 0x33333333 0x77777777 0xAAAAAAAA 0xEEEEEEEE +; +; rsrc2: 0x20088 +; group: 32,1,1 +; Run: vk_compute_test cs_w32_lds_wrxchg2st64_b64.spv 1 dump +; -> out[0..7] = 0x11111111 0x44444444 0x55555555 0x88888888 0x33333333 0x77777777 0xAAAAAAAA 0xEEEEEEEE +; mattr: +wavefrontsize32,-wavefrontsize64 +v_mov_b32_e32 v1, 0x200 +v_mov_b32_e32 v2, 0x11111111 +v_mov_b32_e32 v3, 0x44444444 +ds_write_b64 v1, v[2:3] +v_mov_b32_e32 v1, 0x400 +v_mov_b32_e32 v2, 0x55555555 +v_mov_b32_e32 v3, 0x88888888 +ds_write_b64 v1, v[2:3] +v_mov_b32_e32 v1, 8 +v_mov_b32_e32 v2, 0xdeadbeef +ds_write_b32 v1, v2 +v_mov_b32_e32 v1, 16 +v_mov_b32_e32 v2, 0xfeedface +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 v4, 0x33333333 +v_mov_b32_e32 v5, 0x77777777 +v_mov_b32_e32 v6, 0xaaaaaaaa +v_mov_b32_e32 v7, 0xeeeeeeee +ds_wrxchg2st64_rtn_b64 v[10:13], v1, v[4:5], v[6:7] offset0:1 offset1:2 +s_waitcnt lgkmcnt(0) +v_mov_b32_e32 v1, 0x200 +ds_read_b32 v14, v1 +v_mov_b32_e32 v1, 0x204 +ds_read_b32 v15, v1 +v_mov_b32_e32 v1, 0x400 +ds_read_b32 v16, v1 +v_mov_b32_e32 v1, 0x404 +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 diff --git a/runtime/test/shaders/cs_w32_lds_wrxchg_b64.asm b/runtime/test/shaders/cs_w32_lds_wrxchg_b64.asm new file mode 100644 index 0000000000..e4ffc26f96 --- /dev/null +++ b/runtime/test/shaders/cs_w32_lds_wrxchg_b64.asm @@ -0,0 +1,70 @@ +; regen_fixtures: this source has a translator fixture in tests/semantic/fixtures/disasm +; ds_wrxchg_rtn_b64 and ds_wrxchg2_rtn_b64 (RDNA2 ISA, DS), 512 B LDS, only lane 0 runs. +; A 64-bit element is two dwords, low first: M[A] = DATA and vdst gets the old 64 bits. +; ds_wrxchg_rtn_b64 has one element at vaddr + offset (bytes). ds_wrxchg2_rtn_b64 has two at +; vaddr + offset0/offset1 * 8, as ds_write2_b64 addresses them, and vdst is four VGPRs: +; vdst[0:1] = old at offset0, vdst[2:3] = old at offset1. +; +; Seeds: +; M[0] = 0x88888888:11111111 M[8] = 0x44444444:22222222 M[16] = 0xCCCCCCCC:33333333 +; Lane 0: +; ds_wrxchg_rtn_b64 v[10:11], v1, v[4:5] at 0, DATA 0xAAAAAAAA:BBBBBBBB +; -> v10/v11 = 0x11111111 / 0x88888888, M[0] = BBBBBBBB:AAAAAAAA +; ds_wrxchg2_rtn_b64 v[12:15], v1, v[4:5], v[6:7] offset0:1 offset1:2, base 0 +; addresses 8 and 16, DATA 0xCCCCCCCC:DDDDDDDD and 0xFFFFFFFF:EEEEEEEE +; -> v12/v13 = 0x22222222 / 0x44444444 (old at offset0) +; v14/v15 = 0x33333333 / 0xCCCCCCCC (old at offset1) +; The two readbacks take the low dword each exchange wrote: M[8] = 0xDDDDDDDD, M[16] = 0xEEEEEEEE. +; +; out[0..7] = 0x11111111 0x88888888 0x22222222 0x44444444 0x33333333 0xCCCCCCCC 0xDDDDDDDD 0xEEEEEEEE +; +; group: 32,1,1 +; Run: vk_compute_test cs_w32_lds_wrxchg_b64.spv 1 dump +; -> out[0..7] = 0x11111111 0x88888888 0x22222222 0x44444444 0x33333333 0xCCCCCCCC 0xDDDDDDDD 0xEEEEEEEE +; mattr: +wavefrontsize32,-wavefrontsize64 +v_mov_b32_e32 v1, 0 +v_mov_b32_e32 v2, 0x11111111 +v_mov_b32_e32 v3, 0x88888888 +ds_write_b64 v1, v[2:3] +v_mov_b32_e32 v1, 8 +v_mov_b32_e32 v2, 0x22222222 +v_mov_b32_e32 v3, 0x44444444 +ds_write_b64 v1, v[2:3] +v_mov_b32_e32 v1, 16 +v_mov_b32_e32 v2, 0x33333333 +v_mov_b32_e32 v3, 0xcccccccc +ds_write_b64 v1, v[2:3] +s_waitcnt lgkmcnt(0) +v_cmpx_eq_u32_e32 0, v0 +v_mov_b32_e32 v1, 0 +v_mov_b32_e32 v4, 0xbbbbbbbb +v_mov_b32_e32 v5, 0xaaaaaaaa +v_mov_b32_e32 v6, 0xdddddddd +v_mov_b32_e32 v7, 0xcccccccc +v_mov_b32_e32 v8, 0xeeeeeeee +v_mov_b32_e32 v9, 0xffffffff +ds_wrxchg_rtn_b64 v[10:11], v1, v[4:5] +ds_wrxchg2_rtn_b64 v[12:15], v1, v[6:7], v[8:9] offset0:1 offset1:2 +s_waitcnt lgkmcnt(0) +v_mov_b32_e32 v1, 8 +ds_read_b32 v16, v1 +v_mov_b32_e32 v1, 16 +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 diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py index 8ba62104d8..ce853fcb3b 100644 --- a/scripts/run_gpu_tests.py +++ b/scripts/run_gpu_tests.py @@ -1211,7 +1211,7 @@ def run_suite(a, work: str) -> int: "cs_w64x_mask_reuse", "cs_w64x_mask_reuse2", "cs_w64x_chain_barrier", "cs_barrier_divergent", "cs_bpermute32", "cs_w64x_partial_scmp", "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_andn2_exec", - "cs_mask_vgpr_exec", "cs_w32_exec_computed", "cs_w64_exec_computed"): + "cs_mask_vgpr_exec", "cs_w32_exec_computed", "cs_w64_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_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 @@ -1252,6 +1252,22 @@ def run_suite(a, work: str) -> int: # 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 (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], + # their _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 / 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, 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 masks (cs_exec_const.asm): each lane takes its own bit of the constant "cs_exec_const": [16, 8, 2, 16, 0, 16], # constant lane masks: lane L takes bit L (cs_w32_mask_imm.asm / cs_w64_mask_imm.asm headers) @@ -1341,8 +1357,13 @@ def run_suite(a, work: str) -> int: "cs_bpermute32", "cs_w32_partial_scmp", "cs_w32_partial_permute", "cs_w32_permlane_fi", "cs_w32_sincos", "cs_w32_buffer_sub16", "cs_w32_buffer_store_sub", "cs_w32_fcmpswap", "cs_lds_b64_cmpst", "cs_lds_xchg64_ext", "cs_lds_atomics_ext", "cs_exec_const", "cs_w32_mask_imm", "cs_mask_vgpr_exec", "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", +<<<<<<< HEAD "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_dpp_ops", "cs_dpp_bound", "cs_dpp_bank", "cs_dpp_fi", "cs_w32_andn2_exec", + "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") and not emulated and not partial +>>>>>>> ba9a1df7 (test(gpu): cover the last three LDS-atomic rows (mskor, inc/dec/min/max, wrxchg b64)) if partial and not emulated: cs_env = dict(os.environ, VKC_SUBGROUP_SIZE="64") if name in WAVE32_LANE_DUMPS: # 32 lanes even without index.json, as check.py requests (#774) @@ -1366,7 +1387,7 @@ def run_suite(a, work: str) -> int: ok, detail = judge_cs_dump(rc, msg, want, wave64=wave64, partial=partial, emulated=emulated, hexwords=name in ("cs_store", "cs_smem_soffset_imm", "cs_w32_lds_u8_d16", "cs_w32_lds_subdword", "cs_w32_lds_wide", - "cs_lds_b64_cmpst", "cs_lds_xchg64_ext", "cs_lds_atomics_ext", "cs_signed_zero_nan")) + "cs_lds_b64_cmpst", "cs_lds_xchg64_ext", "cs_lds_atomics_ext", "cs_signed_zero_nan", "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")) if ok and None in want: unjudged = ", ".join(str(i) for i, w in enumerate(want) if w is None) detail += f" (words {unjudged} not judged on this device: UNJUDGED_WORDS in check.py)" diff --git a/tests/semantic/README.md b/tests/semantic/README.md index c355e60c18..4edf200c83 100644 --- a/tests/semantic/README.md +++ b/tests/semantic/README.md @@ -103,6 +103,11 @@ instruction family per file; the list below describes some of them, not every fi constants) through the interpreter, and checks that the words each `.asm` header derives are the ones `check.py` and `scripts/run_gpu_tests.py` expect. The two interp fixtures get the constants their vertex shader, `vs_interp_consts`, exports. +- `test_batch5_gpu_fixtures.py` runs the six batch-5 LDS atomic GPU fixtures (`cs_w32_lds_mskor`, + `_atomics_incdec`, `_atomics_rtn`, `_minmax_f32`, `_wrxchg_b64`, `_wrxchg2st64_b64`) through the interpreter and + checks the eight words each `.asm` header derives against `check.py` and `scripts/run_gpu_tests.py`. They cover + `ds_mskor`, the `ds_inc/dec/rsub_u32` and `ds_min/max_f32` boundaries with and without return, and the three + 64-bit `ds_wrxchg` forms, and were measured on an RDNA2 iGPU (`gfx1036`, RADV). - `test_vcmpx_forms.py` runs the 14 `v_cmpx` forms that had no test (`eq`/`gt`/`le`/`lt`/`ngt`/`nle` `_f32`, `f_i32`, `t_u32`, `eq`/`gt`/`le` `_i64`, `ge`/`lt`/`ne` `_u64`) in both encodings: each on a table of operands (NaN, signed zeros, infinities; 64-bit values that only one word or the sign tells apart), where diff --git a/tests/semantic/fixtures/disasm/cs_w32_lds_atomics_incdec.s b/tests/semantic/fixtures/disasm/cs_w32_lds_atomics_incdec.s new file mode 100644 index 0000000000..af337b0c99 --- /dev/null +++ b/tests/semantic/fixtures/disasm/cs_w32_lds_atomics_incdec.s @@ -0,0 +1,79 @@ +; cs_w32_lds_atomics_incdec test fixture generated by tests/semantic/regen_fixtures.py from runtime/test/shaders/cs_w32_lds_atomics_incdec.asm + 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 diff --git a/tests/semantic/fixtures/disasm/cs_w32_lds_atomics_rtn.s b/tests/semantic/fixtures/disasm/cs_w32_lds_atomics_rtn.s new file mode 100644 index 0000000000..23f623a914 --- /dev/null +++ b/tests/semantic/fixtures/disasm/cs_w32_lds_atomics_rtn.s @@ -0,0 +1,51 @@ +; cs_w32_lds_atomics_rtn test fixture generated by tests/semantic/regen_fixtures.py from runtime/test/shaders/cs_w32_lds_atomics_rtn.asm + 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 diff --git a/tests/semantic/fixtures/disasm/cs_w32_lds_minmax_f32.s b/tests/semantic/fixtures/disasm/cs_w32_lds_minmax_f32.s new file mode 100644 index 0000000000..56b7ceb529 --- /dev/null +++ b/tests/semantic/fixtures/disasm/cs_w32_lds_minmax_f32.s @@ -0,0 +1,68 @@ +; cs_w32_lds_minmax_f32 test fixture generated by tests/semantic/regen_fixtures.py from runtime/test/shaders/cs_w32_lds_minmax_f32.asm + 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 diff --git a/tests/semantic/fixtures/disasm/cs_w32_lds_mskor.s b/tests/semantic/fixtures/disasm/cs_w32_lds_mskor.s new file mode 100644 index 0000000000..fc61ea00f2 --- /dev/null +++ b/tests/semantic/fixtures/disasm/cs_w32_lds_mskor.s @@ -0,0 +1,59 @@ +; cs_w32_lds_mskor test fixture generated by tests/semantic/regen_fixtures.py from runtime/test/shaders/cs_w32_lds_mskor.asm + v_mov_b32_e32 v1, 0 + v_mov_b32_e32 v2, 0x11223344 + ds_write_b32 v1, v2 + v_mov_b32_e32 v1, 4 + v_mov_b32_e32 v2, 0xffff0000 + ds_write_b32 v1, v2 + v_mov_b32_e32 v1, 8 + v_mov_b32_e32 v2, 0x0f0f0f0f + ds_write_b32 v1, v2 + v_mov_b32_e32 v1, 12 + v_mov_b32_e32 v2, 0xcafebabe + 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, 0x0000ffff + v_mov_b32_e32 v4, 0x00000008 + ds_mskor_rtn_b32 v5, v1, v3, v4 + v_mov_b32_e32 v3, 0x00ff00ff + v_mov_b32_e32 v4, 0x00000001 + ds_mskor_rtn_b32 v6, v1, v3, v4 offset:4 + v_mov_b32_e32 v7, 0xdeadbeef + v_mov_b32_e32 v1, 8 + v_mov_b32_e32 v3, 0xf0f0f0f0 + v_mov_b32_e32 v4, 0x50505050 + ds_mskor_b32 v1, v3, v4 + v_mov_b32_e32 v8, 0xfeedface + v_mov_b32_e32 v1, 12 + v_mov_b32_e32 v3, 0xffffffff + v_mov_b32_e32 v4, 0x12345678 + ds_mskor_b32 v1, v3, v4 + 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 diff --git a/tests/semantic/fixtures/disasm/cs_w32_lds_wrxchg2st64_b64.s b/tests/semantic/fixtures/disasm/cs_w32_lds_wrxchg2st64_b64.s new file mode 100644 index 0000000000..903279dc1f --- /dev/null +++ b/tests/semantic/fixtures/disasm/cs_w32_lds_wrxchg2st64_b64.s @@ -0,0 +1,50 @@ +; cs_w32_lds_wrxchg2st64_b64 test fixture generated by tests/semantic/regen_fixtures.py from runtime/test/shaders/cs_w32_lds_wrxchg2st64_b64.asm + v_mov_b32_e32 v1, 0x200 + v_mov_b32_e32 v2, 0x11111111 + v_mov_b32_e32 v3, 0x44444444 + ds_write_b64 v1, v[2:3] + v_mov_b32_e32 v1, 0x400 + v_mov_b32_e32 v2, 0x55555555 + v_mov_b32_e32 v3, 0x88888888 + ds_write_b64 v1, v[2:3] + v_mov_b32_e32 v1, 8 + v_mov_b32_e32 v2, 0xdeadbeef + ds_write_b32 v1, v2 + v_mov_b32_e32 v1, 16 + v_mov_b32_e32 v2, 0xfeedface + 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 v4, 0x33333333 + v_mov_b32_e32 v5, 0x77777777 + v_mov_b32_e32 v6, 0xaaaaaaaa + v_mov_b32_e32 v7, 0xeeeeeeee + ds_wrxchg2st64_rtn_b64 v[10:13], v1, v[4:5], v[6:7] offset0:1 offset1:2 + s_waitcnt lgkmcnt(0) + v_mov_b32_e32 v1, 0x200 + ds_read_b32 v14, v1 + v_mov_b32_e32 v1, 0x204 + ds_read_b32 v15, v1 + v_mov_b32_e32 v1, 0x400 + ds_read_b32 v16, v1 + v_mov_b32_e32 v1, 0x404 + 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 diff --git a/tests/semantic/fixtures/disasm/cs_w32_lds_wrxchg_b64.s b/tests/semantic/fixtures/disasm/cs_w32_lds_wrxchg_b64.s new file mode 100644 index 0000000000..c4293c31d7 --- /dev/null +++ b/tests/semantic/fixtures/disasm/cs_w32_lds_wrxchg_b64.s @@ -0,0 +1,47 @@ +; cs_w32_lds_wrxchg_b64 test fixture generated by tests/semantic/regen_fixtures.py from runtime/test/shaders/cs_w32_lds_wrxchg_b64.asm + v_mov_b32_e32 v1, 0 + v_mov_b32_e32 v2, 0x11111111 + v_mov_b32_e32 v3, 0x88888888 + ds_write_b64 v1, v[2:3] + v_mov_b32_e32 v1, 8 + v_mov_b32_e32 v2, 0x22222222 + v_mov_b32_e32 v3, 0x44444444 + ds_write_b64 v1, v[2:3] + v_mov_b32_e32 v1, 16 + v_mov_b32_e32 v2, 0x33333333 + v_mov_b32_e32 v3, 0xcccccccc + ds_write_b64 v1, v[2:3] + s_waitcnt lgkmcnt(0) + v_cmpx_eq_u32_e32 0, v0 + v_mov_b32_e32 v1, 0 + v_mov_b32_e32 v4, 0xbbbbbbbb + v_mov_b32_e32 v5, 0xaaaaaaaa + v_mov_b32_e32 v6, 0xdddddddd + v_mov_b32_e32 v7, 0xcccccccc + v_mov_b32_e32 v8, 0xeeeeeeee + v_mov_b32_e32 v9, 0xffffffff + ds_wrxchg_rtn_b64 v[10:11], v1, v[4:5] + ds_wrxchg2_rtn_b64 v[12:15], v1, v[6:7], v[8:9] offset0:1 offset1:2 + s_waitcnt lgkmcnt(0) + v_mov_b32_e32 v1, 8 + ds_read_b32 v16, v1 + v_mov_b32_e32 v1, 16 + 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 diff --git a/tests/semantic/test_batch5_gpu_fixtures.py b/tests/semantic/test_batch5_gpu_fixtures.py new file mode 100644 index 0000000000..fe527514a2 --- /dev/null +++ b/tests/semantic/test_batch5_gpu_fixtures.py @@ -0,0 +1,114 @@ +"""CPU checks for the batch-5 GPU fixtures (docs/design.md rows 321, 322, 324). + +Each fixture runs the translator on its generated disassembly (tests/semantic/fixtures/disasm, made by +regen_fixtures.py) and executes all 32 invocations in the mini interpreter: lane 0 alone passes the fixture's EXEC +cut and runs the LDS atomics and stores the eight results, so the memory holds the words its header derives. The +same words are asserted against the three places that state them: the .asm header, check.py's CS_DUMPS and +scripts/run_gpu_tests.py's table. A GPU run of either runner then compares them with what the device writes. +""" + +import os +import re +import sys +import unittest + +HERE = os.path.dirname(os.path.abspath(__file__)) +ROOT = os.path.dirname(os.path.dirname(HERE)) +SHADERS = os.path.join(ROOT, "runtime", "test", "shaders") +sys.path.insert(0, HERE) +sys.path.insert(0, SHADERS) + +import support # noqa: E402 +import spirv_mini_interp as si # noqa: E402 +import check # noqa: E402 (importing runtime/test/shaders/check.py runs nothing) +from compute_fixture import compute_header # noqa: E402 + +FIXTURES = { + # ds_mskor_b32 / ds_mskor_rtn_b32, DATA2 bits outside DATA ORed in + "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": (5, 0, 0, 5, 0, 4, 5, 0xFFFFFFFE), + # the _rtn_ forms return the pre-op word + "cs_w32_lds_atomics_rtn": (4, 5, 0, 5, 7, 0xFFFFFFFE, 5, 0), + # ds_min/max_f32: NaN, +-0 and +-inf + "cs_w32_lds_minmax_f32": (0x80000000, 0x00000000, 0x3F800000, 0x3F800000, + 0x7FC00000, 0x3F800000, 0x3F800000, 0x3F800000), + # ds_wrxchg_rtn_b64 and ds_wrxchg2_rtn_b64, old value in vdst order, *8 offsets + "cs_w32_lds_wrxchg_b64": (0x11111111, 0x88888888, 0x22222222, 0x44444444, + 0x33333333, 0xCCCCCCCC, 0xDDDDDDDD, 0xEEEEEEEE), + # ds_wrxchg2st64_rtn_b64, old values then the words it wrote at *64 offsets + "cs_w32_lds_wrxchg2st64_b64": (0x11111111, 0x44444444, 0x55555555, 0x88888888, + 0x33333333, 0x77777777, 0xAAAAAAAA, 0xEEEEEEEE), +} +# The output V# in s[0:3]: base 0, num_records max, FORMAT 32_FLOAT, DST_SEL xyzw (as vk_compute_test sets it); the +# heap base in push-constant dwords 32/33 is 0, so an Xbox VA is the memory word index below. +OUT_V = [0, 0, 0xFFFFFFFF, 0x31016FAC] + + +def read(name): + with open(os.path.join(SHADERS, name + ".asm"), encoding="utf-8") as f: + return f.read() + + +def header_words(name): + """The eight words of the fixture's "; Run:" line, decimal or 0x hex.""" + m = re.search(r"out\[0\.\.7\] = ([0-9a-fA-Fx ]+)", read(name)) + if not m: + raise AssertionError(f"{name}.asm has no '; Run:' words") + words = m.group(1).split() + if len(words) != 8: + raise AssertionError(f"{name}.asm names {len(words)} words, not 8") + return tuple(int(w, 0) for w in words) + + +def runner_words(name): + """The tuple scripts/run_gpu_tests.py expects for `name` (its table is local to the run loop, so read the source).""" + with open(os.path.join(ROOT, "scripts", "run_gpu_tests.py"), encoding="utf-8") as f: + m = re.search(r'"%s": \[([^\]]*)\]' % re.escape(name), f.read()) + return tuple(int(w, 0) for w in m.group(1).replace("\n", " ").split(",")) if m else None + + +def interpreter_words(name): + spv = support.translate_fixture( + name, fssm=bytes(compute_header(os.path.join(SHADERS, name + ".asm"))) + ) + memory = {} + si.run_workgroup( + spv, + 32, + 32, + inputs_for=lambda i: {"%wg_id": (0, 0, 0), "%local_id": (i, 0, 0)}, + push_constants=OUT_V + [0] * 28, + memory=memory, + ) + return memory + + +class Batch5GpuFixtureTests(unittest.TestCase): + def test_interpreter_stores_the_header_words(self): + for name, want in FIXTURES.items(): + with self.subTest(name=name): + memory = interpreter_words(name) + self.assertEqual(tuple(memory.get(4 * i, 0xDEAD0000) for i in range(8)), want) + # lane 0 stored the eight dwords and nothing else did + self.assertEqual(sorted(memory), [4 * i for i in range(8)]) + + def test_header_check_and_runner_agree(self): + cs_dumps = dict(check.CS_DUMPS) + for name, want in FIXTURES.items(): + with self.subTest(name=name): + self.assertEqual(header_words(name), want) + self.assertEqual(tuple(cs_dumps.get(name, ())), want) + self.assertEqual(runner_words(name), want) + + def test_wave32_registration(self): + for name in FIXTURES: + with self.subTest(name=name): + self.assertIn(name, check.WAVE32_DUMPS) + # 32 EXEC bits wide, and the LDS atomics are not idempotent: one wave must hold the only lane 0 + self.assertIn(name, check.WAVE32_LANE_DUMPS) + + +if __name__ == "__main__": + unittest.main()