diff --git a/runtime/test/shaders/check.py b/runtime/test/shaders/check.py index 1e6c311d5c..3704adf6d5 100644 --- a/runtime/test/shaders/check.py +++ b/runtime/test/shaders/check.py @@ -107,7 +107,7 @@ def not_found_message(build, missing): "cs_barrier_divergent", "cs_barrier_early_end", "cs_barrier_loop", "cs_w32_lds_u8_d16", "cs_bpermute32", "cs_w32_lds_subdword", "cs_w32_lds_wide", "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_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") # Wave32 lane-mask dumps: their EXEC/VCC masks and lane selects cover 32 lanes, so a device whose widest subgroup is @@ -116,7 +116,7 @@ def not_found_message(build, missing): # 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_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_DPP = [("cs_dpp", [1, 0, 3, 2, 5, 4, 7, 6]), ("cs_dpp_row", [0, 0, 1, 2, 3, 4, 5, 6]), @@ -163,6 +163,12 @@ def not_found_message(build, missing): # ds_wrxchg*_rtn_b64, ds_or_rtn_b64, ds_min_f32, ds_max_rtn_f32 (cs_lds_xchg64_ext.asm header) ("cs_lds_xchg64_ext", [0x11110003, 0x33333333, 0xF00FF000, 0x04030201, 0x40302010, 0x70500705, 0x3FC00000, 0x80000000]), + # ds_wrxchg2_rtn_b32's pair cases and ds_wrxchg2st64_rtn_b32 + # (cs_w32_wrxchg2_ext.asm / cs_w32_wrxchg2st64.asm headers) + ("cs_w32_wrxchg2_ext", [0x77777777, 0x88880008, 0x99990009, 0xDEADBEEF, + 0xAAAAAAAA, 0xBBBBBBBB, 0x12341234, 0x56785678]), + ("cs_w32_wrxchg2st64", [0x33333333, 0x44444444, 0x55550005, 0x66660006, + 0xB0B00084, 0xB0B00088, 0xB0B00140, 0xB0B002C0]), # 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]), diff --git a/runtime/test/shaders/cs_w32_wrxchg2_ext.asm b/runtime/test/shaders/cs_w32_wrxchg2_ext.asm new file mode 100644 index 0000000000..8744ddeca5 --- /dev/null +++ b/runtime/test/shaders/cs_w32_wrxchg2_ext.asm @@ -0,0 +1,91 @@ +; GPU test for ds_wrxchg2_rtn_b32, part two: the four cases cs_w32_new_ops.asm leaves out +; (docs/design.md "ds_wrxchg2_rtn_b32, ds_wrxchg2st64_rtn_b32" row). cs_w32_new_ops covers the first +; returned word and data1 in LDS with offset0:2 offset1:5; this fixture covers: +; +; - the SECOND returned word of the pair, which is data0 when both offsets name one dword +; - both offsets on one dword (the second exchange reads back what the first wrote) +; - vdst aliasing the data VGPRs (the data must be read before vdst is written) +; - that an exchange at one base leaves a neighbouring LDS word alone +; +; LDS 4 KiB (RSRC2 0x40088), group 32x1x1, only lane 0 runs (32 lanes on one LDS address would race: +; which lane's exchange runs first is up to the hardware). LDS is seeded by ds_write_b32 before each case. +; Every word is stored raw, in this order: +; +; out[0] both offsets on one dword: ds_wrxchg2_rtn_b32 at base 0x200, offset0:1 offset1:1 +; (both = element 0x204). Seeded M[0x204]=0x77777777, data0=0x88880008, data1=0x99990009. +; vdst[0] = the word the first exchange took out of M -> 0x77777777 +; out[1] vdst[1] = the second exchange's return, which is data0, not the +; word the first exchange wrote -> 0x88880008 +; out[2] M[0x204] after both: data1 landed -> 0x99990009 +; out[3] M[0x700], seeded 0xDEADBEEF before the exchange and read after it: +; the exchange touched only 0x204 -> 0xDEADBEEF +; out[4] vdst aliases the data VGPRs: ds_wrxchg2_rtn_b32 v[4:5], ... with v4=0x12341234 v5=0x56785678 +; at base 0x300, offset0:0 offset1:2, M[0x300]=0xAAAAAAAA, M[0x308]=0xBBBBBBBB. +; vdst[0] = the old word, so the data was read before the write -> 0xAAAAAAAA +; out[5] vdst[1] = the old word at 0x308 -> 0xBBBBBBBB +; out[6] M[0x300] after: data0 -> 0x12341234 +; out[7] M[0x308] after: data1 -> 0x56785678 +; +; Run: vk_compute_test cs_w32_wrxchg2_ext.spv 1 dump +; -> out[0..7] = 0x77777777 0x88880008 0x99990009 0xDEADBEEF +; 0xAAAAAAAA 0xBBBBBBBB 0x12341234 0x56785678 +; rsrc2: 0x40088 +; group: 32,1,1 +; mattr: +wavefrontsize32,-wavefrontsize64 +v_cmpx_eq_u32_e32 0, v0 + +; --- both offsets on one dword (element 0x204) --- +v_mov_b32_e32 v1, 0x204 +v_mov_b32_e32 v4, 0x77777777 +ds_write_b32 v1, v4 +v_mov_b32_e32 v2, 0x700 +v_mov_b32_e32 v5, 0xDEADBEEF +ds_write_b32 v2, v5 +s_waitcnt lgkmcnt(0) +v_mov_b32_e32 v1, 0x200 +v_mov_b32_e32 v4, 0x88880008 +v_mov_b32_e32 v5, 0x99990009 +ds_wrxchg2_rtn_b32 v[12:13], v1, v4, v5 offset0:1 offset1:1 +s_waitcnt lgkmcnt(0) +v_mov_b32_e32 v21, 0 +buffer_store_dword v12, v21, s[0:3], 0 offen +v_mov_b32_e32 v21, 4 +buffer_store_dword v13, v21, s[0:3], 0 offen +v_mov_b32_e32 v1, 0x204 +ds_read_b32 v10, v1 +v_mov_b32_e32 v2, 0x700 +ds_read_b32 v11, v2 +s_waitcnt lgkmcnt(0) +v_mov_b32_e32 v21, 8 +buffer_store_dword v10, v21, s[0:3], 0 offen +v_mov_b32_e32 v21, 12 +buffer_store_dword v11, v21, s[0:3], 0 offen + +; --- vdst aliases the data VGPRs --- +v_mov_b32_e32 v1, 0x300 +v_mov_b32_e32 v4, 0xAAAAAAAA +ds_write_b32 v1, v4 +v_mov_b32_e32 v2, 0x308 +v_mov_b32_e32 v5, 0xBBBBBBBB +ds_write_b32 v2, v5 +s_waitcnt lgkmcnt(0) +v_mov_b32_e32 v1, 0x300 +v_mov_b32_e32 v4, 0x12341234 +v_mov_b32_e32 v5, 0x56785678 +ds_wrxchg2_rtn_b32 v[4:5], v1, v4, v5 offset0:0 offset1:2 +s_waitcnt lgkmcnt(0) +v_mov_b32_e32 v21, 16 +buffer_store_dword v4, v21, s[0:3], 0 offen +v_mov_b32_e32 v21, 20 +buffer_store_dword v5, v21, s[0:3], 0 offen +ds_read_b32 v10, v1 +s_waitcnt lgkmcnt(0) +v_mov_b32_e32 v21, 24 +buffer_store_dword v10, v21, s[0:3], 0 offen +v_mov_b32_e32 v1, 0x308 +ds_read_b32 v11, v1 +s_waitcnt lgkmcnt(0) +v_mov_b32_e32 v21, 28 +buffer_store_dword v11, v21, s[0:3], 0 offen + +s_endpgm diff --git a/runtime/test/shaders/cs_w32_wrxchg2st64.asm b/runtime/test/shaders/cs_w32_wrxchg2st64.asm new file mode 100644 index 0000000000..2f2b25a9ab --- /dev/null +++ b/runtime/test/shaders/cs_w32_wrxchg2st64.asm @@ -0,0 +1,93 @@ +; GPU test for ds_wrxchg2st64_rtn_b32 (docs/design.md "ds_wrxchg2_rtn_b32, ds_wrxchg2st64_rtn_b32" +; row). Neither this form nor the row's st64 step is covered by a GPU fixture on main: cs_w32_new_ops +; runs ds_wrxchg2_rtn_b32 only, and cs_lds_xchg64_ext runs the _b64 pair forms. The row and the gfx1100 +; measurement both say the st64 unit is 64 dwords = 256 bytes, i.e. offset0:1 and offset1:2 address +; vaddr + 256 and vaddr + 512; this fixture pins that on a GPU. +; +; LDS 4 KiB (RSRC2 0x40088), group 32x1x1, only lane 0 runs. Base 0x80, so the two elements are at +; 0x180 and 0x280 and neither is where a non-st64 unit would have put them (0x84 and 0x88) - those two +; words are seeded too and must come back untouched, which is what proves the step size. +; Every word is stored raw, in this order: +; +; out[0] vdst[0] = the old word at 0x180 -> 0x33333333 +; out[1] vdst[1] = the old word at 0x280 -> 0x44444444 +; out[2] M[0x180] after: data0 -> 0x55550005 +; out[3] M[0x280] after: data1 -> 0x66660006 +; out[4] M[0x84], where a 4-byte step would have written data0: untouched -> 0xB0B00084 +; out[5] M[0x88], where a 4-byte step would have written data1: untouched -> 0xB0B00088 +; out[6] M[0x140], one 256-byte step short of 0x180: untouched -> 0xB0B00140 +; out[7] M[0x2c0], one 256-byte step past 0x280: untouched -> 0xB0B002C0 +; +; Run: vk_compute_test cs_w32_wrxchg2st64.spv 1 dump +; -> out[0..7] = 0x33333333 0x44444444 0x55550005 0x66660006 +; 0xB0B00084 0xB0B00088 0xB0B00140 0xB0B002C0 +; rsrc2: 0x40088 +; group: 32,1,1 +; mattr: +wavefrontsize32,-wavefrontsize64 +v_cmpx_eq_u32_e32 0, v0 + +; --- seed the two real elements and the four words the exchange must not touch --- +v_mov_b32_e32 v1, 0x180 +v_mov_b32_e32 v4, 0x33333333 +ds_write_b32 v1, v4 +v_mov_b32_e32 v1, 0x280 +v_mov_b32_e32 v4, 0x44444444 +ds_write_b32 v1, v4 +v_mov_b32_e32 v1, 0x84 +v_mov_b32_e32 v4, 0xB0B00084 +ds_write_b32 v1, v4 +v_mov_b32_e32 v1, 0x88 +v_mov_b32_e32 v4, 0xB0B00088 +ds_write_b32 v1, v4 +v_mov_b32_e32 v1, 0x140 +v_mov_b32_e32 v4, 0xB0B00140 +ds_write_b32 v1, v4 +v_mov_b32_e32 v1, 0x2C0 +v_mov_b32_e32 v4, 0xB0B002C0 +ds_write_b32 v1, v4 +s_waitcnt lgkmcnt(0) + +; --- the st64 pair exchange: base 0x80, offset0:1 offset1:2 --- +v_mov_b32_e32 v4, 0x55550005 +v_mov_b32_e32 v5, 0x66660006 +v_mov_b32_e32 v1, 0x80 +ds_wrxchg2st64_rtn_b32 v[12:13], v1, v4, v5 offset0:1 offset1:2 +s_waitcnt lgkmcnt(0) + +v_mov_b32_e32 v21, 0 +buffer_store_dword v12, v21, s[0:3], 0 offen +v_mov_b32_e32 v21, 4 +buffer_store_dword v13, v21, s[0:3], 0 offen + +; --- read back the two elements and the four words that must be untouched --- +v_mov_b32_e32 v1, 0x180 +ds_read_b32 v10, v1 +v_mov_b32_e32 v2, 0x280 +ds_read_b32 v11, v2 +s_waitcnt lgkmcnt(0) +v_mov_b32_e32 v21, 8 +buffer_store_dword v10, 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 v1, 0x84 +ds_read_b32 v3, v1 +v_mov_b32_e32 v1, 0x88 +ds_read_b32 v6, v1 +s_waitcnt lgkmcnt(0) +v_mov_b32_e32 v21, 16 +buffer_store_dword v3, v21, s[0:3], 0 offen +v_mov_b32_e32 v21, 20 +buffer_store_dword v6, v21, s[0:3], 0 offen + +v_mov_b32_e32 v1, 0x140 +ds_read_b32 v3, v1 +v_mov_b32_e32 v1, 0x2C0 +ds_read_b32 v6, v1 +s_waitcnt lgkmcnt(0) +v_mov_b32_e32 v21, 24 +buffer_store_dword v3, v21, s[0:3], 0 offen +v_mov_b32_e32 v21, 28 +buffer_store_dword v6, v21, s[0:3], 0 offen + +s_endpgm diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py index 6b96cc1588..4075f87d81 100644 --- a/scripts/run_gpu_tests.py +++ b/scripts/run_gpu_tests.py @@ -1209,7 +1209,7 @@ 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_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_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_dump_wants = { "cs_store": [0x400080FF, 0xE00003FF, 0x3C004000, 0xEEEEEEEE, 0x40003C00, 0xBC003800, 0x40FF8000, 0x3FF00000], @@ -1247,6 +1247,12 @@ def run_suite(a, work: str) -> int: # ds_wrxchg*_rtn_b64, ds_or_rtn_b64, ds_min_f32, ds_max_rtn_f32 (cs_lds_xchg64_ext.asm header) "cs_lds_xchg64_ext": [0x11110003, 0x33333333, 0xF00FF000, 0x04030201, 0x40302010, 0x70500705, 0x3FC00000, 0x80000000], + # ds_wrxchg2_rtn_b32's pair cases and ds_wrxchg2st64_rtn_b32 + # (cs_w32_wrxchg2_ext.asm / cs_w32_wrxchg2st64.asm headers) + "cs_w32_wrxchg2_ext": [0x77777777, 0x88880008, 0x99990009, 0xDEADBEEF, + 0xAAAAAAAA, 0xBBBBBBBB, 0x12341234, 0x56785678], + "cs_w32_wrxchg2st64": [0x33333333, 0x44444444, 0x55550005, 0x66660006, + 0xB0B00084, 0xB0B00088, 0xB0B00140, 0xB0B002C0], # 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], @@ -1337,7 +1343,7 @@ def run_suite(a, work: str) -> int: "cs_w32_lds_u8_d16", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", "cs_w32_lds_subdword", "cs_w32_lds_wide", "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_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 @@ -1364,7 +1370,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_w32_wrxchg2_ext", "cs_w32_wrxchg2st64", "cs_signed_zero_nan")) 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)"