diff --git a/docs/shader_validation.md b/docs/shader_validation.md index ac33debfa..9fcddee27 100644 --- a/docs/shader_validation.md +++ b/docs/shader_validation.md @@ -2054,6 +2054,40 @@ Hardware validation was executed via `tools/hw_oracle` and `tools/salu_diff.py` - **Constant operands under `op_sel` / `op_sel_hi`:** Integer constants under VOP3P are uniformly treated as 32-bit dwords `C`. When `op_sel[i] == 0`, bits `[15:0]` are selected; when `op_sel[i] == 1`, bits `[31:16]` are selected. Positive inline constants zero-extend (`5` → `0x00000005`: lo=`0x0005`, hi=`0x0000`; `64` → `0x00000040`: lo=`0x0040`, hi=`0x0000`). Negative inline constants sign-extend (`-1` → `0xFFFFFFFF`: lo=`0xFFFF`, hi=`0xFFFF`; `-16` → `0xFFFFFFF0`: lo=`0xFFF0`, hi=`0xFFFF`). 32-bit literals preserve their full dword (`0x12345678`: lo=`0x5678`, hi=`0x1234`; `0x80017fff`: lo=`0x7fff`, hi=`0x8001`). Float inline tokens (`0.5`, `1.0`, `-2.0`, `4.0`) assemble as their 32-bit IEEE 754 bit patterns (`1.0` → `0x3f800000`: lo=`0x0000`, hi=`0x3f80`). - **`clamp` saturation:** Unsigned add/mad saturate to `0xFFFF`; unsigned sub saturates underflow to `0x0000`; signed add/sub/mad saturate to `[-32768, 32767]`. - **Silicon vs Translator parity:** 380 of 380 kernels match bit-for-bit between native hardware and `tools/rdna2spirv.py` lowered to SPIR-V (0 mismatches, 0 wave32/wave64 differences). +### Vulkan GPU fixtures for `EXEC`-masked sdst, the global atomics, integer clamp, the mad flush and the f64 compares + +Nine `runtime/test/shaders` fixtures (`cs_w32_sdst_exec`, `cs_global_atomic32_int`, `cs_global_atomic32_rtn`, +`cs_global_atomic32_float`, `cs_global_atomic32_x2`, `cs_w32_clamp32`, `cs_w32_clamp16`, `cs_w32_mad_denorm`, +`cs_w32_vcmp_f64`) close the last GPU holes of `docs/design.md` rows 218, 226, 265, 379/380 and 381. They are +wave32 dumps of eight words whose values are derived in each header, registered in `runtime/test/shaders/check.py` +and `scripts/run_gpu_tests.py`, and their `.s` fixtures are generated by `tests/semantic/regen_fixtures.py` from the +marked `.asm` sources; `tests/semantic/test_batch4_gpu_fixtures.py` runs +the same disassembly in the interpreter and keeps the header, `CS_DUMPS` and the runner table in step. + +Run on the RDNA2 iGPU `gfx1036` through RADV (`RAPHAEL_MENDOCINO`, Mesa 27.0.0-devel, `MESA_VK_DEVICE_SELECT=1002:13c0!`): +9/9 fixtures and 72/72 words exact, through both `scripts/run_gpu_tests.py` (211/226 pass, 15 skipped, no failure) and +`runtime/test/shaders/check.py` (194/197 pass, 3 skipped). What each one measured: + +- **`cs_w32_sdst_exec`** (`EXEC`-masked sdst): all eight carry/sign-out ops under `EXEC = 0xAAAAAAAA` with operands + that carry, borrow or sign-out on every lane give the sdst mask `0xAAAAAAAA` (word `272` = 16 lanes | 1 << 8). +- **`cs_global_atomic32_int` / `_rtn` / `_float` / `_x2`** (32-bit global atomics): add/sub/smin/umin/smax/umax/and/or; + xor/swap/inc/dec plus four `glc` returns; fmin/fmax on 1.0/2.0, a qNaN and -0/+0, and cmpswap hit and miss; + and/or/xor/swap_x2 on 8-byte elements. Note that `global_atomic_cmpswap` accepts `glc` only on the form with a + single VGPR destination (`v4, v[0:1], v[2:3], off glc`); that is the form whose returned old word the fixture reads. +- **`cs_w32_clamp32` / `cs_w32_clamp16`** (integer clamp): the three `*_nc_u32`, two `*_nc_i32` and two `*_nc_u16` + forms saturate as documented, `clamp` without overflow keeps the sum, and the six carry ops saturate D to + `0xFFFFFFFF`/`0` while sdst keeps the real carry (out[7] of `cs_w32_clamp32` and out[3..7] of `cs_w32_clamp16`). +- **`cs_w32_mad_denorm`** (denormal flush): `v_mad_f32`, `v_mac_f32`, `v_mad_legacy_f32` and `v_mac_legacy_f32` + return `0` for a subnormal operand scaled into range and for a subnormal product, with a `clamp` case and a + non-flushing control (`7.0`). These opcodes are GFX10.1-only, so this checks the translator's model on the Vulkan + path, not the native instruction. +- **`cs_w32_vcmp_f64`** (f64 compares): all 16 predicates in both forms in eight words, four per dword; `v_cmp_*_f64` + on -0.0 against +0.0 gives `0xC 0xC 0xC 0xC` and `v_cmpx_*_f64` on a qNaN against 1.0 gives `0 0 0xF 0xF`. + +One translator gap the fixture worked around: the raw spelling `v_cmp_lt_f64 v[1:2], v[3:4]` (implicit VCC) is +rejected with `Unsupported: v_cmp destination`, while the assembler's printed form with `vcc_lo` translates; the +fixture spells the destination out, as a disassembled listing does. + ### Pixel-shader ISA on the hardware (`tools/ps_oracle.py`, EGEN-TOOL-PS-ORACLE) `tools/hw_oracle` only launches compute kernels, so what only a pixel shader has (`v_interp_*` and the parameter diff --git a/runtime/test/shaders/check.py b/runtime/test/shaders/check.py index f0ddf2f31..6bf381bb8 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_sdst_exec", "cs_global_atomic32_int", "cs_global_atomic32_rtn", "cs_global_atomic32_float", "cs_global_atomic32_x2", "cs_w32_clamp32", "cs_w32_clamp16", "cs_w32_mad_denorm", "cs_w32_vcmp_f64") # 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,11 @@ 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", + # the sdst masks are 32 EXEC bits wide, and one wave must hold the only lane 0 (the + # atomics are not idempotent, so four 8-lane groups' lane 0s would race) + "cs_w32_sdst_exec", "cs_global_atomic32_int", "cs_global_atomic32_rtn", + "cs_global_atomic32_float", "cs_global_atomic32_x2") 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]), @@ -204,7 +208,23 @@ 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]), + # batch 4: sdst under a partial EXEC (derivations in cs_w32_sdst_exec.asm); each sdst is 0xAAAAAAAA, + # so the word is 16 set lanes | lowest lane 1 << 8 + ("cs_w32_sdst_exec", [272, 272, 272, 272, 272, 272, 272, 272]), + # 32-bit GLOBAL atomics, the 15 ops and the four _x2 forms (derivations in each .asm header) + ("cs_global_atomic32_int", [0x80000004, 2, 0xFFFFFFFB, 3, 3, 0xFFFFFFFB, 0xF000F000, 0xFF0FFF0F]), + ("cs_global_atomic32_rtn", [0xFFFFFFFF, 0xCAFEF00D, 6, 4, 0x11111111, 0x100, 0xF0F0, 0xAAAA]), + ("cs_global_atomic32_float", [0x3F800000, 0x40000000, 0x40400000, 0, 0x43, 0x42, 0x55, 0x55]), + ("cs_global_atomic32_x2", [0xF000F000, 0x0F0F0F0F, 0xFF0FFF0F, 0xFFFFFFFF, + 0x55555555, 0xEDCBA987, 0xAAAABBBB, 0xCCCCDDDD]), + # integer clamp on the 32-bit VOP3 forms and the carry ops, then the 16-bit forms (#265) + ("cs_w32_clamp32", [0xFFFFFFFF, 0, 0, 0x7FFFFFFF, 0x80000000, 3, 12, 0]), + ("cs_w32_clamp16", [0xDEADFFFF, 0xDEAD0000, 0xDEAD0000, 0xFFFFFFFF, 0xFFFFFFFF, 0, 0, 0]), + # denormal flush in v_mad/v_mac_f32 and the legacy pair (#379 #380) + ("cs_w32_mad_denorm", [0, 0, 0, 0, 0x40E00000, 0, 0, 0]), + # all 16 v_cmp/v_cmpx_*_f64 predicates, four per dword (#381) + ("cs_w32_vcmp_f64", [0xC, 0xC, 0xC, 0xC, 0, 0, 0xF, 0xF])] # 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. diff --git a/runtime/test/shaders/cs_global_atomic32_float.asm b/runtime/test/shaders/cs_global_atomic32_float.asm new file mode 100644 index 000000000..394b43531 --- /dev/null +++ b/runtime/test/shaders/cs_global_atomic32_float.asm @@ -0,0 +1,66 @@ +; regen_fixtures: this source has a translator fixture in tests/semantic/fixtures/disasm +; The 32-bit float and compare-swap GLOBAL atomics (#226): fmin, fmax and cmpswap, hit and miss. +; Lane 0 of a wave32 group seeds six dwords through the output V# (base 0), runs the atomics through a global +; pointer (s[20:21] = 0, vaddr v1 = 0, so the address is the instruction offset), waits and reads them back: +; 0x40 fmin 1.0, 2.0 -> 1.0 (0x3F800000) +; 0x44 fmax 1.0, 2.0 -> 2.0 (0x40000000) +; 0x48 fmin qNaN (0x7FC00001), 3.0 -> 3.0 (NMin returns the non-NaN operand, no float-atomic extension) +; 0x4C fmax -0.0, +0.0 -> +0.0 (0x00000000; NMax ranks -0 below +0) +; 0x50 cmpswap 0x42 with DATA 0x43, CMP 0x42 -> hit: memory 0x43, vdst the old word 0x42 +; 0x54 cmpswap 0x55 with DATA 0x43, CMP 0x44 -> miss: memory and vdst both 0x55 +; The vdata pair is {DATA, CMP}: DATA in the low VGPR, the comparator in the next. Both cmpswap forms carry glc, +; which is where the returned old word comes from; the memory words are out[4] (hit) and out[6] (miss). +; out[0] = 0x40, out[1] = 0x44, out[2] = 0x48, out[3] = 0x4C, out[4] = 0x50, out[5] = 0x50's vdst, +; out[6] = 0x54, out[7] = 0x54's vdst. +; group: 32,1,1 +; Run: VKC_SUBGROUP_SIZE=32 vk_compute_test cs_global_atomic32_float.spv 1 dump -> out[0..7] = 1065353216 1073741824 1077936128 0 67 66 85 85 +; mattr: +wavefrontsize32,-wavefrontsize64 +v_cmpx_eq_u32_e32 0, v0 +v_mov_b32_e32 v11, 0 +v_mov_b32_e32 v10, 0x3f800000 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x40 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x44 +v_mov_b32_e32 v10, 0x7fc00001 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x48 +v_mov_b32_e32 v10, 0x80000000 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x4c +v_mov_b32_e32 v10, 0x42 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x50 +v_mov_b32_e32 v10, 0x55 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x54 +s_waitcnt vmcnt(0) +s_waitcnt_vscnt null, 0x0 +s_mov_b32 s20, 0 +s_mov_b32 s21, 0 +v_mov_b32 v1, 0 +v_mov_b32 v2, 0x40000000 +global_atomic_fmin v1, v2, s[20:21] offset:0x40 +global_atomic_fmax v1, v2, s[20:21] offset:0x44 +v_mov_b32 v2, 0x40400000 +global_atomic_fmin v1, v2, s[20:21] offset:0x48 +v_mov_b32 v2, 0 +global_atomic_fmax v1, v2, s[20:21] offset:0x4c +v_mov_b32 v2, 0x43 +v_mov_b32 v3, 0x42 +global_atomic_cmpswap v4, v1, v[2:3], s[20:21] offset:0x50 glc +v_mov_b32 v2, 0x43 +v_mov_b32 v3, 0x44 +global_atomic_cmpswap v5, v1, v[2:3], s[20:21] offset:0x54 glc +s_waitcnt vmcnt(0) +s_waitcnt_vscnt null, 0x0 +buffer_load_dword v6, v11, s[0:3], 0 offen offset:0x40 +buffer_load_dword v7, v11, s[0:3], 0 offen offset:0x44 +buffer_load_dword v8, v11, s[0:3], 0 offen offset:0x48 +buffer_load_dword v9, v11, s[0:3], 0 offen offset:0x4c +buffer_load_dword v10, v11, s[0:3], 0 offen offset:0x50 +buffer_load_dword v12, v11, s[0:3], 0 offen offset:0x54 +s_waitcnt vmcnt(0) +buffer_store_dword v6, v11, s[0:3], 0 offen +buffer_store_dword v7, v11, s[0:3], 0 offen offset:4 +buffer_store_dword v8, v11, s[0:3], 0 offen offset:8 +buffer_store_dword v9, v11, s[0:3], 0 offen offset:12 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:16 +buffer_store_dword v4, v11, s[0:3], 0 offen offset:20 +buffer_store_dword v12, v11, s[0:3], 0 offen offset:24 +buffer_store_dword v5, v11, s[0:3], 0 offen offset:28 +s_endpgm diff --git a/runtime/test/shaders/cs_global_atomic32_int.asm b/runtime/test/shaders/cs_global_atomic32_int.asm new file mode 100644 index 000000000..1d6062e05 --- /dev/null +++ b/runtime/test/shaders/cs_global_atomic32_int.asm @@ -0,0 +1,71 @@ +; regen_fixtures: this source has a translator fixture in tests/semantic/fixtures/disasm +; The ten integer 32-bit GLOBAL atomics, memory result (#226): add, sub, smin, umin, smax, umax, and, or. +; Lane 0 of a wave32 group seeds eight dwords through the output V# (base 0), runs one atomic on each through a +; global pointer (s[20:21] = 0, vaddr v1 = 0, so the address is the instruction offset), waits, reads each dword +; back and stores it: +; 0x40 add 5 + 0x7FFFFFFF = 0x80000004 +; 0x44 sub 5 - 3 = 2 +; 0x48 smin 0xFFFFFFFB (-5), 3 = 0xFFFFFFFB (signed: -5 < 3) +; 0x4C umin 0xFFFFFFFB, 3 = 3 (unsigned: 3 < 0xFFFFFFFB) +; 0x50 smax 0xFFFFFFFB (-5), 3 = 3 (signed: 3 > -5) +; 0x54 umax 0xFFFFFFFB, 3 = 0xFFFFFFFB (unsigned) +; 0x58 and 0xF0F0F0F0 & 0xFF00FF00 = 0xF000F000 +; 0x5C or 0x0F0F0F0F | 0xFF00FF00 = 0xFF0FFF0F +; The pairs above are what tells the signed and unsigned forms apart: the same operand pair gives opposite results. +; The `glc` returns and the other seven ops are in cs_global_atomic32_rtn.asm / cs_global_atomic32_float.asm. +; group: 32,1,1 +; Run: VKC_SUBGROUP_SIZE=32 vk_compute_test cs_global_atomic32_int.spv 1 dump -> out[0..7] = 2147483652 2 4294967291 3 3 4294967291 4026593280 4279238415 +; mattr: +wavefrontsize32,-wavefrontsize64 +v_cmpx_eq_u32_e32 0, v0 +v_mov_b32_e32 v11, 0 +v_mov_b32_e32 v10, 5 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x40 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x44 +v_mov_b32_e32 v10, 0xfffffffb +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x48 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x4c +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x50 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x54 +v_mov_b32_e32 v10, 0xf0f0f0f0 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x58 +v_mov_b32_e32 v10, 0x0f0f0f0f +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x5c +s_waitcnt vmcnt(0) +s_waitcnt_vscnt null, 0x0 +s_mov_b32 s20, 0 +s_mov_b32 s21, 0 +v_mov_b32 v1, 0 +v_mov_b32 v2, 0x7fffffff +global_atomic_add v1, v2, s[20:21] offset:0x40 +v_mov_b32 v2, 3 +global_atomic_sub v1, v2, s[20:21] offset:0x44 +v_mov_b32 v2, 3 +global_atomic_smin v1, v2, s[20:21] offset:0x48 +global_atomic_umin v1, v2, s[20:21] offset:0x4c +global_atomic_smax v1, v2, s[20:21] offset:0x50 +global_atomic_umax v1, v2, s[20:21] offset:0x54 +v_mov_b32 v2, 0xff00ff00 +global_atomic_and v1, v2, s[20:21] offset:0x58 +global_atomic_or v1, v2, s[20:21] offset:0x5c +s_waitcnt vmcnt(0) +s_waitcnt_vscnt null, 0x0 +buffer_load_dword v3, v11, s[0:3], 0 offen offset:0x40 +buffer_load_dword v4, v11, s[0:3], 0 offen offset:0x44 +buffer_load_dword v5, v11, s[0:3], 0 offen offset:0x48 +buffer_load_dword v6, v11, s[0:3], 0 offen offset:0x4c +buffer_load_dword v7, v11, s[0:3], 0 offen offset:0x50 +buffer_load_dword v8, v11, s[0:3], 0 offen offset:0x54 +buffer_load_dword v9, v11, s[0:3], 0 offen offset:0x58 +buffer_load_dword v10, v11, s[0:3], 0 offen offset:0x5c +s_waitcnt vmcnt(0) +v_cmpx_eq_u32_e32 0, v0 +v_mov_b32_e32 v11, 0 +buffer_store_dword v3, v11, s[0:3], 0 offen +buffer_store_dword v4, v11, s[0:3], 0 offen offset:4 +buffer_store_dword v5, v11, s[0:3], 0 offen offset:8 +buffer_store_dword v6, v11, s[0:3], 0 offen offset:12 +buffer_store_dword v7, v11, s[0:3], 0 offen offset:16 +buffer_store_dword v8, v11, s[0:3], 0 offen offset:20 +buffer_store_dword v9, v11, s[0:3], 0 offen offset:24 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:28 +s_endpgm diff --git a/runtime/test/shaders/cs_global_atomic32_rtn.asm b/runtime/test/shaders/cs_global_atomic32_rtn.asm new file mode 100644 index 000000000..c74b5bb51 --- /dev/null +++ b/runtime/test/shaders/cs_global_atomic32_rtn.asm @@ -0,0 +1,72 @@ +; regen_fixtures: this source has a translator fixture in tests/semantic/fixtures/disasm +; The other 32-bit GLOBAL atomics (#226): xor, swap, inc, dec, and add/sub/xor/swap again in their returning +; (glc) form, whose word is the pre-op value. +; Lane 0 of a wave32 group seeds eight dwords through the output V# (base 0), runs one atomic on each through a +; global pointer (s[20:21] = 0, vaddr v1 = 0, so the address is the instruction offset), waits, and stores: +; 0x40 xor 0xF0F0F0F0 ^ 0x0F0F0F0F = 0xFFFFFFFF -> out[0] +; 0x44 swap 0x12345678 -> 0xCAFEF00D -> out[1] (the old word is gone) +; 0x48 inc 5 with DATA 10: 5 < 10, so 6 -> out[2] +; 0x4C dec 5 with DATA 10: 0 < 5 < 10, so 4 -> out[3] +; 0x50 add glc: 0x11111111 + 0x22222222; vdst = the old word -> out[4] = 0x11111111 +; 0x54 sub glc: 0x100 - 1; vdst = the old word -> out[5] = 0x100 +; 0x58 xor glc: 0xF0F0 ^ 0x0FF0; vdst = the old word -> out[6] = 0xF0F0 +; 0x5C swap glc: 0xAAAA <- 0x5555; vdst = the old word -> out[7] = 0xAAAA +; inc wraps to 0 when M >= DATA and dec returns DATA when M == 0 or M > DATA (cs_global_atomic32_float.asm keeps +; the fmin/fmax and cmpswap cases); the glc words here are the pre-op values, which the memory result of the same +; op cannot be confused with. +; group: 32,1,1 +; Run: VKC_SUBGROUP_SIZE=32 vk_compute_test cs_global_atomic32_rtn.spv 1 dump -> out[0..7] = 4294967295 3405705229 6 4 286331153 256 61680 43690 +; mattr: +wavefrontsize32,-wavefrontsize64 +v_cmpx_eq_u32_e32 0, v0 +v_mov_b32_e32 v11, 0 +v_mov_b32_e32 v10, 0xf0f0f0f0 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x40 +v_mov_b32_e32 v10, 0x12345678 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x44 +v_mov_b32_e32 v10, 5 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x48 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x4c +v_mov_b32_e32 v10, 0x11111111 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x50 +v_mov_b32_e32 v10, 0x100 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x54 +v_mov_b32_e32 v10, 0xf0f0 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x58 +v_mov_b32_e32 v10, 0xaaaa +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x5c +s_waitcnt vmcnt(0) +s_waitcnt_vscnt null, 0x0 +s_mov_b32 s20, 0 +s_mov_b32 s21, 0 +v_mov_b32 v1, 0 +v_mov_b32 v2, 0x0f0f0f0f +global_atomic_xor v1, v2, s[20:21] offset:0x40 +v_mov_b32 v2, 0xcafef00d +global_atomic_swap v1, v2, s[20:21] offset:0x44 +v_mov_b32 v2, 10 +global_atomic_inc v1, v2, s[20:21] offset:0x48 +global_atomic_dec v1, v2, s[20:21] offset:0x4c +v_mov_b32 v2, 0x22222222 +global_atomic_add v6, v1, v2, s[20:21] offset:0x50 glc +v_mov_b32 v2, 1 +global_atomic_sub v7, v1, v2, s[20:21] offset:0x54 glc +v_mov_b32 v2, 0x0ff0 +global_atomic_xor v8, v1, v2, s[20:21] offset:0x58 glc +v_mov_b32 v2, 0x5555 +global_atomic_swap v9, v1, v2, s[20:21] offset:0x5c glc +s_waitcnt vmcnt(0) +s_waitcnt_vscnt null, 0x0 +buffer_load_dword v3, v11, s[0:3], 0 offen offset:0x40 +buffer_load_dword v4, v11, s[0:3], 0 offen offset:0x44 +buffer_load_dword v5, v11, s[0:3], 0 offen offset:0x48 +buffer_load_dword v10, v11, s[0:3], 0 offen offset:0x4c +s_waitcnt vmcnt(0) +buffer_store_dword v3, v11, s[0:3], 0 offen +buffer_store_dword v4, v11, s[0:3], 0 offen offset:4 +buffer_store_dword v5, v11, s[0:3], 0 offen offset:8 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:12 +buffer_store_dword v6, v11, s[0:3], 0 offen offset:16 +buffer_store_dword v7, v11, s[0:3], 0 offen offset:20 +buffer_store_dword v8, v11, s[0:3], 0 offen offset:24 +buffer_store_dword v9, v11, s[0:3], 0 offen offset:28 +s_endpgm diff --git a/runtime/test/shaders/cs_global_atomic32_x2.asm b/runtime/test/shaders/cs_global_atomic32_x2.asm new file mode 100644 index 000000000..ea2a33232 --- /dev/null +++ b/runtime/test/shaders/cs_global_atomic32_x2.asm @@ -0,0 +1,69 @@ +; regen_fixtures: this source has a translator fixture in tests/semantic/fixtures/disasm +; The four 64-bit-element GLOBAL atomics (#226): global_atomic_{and,or,xor,swap}_x2 on 8-byte-aligned elements. +; Lane 0 of a wave32 group seeds four 64-bit elements through the output V# (base 0), runs one atomic on each +; through a global pointer (s[20:21] = 0, vaddr v1 = 0, so the address is the instruction offset), waits, reads the +; elements back and stores them: +; 0x40 and_x2 {0xF0F0F0F0, 0xFFFFFFFF} & {0xFF00FF00, 0x0F0F0F0F} = {0xF000F000, 0x0F0F0F0F} +; 0x48 or_x2 {0x0F0F0F0F, 0x00000000} | {0xFF00FF00, 0xFFFFFFFF} = {0xFF0FFF0F, 0xFFFFFFFF} +; 0x50 xor_x2 {0xAAAA5555, 0x12345678} ^ {0xFFFF0000, 0xFFFFFFFF} = {0x55555555, 0xEDCBA987} +; 0x58 swap_x2 {0x11112222, 0x33334444} <- {0xAAAABBBB, 0xCCCCDDDD} = {0xAAAABBBB, 0xCCCCDDDD} +; Each element is two dwords, low word first, as one 32-bit atomic per dword: a bitwise op or an exchange leaves +; the same memory that way. out[0..1] = 0x40, out[2..3] = 0x48, out[4..5] = 0x50, out[6..7] = 0x58 (low, high). +; group: 32,1,1 +; Run: VKC_SUBGROUP_SIZE=32 vk_compute_test cs_global_atomic32_x2.spv 1 dump -> out[0..7] = 4026593280 252645135 4279238415 4294967295 1431655765 3989547399 2863315899 3435978205 +; mattr: +wavefrontsize32,-wavefrontsize64 +v_cmpx_eq_u32_e32 0, v0 +v_mov_b32_e32 v11, 0 +v_mov_b32_e32 v10, 0xf0f0f0f0 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x40 +v_mov_b32_e32 v10, 0xffffffff +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x44 +v_mov_b32_e32 v10, 0x0f0f0f0f +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x48 +v_mov_b32_e32 v10, 0 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x4c +v_mov_b32_e32 v10, 0xaaaa5555 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x50 +v_mov_b32_e32 v10, 0x12345678 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x54 +v_mov_b32_e32 v10, 0x11112222 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x58 +v_mov_b32_e32 v10, 0x33334444 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x5c +s_waitcnt vmcnt(0) +s_waitcnt_vscnt null, 0x0 +s_mov_b32 s20, 0 +s_mov_b32 s21, 0 +v_mov_b32 v1, 0 +v_mov_b32 v2, 0xff00ff00 +v_mov_b32 v3, 0x0f0f0f0f +global_atomic_and_x2 v1, v[2:3], s[20:21] offset:0x40 +v_mov_b32 v2, 0xff00ff00 +v_mov_b32 v3, 0xffffffff +global_atomic_or_x2 v1, v[2:3], s[20:21] offset:0x48 +v_mov_b32 v2, 0xffff0000 +v_mov_b32 v3, 0xffffffff +global_atomic_xor_x2 v1, v[2:3], s[20:21] offset:0x50 +v_mov_b32 v2, 0xaaaabbbb +v_mov_b32 v3, 0xccccdddd +global_atomic_swap_x2 v1, v[2:3], s[20:21] offset:0x58 +s_waitcnt vmcnt(0) +s_waitcnt_vscnt null, 0x0 +buffer_load_dword v4, v11, s[0:3], 0 offen offset:0x40 +buffer_load_dword v5, v11, s[0:3], 0 offen offset:0x44 +buffer_load_dword v6, v11, s[0:3], 0 offen offset:0x48 +buffer_load_dword v7, v11, s[0:3], 0 offen offset:0x4c +buffer_load_dword v8, v11, s[0:3], 0 offen offset:0x50 +buffer_load_dword v9, v11, s[0:3], 0 offen offset:0x54 +buffer_load_dword v10, v11, s[0:3], 0 offen offset:0x58 +buffer_load_dword v12, v11, s[0:3], 0 offen offset:0x5c +s_waitcnt vmcnt(0) +buffer_store_dword v4, v11, s[0:3], 0 offen +buffer_store_dword v5, v11, s[0:3], 0 offen offset:4 +buffer_store_dword v6, v11, s[0:3], 0 offen offset:8 +buffer_store_dword v7, v11, s[0:3], 0 offen offset:12 +buffer_store_dword v8, v11, s[0:3], 0 offen offset:16 +buffer_store_dword v9, v11, s[0:3], 0 offen offset:20 +buffer_store_dword v10, v11, s[0:3], 0 offen offset:24 +buffer_store_dword v12, v11, s[0:3], 0 offen offset:28 +s_endpgm diff --git a/runtime/test/shaders/cs_w32_clamp16.asm b/runtime/test/shaders/cs_w32_clamp16.asm new file mode 100644 index 000000000..b82f72b72 --- /dev/null +++ b/runtime/test/shaders/cs_w32_clamp16.asm @@ -0,0 +1,58 @@ +; regen_fixtures: this source has a translator fixture in tests/semantic/fixtures/disasm +; The 16-bit integer clamp bit and the five other carry-out ops with clamp (#265). +; Lane 0 of a wave32 group computes one result per form and stores eight dwords. The v_add_nc_u16/v_sub_nc_u16 +; destinations are preloaded with 0xDEAD0000: the VOP3 16-bit forms are partial writes that keep the high half. +; out[0] = v_add_nc_u16 0xFFFF + 1 clamp = 0xDEADFFFF (saturates to 0xFFFF, high half kept) +; out[1] = v_sub_nc_u16 1 - 2 clamp = 0xDEAD0000 (borrow saturates to 0) +; out[2] = v_add_nc_u16 0xFFFF + 1 = 0xDEAD0000 (no clamp: wraps to 0) +; out[3] = v_add_co_u32 0xFFFFFFFF + 1 clamp = 0xFFFFFFFF (carry saturates D; sdst still gets 1) +; out[4] = v_add_co_ci_u32 0xFFFFFFFF + 0 + carry-in 1 clamp = 0xFFFFFFFF +; out[5] = v_sub_co_u32 0 - 1 clamp = 0x00000000 (borrow saturates D; sdst still gets 1) +; out[6] = v_sub_co_ci_u32 0 - 0 - borrow-in 1 clamp = 0x00000000 +; out[7] = v_subrev_co_u32 1, 0 clamp = 0x00000000 (S1 - S0 = 0 - 1 borrows) +; The sdst of the carry ops keeps the real carry/borrow (the CPU test checks that); v_subrev_co_ci_u32 clamp is +; out[7] of cs_w32_clamp32.asm. The unsigned 16-bit names on gfx10 are the _nc_ ones: v_add_u16/v_subrev_u16 do +; not assemble for gfx1013. +; group: 32,1,1 +; Run: VKC_SUBGROUP_SIZE=32 vk_compute_test cs_w32_clamp16.spv 1 dump -> out[0..7] = 3735945215 3735879680 3735879680 4294967295 4294967295 0 0 0 +; mattr: +wavefrontsize32,-wavefrontsize64 +v_mov_b32_e32 v3, 0xdead0000 +v_mov_b32_e32 v4, 0xdead0000 +v_mov_b32_e32 v5, 0xdead0000 +v_mov_b32_e32 v1, 0xffff +v_mov_b32_e32 v2, 1 +v_add_nc_u16 v3, v1, v2 clamp +v_mov_b32_e32 v1, 1 +v_mov_b32_e32 v2, 2 +v_sub_nc_u16 v4, v1, v2 clamp +v_mov_b32_e32 v1, 0xffff +v_mov_b32_e32 v2, 1 +v_add_nc_u16 v5, v1, v2 +v_mov_b32_e32 v1, 0xffffffff +v_mov_b32_e32 v2, 1 +v_add_co_u32 v6, vcc_lo, v1, v2 clamp +s_mov_b32 vcc_lo, -1 +v_mov_b32_e32 v1, 0xffffffff +v_mov_b32_e32 v2, 0 +v_add_co_ci_u32_e64 v7, vcc_lo, v1, v2, vcc_lo clamp +v_mov_b32_e32 v1, 0 +v_mov_b32_e32 v2, 1 +v_sub_co_u32 v8, vcc_lo, v1, v2 clamp +s_mov_b32 vcc_lo, -1 +v_mov_b32_e32 v1, 0 +v_mov_b32_e32 v2, 0 +v_sub_co_ci_u32_e64 v9, vcc_lo, v1, v2, vcc_lo clamp +v_mov_b32_e32 v1, 1 +v_mov_b32_e32 v2, 0 +v_subrev_co_u32 v10, vcc_lo, v1, v2 clamp +v_cmpx_eq_u32_e32 0, v0 +v_mov_b32_e32 v20, 0 +buffer_store_dword v3, v20, s[0:3], 0 offen +buffer_store_dword v4, v20, s[0:3], 0 offen offset:4 +buffer_store_dword v5, v20, s[0:3], 0 offen offset:8 +buffer_store_dword v6, v20, s[0:3], 0 offen offset:12 +buffer_store_dword v7, v20, s[0:3], 0 offen offset:16 +buffer_store_dword v8, v20, s[0:3], 0 offen offset:20 +buffer_store_dword v9, v20, s[0:3], 0 offen offset:24 +buffer_store_dword v10, v20, s[0:3], 0 offen offset:28 +s_endpgm diff --git a/runtime/test/shaders/cs_w32_clamp32.asm b/runtime/test/shaders/cs_w32_clamp32.asm new file mode 100644 index 000000000..7fd75fb80 --- /dev/null +++ b/runtime/test/shaders/cs_w32_clamp32.asm @@ -0,0 +1,51 @@ +; regen_fixtures: this source has a translator fixture in tests/semantic/fixtures/disasm +; The 32-bit integer clamp bit on the VOP3 add/sub forms (#265): v_add/sub/subrev_nc_u32, v_add/sub_nc_i32 and one +; of the carry-out ops. Lane 0 of a wave32 group computes one result per form and stores eight dwords: +; out[0] = v_add_nc_u32 0xFFFFFFFE + 5 clamp = 0xFFFFFFFF (overflow saturates) +; out[1] = v_sub_nc_u32 5 - 10 clamp = 0x00000000 (borrow saturates to 0) +; out[2] = v_subrev_nc_u32 10, 5 clamp = 0x00000000 (S1 - S0 = 5 - 10; the operands are swapped) +; out[3] = v_add_nc_i32 0x7FFFFFFF + 1 clamp = 0x7FFFFFFF (signed add saturates at INT32_MAX) +; out[4] = v_sub_nc_i32 0x80000000 - 1 clamp = 0x80000000 (signed sub saturates at INT32_MIN) +; out[5] = v_add_nc_u32 0xFFFFFFFE + 5 = 0x00000003 (no clamp: wraps) +; out[6] = v_add_nc_i32 5 + 7 clamp = 0x0000000C (no overflow: clamp keeps the sum) +; out[7] = v_subrev_co_ci_u32 clamp, 0 - 0 - 1 = 0x00000000 (borrow-in saturates D to 0; sdst keeps the +; real borrow, checked by tests/semantic/test_alu_add_co_clamp.py) +; The 16-bit forms and the other five carry ops are in cs_w32_clamp16.asm. +; group: 32,1,1 +; Run: VKC_SUBGROUP_SIZE=32 vk_compute_test cs_w32_clamp32.spv 1 dump -> out[0..7] = 4294967295 0 0 2147483647 2147483648 3 12 0 +; mattr: +wavefrontsize32,-wavefrontsize64 +v_mov_b32_e32 v1, 0xfffffffe +v_mov_b32_e32 v2, 5 +v_add_nc_u32 v3, v1, v2 clamp +v_mov_b32_e32 v1, 5 +v_mov_b32_e32 v2, 10 +v_sub_nc_u32 v4, v1, v2 clamp +v_mov_b32_e32 v1, 10 +v_mov_b32_e32 v2, 5 +v_subrev_nc_u32 v5, v1, v2 clamp +v_mov_b32_e32 v1, 0x7fffffff +v_mov_b32_e32 v2, 1 +v_add_nc_i32 v6, v1, v2 clamp +v_mov_b32_e32 v1, 0x80000000 +v_sub_nc_i32 v7, v1, v2 clamp +v_mov_b32_e32 v1, 0xfffffffe +v_mov_b32_e32 v2, 5 +v_add_nc_u32 v8, v1, v2 +v_mov_b32_e32 v1, 5 +v_mov_b32_e32 v2, 7 +v_add_nc_i32 v9, v1, v2 clamp +s_mov_b32 vcc_lo, -1 +v_mov_b32_e32 v1, 0 +v_mov_b32_e32 v2, 0 +v_subrev_co_ci_u32_e64 v10, vcc_lo, v1, v2, vcc_lo clamp +v_cmpx_eq_u32_e32 0, v0 +v_mov_b32_e32 v20, 0 +buffer_store_dword v3, v20, s[0:3], 0 offen +buffer_store_dword v4, v20, s[0:3], 0 offen offset:4 +buffer_store_dword v5, v20, s[0:3], 0 offen offset:8 +buffer_store_dword v6, v20, s[0:3], 0 offen offset:12 +buffer_store_dword v7, v20, s[0:3], 0 offen offset:16 +buffer_store_dword v8, v20, s[0:3], 0 offen offset:20 +buffer_store_dword v9, v20, s[0:3], 0 offen offset:24 +buffer_store_dword v10, v20, s[0:3], 0 offen offset:28 +s_endpgm diff --git a/runtime/test/shaders/cs_w32_mad_denorm.asm b/runtime/test/shaders/cs_w32_mad_denorm.asm new file mode 100644 index 000000000..f4fe45cc2 --- /dev/null +++ b/runtime/test/shaders/cs_w32_mad_denorm.asm @@ -0,0 +1,54 @@ +; regen_fixtures: this source has a translator fixture in tests/semantic/fixtures/disasm +; Denormal flush in v_mad_f32, v_mac_f32, v_mad_legacy_f32 and v_mac_legacy_f32 (#379 #380): a subnormal operand or +; result reads as signed zero, so the Vulkan words check the translator's model even though the gfx1036 part does +; not decode these four GFX10.1 opcodes (the native measurement is an RDNA1 one). +; Lane 0 of a wave32 group computes one result per form and stores eight dwords. SUBN = 0x00000001 (2^-149), +; P23 = 0x4B000000 (2^23), FLT_MIN = 0x00800000, HALF = 0x3F000000: +; out[0] = v_mad_f32 SUBN * P23 + 0 = 0 (operand flushed; 2^-149 * 2^23 = FLT_MIN otherwise) +; out[1] = v_mad_f32 FLT_MIN * HALF + 0 = 0 (product 2^-127 flushed; 0x00400000 otherwise) +; out[2] = v_mad_f32 SUBN * P23 + 0 clamp = 0 (the flush runs before clamp) +; out[3] = v_mac_f32 D=0, SUBN * P23 = 0 (D is read as the addend; 0x00800000 otherwise) +; out[4] = v_mac_f32 D=1.0, 2.0 * 3.0 = 0x40E00000 (7.0; a control: the op itself runs) +; out[5] = v_mad_legacy_f32 SUBN * P23 + 0 = 0 +; out[6] = v_mad_legacy_f32 FLT_MIN * HALF + 0 = 0 +; out[7] = v_mac_legacy_f32 D=0, SUBN * P23 = 0 +; group: 32,1,1 +; Run: VKC_SUBGROUP_SIZE=32 vk_compute_test cs_w32_mad_denorm.spv 1 dump -> out[0..7] = 0 0 0 0 1088421888 0 0 0 +; mattr: +wavefrontsize32,-wavefrontsize64 +v_mov_b32_e32 v1, 1 +v_mov_b32_e32 v2, 0x4b000000 +v_mov_b32_e32 v4, 0 +v_mad_f32 v3, v1, v2, v4 +v_mov_b32_e32 v1, 0x00800000 +v_mov_b32_e32 v2, 0.5 +v_mad_f32 v5, v1, v2, v4 +v_mov_b32_e32 v1, 1 +v_mov_b32_e32 v2, 0x4b000000 +v_mad_f32 v6, v1, v2, v4 clamp +v_mov_b32_e32 v7, 0 +v_mac_f32 v7, v1, v2 +v_mov_b32_e32 v8, 1.0 +v_mov_b32_e32 v1, 2.0 +v_mov_b32_e32 v2, 3.0 +v_mac_f32 v8, v1, v2 +v_mov_b32_e32 v1, 1 +v_mov_b32_e32 v2, 0x4b000000 +v_mad_legacy_f32 v9, v1, v2, v4 +v_mov_b32_e32 v1, 0x00800000 +v_mov_b32_e32 v2, 0.5 +v_mad_legacy_f32 v10, v1, v2, v4 +v_mov_b32_e32 v1, 1 +v_mov_b32_e32 v2, 0x4b000000 +v_mov_b32_e32 v11, 0 +v_mac_legacy_f32 v11, v1, v2 +v_cmpx_eq_u32_e32 0, v0 +v_mov_b32_e32 v20, 0 +buffer_store_dword v3, v20, s[0:3], 0 offen +buffer_store_dword v5, v20, s[0:3], 0 offen offset:4 +buffer_store_dword v6, v20, s[0:3], 0 offen offset:8 +buffer_store_dword v7, v20, s[0:3], 0 offen offset:12 +buffer_store_dword v8, v20, s[0:3], 0 offen offset:16 +buffer_store_dword v9, v20, s[0:3], 0 offen offset:20 +buffer_store_dword v10, v20, s[0:3], 0 offen offset:24 +buffer_store_dword v11, v20, s[0:3], 0 offen offset:28 +s_endpgm diff --git a/runtime/test/shaders/cs_w32_sdst_exec.asm b/runtime/test/shaders/cs_w32_sdst_exec.asm new file mode 100644 index 000000000..b5aaf1cba --- /dev/null +++ b/runtime/test/shaders/cs_w32_sdst_exec.asm @@ -0,0 +1,140 @@ +; regen_fixtures: this source has a translator fixture in tests/semantic/fixtures/disasm +; The scalar destination of a VALU carry/sign-out op under a partial EXEC (#218): every active lane writes its +; carry/borrow bit, every inactive lane writes 0 (RDNA2 ISA: SDST[lane] = EXEC[lane] ? bit : 0), as v_cmp does. +; The eight ops each run with EXEC = 0xAAAAAAAA (odd lanes on) and operands that carry/borrow/sign-out on every +; lane, so a correct sdst is exactly 0xAAAAAAAA; an sdst that ignores EXEC is 0xFFFFFFFF. Lane 0 (off in that +; mask) reads the result back with the four places below: +; v_cndmask_b32_e64 v20, 0, 1, -> 1 on the lanes of the mask +; v_cmp_ne_u32_e32 vcc_lo, 0, v20 -> the mask again, now under the whole wave +; s_bcnt1 / s_ff1 of it -> lane count and lowest lane +; word = (set lanes) | (lowest lane) << 8, as cs_w32_mask_imm.asm derives: 16 | 1<<8 = 272; an unmasked sdst +; (all 32 bits) gives 32 | 0<<8 = 32, and a missing write 0 | -1<<8 = 0xFFFFFF00. +; out[0] = v_add_co_u32 v3, vcc, 0xFFFFFFFF, 1 -> 0xAAAAAAAA (carry on every active lane) +; out[1] = v_add_co_ci_u32 v3, vcc, 0xFFFFFFFF, 0 -> 0xAAAAAAAA (carry in from VCC = -1) +; out[2] = v_sub_co_u32 v3, s10, 0, 1 -> 0xAAAAAAAA (borrow on every active lane) +; out[3] = v_sub_co_ci_u32 v3, s10, 0, 0, s12 -> 0xAAAAAAAA (borrow in from s12 = -1) +; out[4] = v_subrev_co_u32 v3, s10, 1, 0 -> 0xAAAAAAAA (0 - 1) +; out[5] = v_subrev_co_ci_u32 v3, s10, 0, 0, s12 -> 0xAAAAAAAA (0 - 0 - 1) +; out[6] = v_mad_u64_u32 v[24:25], s10, 0xFFFFFFFF, 1, 0xFFFFFFFF_FFFFFFFF -> 0xAAAAAAAA (carry out) +; out[7] = v_mad_i64_i32 v[24:25], s10, -1, 1, 0 -> 0xAAAAAAAA (sum -1, sign bit 64) +; Until 2026-11-22 the six `*_co_*` ops and the two `v_mad_*64` ops did not AND the carry/sign bit with +; `active`, so inactive lanes leaked 1 bits into VCC/SGPR masks and s_bcnt1/s_cbranch_vccz/v_cndmask saw them. +; group: 32,1,1 +; Run: VKC_SUBGROUP_SIZE=32 vk_compute_test cs_w32_sdst_exec.spv 1 dump -> out[0..7] = 272 272 272 272 272 272 272 272 +; mattr: +wavefrontsize32,-wavefrontsize64 +v_mov_b32_e32 v1, 0xffffffff +v_mov_b32_e32 v2, 1 +s_mov_b32 exec_lo, 0xaaaaaaaa +v_add_co_u32 v3, vcc_lo, v1, v2 +s_mov_b32 exec_lo, -1 +v_cndmask_b32_e64 v20, 0, 1, vcc_lo +v_cmp_ne_u32_e32 vcc_lo, 0, v20 +s_bcnt1_i32_b32 s20, vcc_lo +s_ff1_i32_b32 s21, vcc_lo +s_lshl_b32 s21, s21, 8 +s_or_b32 s20, s20, s21 +s_mov_b32 vcc_lo, -1 +v_mov_b32_e32 v2, 0 +s_mov_b32 exec_lo, 0xaaaaaaaa +v_add_co_ci_u32_e32 v3, vcc_lo, v1, v2, vcc_lo +s_mov_b32 exec_lo, -1 +v_cndmask_b32_e64 v20, 0, 1, vcc_lo +v_cmp_ne_u32_e32 vcc_lo, 0, v20 +s_bcnt1_i32_b32 s22, vcc_lo +s_ff1_i32_b32 s23, vcc_lo +s_lshl_b32 s23, s23, 8 +s_or_b32 s22, s22, s23 +v_mov_b32_e32 v4, 0 +v_mov_b32_e32 v5, 1 +s_mov_b32 exec_lo, 0xaaaaaaaa +v_sub_co_u32 v3, s10, v4, v5 +s_mov_b32 exec_lo, -1 +v_cndmask_b32_e64 v20, 0, 1, s10 +v_cmp_ne_u32_e32 vcc_lo, 0, v20 +s_bcnt1_i32_b32 s24, vcc_lo +s_ff1_i32_b32 s25, vcc_lo +s_lshl_b32 s25, s25, 8 +s_or_b32 s24, s24, s25 +s_mov_b32 s12, -1 +v_mov_b32_e32 v6, 0 +s_mov_b32 exec_lo, 0xaaaaaaaa +v_sub_co_ci_u32_e64 v3, s10, v6, v6, s12 +s_mov_b32 exec_lo, -1 +v_cndmask_b32_e64 v20, 0, 1, s10 +v_cmp_ne_u32_e32 vcc_lo, 0, v20 +s_bcnt1_i32_b32 s26, vcc_lo +s_ff1_i32_b32 s27, vcc_lo +s_lshl_b32 s27, s27, 8 +s_or_b32 s26, s26, s27 +v_mov_b32_e32 v7, 1 +v_mov_b32_e32 v8, 0 +s_mov_b32 exec_lo, 0xaaaaaaaa +v_subrev_co_u32 v3, s10, v7, v8 +s_mov_b32 exec_lo, -1 +v_cndmask_b32_e64 v20, 0, 1, s10 +v_cmp_ne_u32_e32 vcc_lo, 0, v20 +s_bcnt1_i32_b32 s28, vcc_lo +s_ff1_i32_b32 s29, vcc_lo +s_lshl_b32 s29, s29, 8 +s_or_b32 s28, s28, s29 +s_mov_b32 exec_lo, 0xaaaaaaaa +v_subrev_co_ci_u32_e64 v3, s10, v6, v6, s12 +s_mov_b32 exec_lo, -1 +v_cndmask_b32_e64 v20, 0, 1, s10 +v_cmp_ne_u32_e32 vcc_lo, 0, v20 +s_bcnt1_i32_b32 s30, vcc_lo +s_ff1_i32_b32 s31, vcc_lo +s_lshl_b32 s31, s31, 8 +s_or_b32 s30, s30, s31 +v_mov_b32_e32 v9, 0xffffffff +v_mov_b32_e32 v10, 1 +v_mov_b32_e32 v12, 0xffffffff +v_mov_b32_e32 v13, 0xffffffff +s_mov_b32 exec_lo, 0xaaaaaaaa +v_mad_u64_u32 v[24:25], s10, v9, v10, v[12:13] +s_mov_b32 exec_lo, -1 +v_cndmask_b32_e64 v20, 0, 1, s10 +v_cmp_ne_u32_e32 vcc_lo, 0, v20 +s_bcnt1_i32_b32 s32, vcc_lo +s_ff1_i32_b32 s33, vcc_lo +s_lshl_b32 s33, s33, 8 +s_or_b32 s32, s32, s33 +v_mov_b32_e32 v14, -1 +v_mov_b32_e32 v15, 1 +v_mov_b32_e32 v16, 0 +v_mov_b32_e32 v17, 0 +s_mov_b32 exec_lo, 0xaaaaaaaa +v_mad_i64_i32 v[24:25], s10, v14, v15, v[16:17] +s_mov_b32 exec_lo, -1 +v_cndmask_b32_e64 v20, 0, 1, s10 +v_cmp_ne_u32_e32 vcc_lo, 0, v20 +s_bcnt1_i32_b32 s34, vcc_lo +s_ff1_i32_b32 s35, vcc_lo +s_lshl_b32 s35, s35, 8 +s_or_b32 s34, s34, s35 +v_cmpx_eq_u32_e32 0, v0 +v_mov_b32_e32 v1, s20 +v_mov_b32_e32 v2, 0 +buffer_store_dword v1, v2, s[0:3], 0 offen +v_mov_b32_e32 v1, s22 +v_mov_b32_e32 v2, 4 +buffer_store_dword v1, v2, s[0:3], 0 offen +v_mov_b32_e32 v1, s24 +v_mov_b32_e32 v2, 8 +buffer_store_dword v1, v2, s[0:3], 0 offen +v_mov_b32_e32 v1, s26 +v_mov_b32_e32 v2, 12 +buffer_store_dword v1, v2, s[0:3], 0 offen +v_mov_b32_e32 v1, s28 +v_mov_b32_e32 v2, 16 +buffer_store_dword v1, v2, s[0:3], 0 offen +v_mov_b32_e32 v1, s30 +v_mov_b32_e32 v2, 20 +buffer_store_dword v1, v2, s[0:3], 0 offen +v_mov_b32_e32 v1, s32 +v_mov_b32_e32 v2, 24 +buffer_store_dword v1, v2, s[0:3], 0 offen +v_mov_b32_e32 v1, s34 +v_mov_b32_e32 v2, 28 +buffer_store_dword v1, v2, s[0:3], 0 offen +s_endpgm diff --git a/runtime/test/shaders/cs_w32_vcmp_f64.asm b/runtime/test/shaders/cs_w32_vcmp_f64.asm new file mode 100644 index 000000000..6c0549ca1 --- /dev/null +++ b/runtime/test/shaders/cs_w32_vcmp_f64.asm @@ -0,0 +1,173 @@ +; regen_fixtures: this source has a translator fixture in tests/semantic/fixtures/disasm +; All 16 binary64 compare predicates in both forms (#381): v_cmp_*_f64 (VCC destination, spelled out as a +; disassembly does) and v_cmpx_*_f64 (EXEC narrowing), 32 instructions packed into eight dwords, four +; predicates per dword. +; Lane 0 of a wave32 group stores out[0..3] from the v_cmp half and out[4..7] from the v_cmpx half. Predicate i of +; each group of four lands in bit i of the group's dword (f, lt, eq, le | gt, lg, ge, o | u, nge, nlg, ngt | +; nle, neq, nlt, tru). +; v_cmp half: v[1:2] = -0.0 (0x80000000_00000000), v[3:4] = +0.0. Equal and ordered, so eq/le/ge/o/tru are 1 +; and f/lt/gt/lg/u/nge/neq/nle are 0; nlg, ngt and nlt are 1. +; dwords 0xC 0xC 0xC 0xC (-0.0 compares equal to +0.0, not below it) +; v_cmpx half: v[5:6] = qNaN (0x7FF80000_00000000), v[7:8] = 1.0. Every ordered predicate is 0, so EXEC goes to +; 0 on f/lt/eq/le/gt/lg/ge/o, and u/nge/nlg/ngt/nle/neq/nlt/tru are 1. +; dwords 0 0 0xF 0xF +; v_cmpx reads EXEC: v9 is preloaded 0, only lanes the compare left on run the trailing v_mov_b32 v9, 1, and EXEC +; is restored before the next predicate. +; group: 32,1,1 +; Run: VKC_SUBGROUP_SIZE=32 vk_compute_test cs_w32_vcmp_f64.spv 1 dump -> out[0..7] = 12 12 12 12 0 0 15 15 +; mattr: +wavefrontsize32,-wavefrontsize64 +v_mov_b32_e32 v1, 0 +v_mov_b32_e32 v2, 0x80000000 +v_mov_b32_e32 v3, 0 +v_mov_b32_e32 v4, 0 +v_mov_b32_e32 v5, 0 +v_mov_b32_e32 v6, 0x7ff80000 +v_mov_b32_e32 v7, 0 +v_mov_b32_e32 v8, 0x3ff00000 +v_mov_b32_e32 v20, 0 +v_mov_b32_e32 v21, 0 +v_mov_b32_e32 v22, 0 +v_mov_b32_e32 v23, 0 +v_mov_b32_e32 v24, 0 +v_mov_b32_e32 v25, 0 +v_mov_b32_e32 v26, 0 +v_mov_b32_e32 v27, 0 +v_cmp_f_f64 vcc_lo, v[1:2], v[3:4] +v_cndmask_b32_e64 v9, 0, 1, vcc_lo +v_lshl_or_b32 v20, v9, 0, v20 +v_cmp_lt_f64 vcc_lo, v[1:2], v[3:4] +v_cndmask_b32_e64 v9, 0, 1, vcc_lo +v_lshl_or_b32 v20, v9, 1, v20 +v_cmp_eq_f64 vcc_lo, v[1:2], v[3:4] +v_cndmask_b32_e64 v9, 0, 1, vcc_lo +v_lshl_or_b32 v20, v9, 2, v20 +v_cmp_le_f64 vcc_lo, v[1:2], v[3:4] +v_cndmask_b32_e64 v9, 0, 1, vcc_lo +v_lshl_or_b32 v20, v9, 3, v20 +v_cmp_gt_f64 vcc_lo, v[1:2], v[3:4] +v_cndmask_b32_e64 v9, 0, 1, vcc_lo +v_lshl_or_b32 v21, v9, 0, v21 +v_cmp_lg_f64 vcc_lo, v[1:2], v[3:4] +v_cndmask_b32_e64 v9, 0, 1, vcc_lo +v_lshl_or_b32 v21, v9, 1, v21 +v_cmp_ge_f64 vcc_lo, v[1:2], v[3:4] +v_cndmask_b32_e64 v9, 0, 1, vcc_lo +v_lshl_or_b32 v21, v9, 2, v21 +v_cmp_o_f64 vcc_lo, v[1:2], v[3:4] +v_cndmask_b32_e64 v9, 0, 1, vcc_lo +v_lshl_or_b32 v21, v9, 3, v21 +v_cmp_u_f64 vcc_lo, v[1:2], v[3:4] +v_cndmask_b32_e64 v9, 0, 1, vcc_lo +v_lshl_or_b32 v22, v9, 0, v22 +v_cmp_nge_f64 vcc_lo, v[1:2], v[3:4] +v_cndmask_b32_e64 v9, 0, 1, vcc_lo +v_lshl_or_b32 v22, v9, 1, v22 +v_cmp_nlg_f64 vcc_lo, v[1:2], v[3:4] +v_cndmask_b32_e64 v9, 0, 1, vcc_lo +v_lshl_or_b32 v22, v9, 2, v22 +v_cmp_ngt_f64 vcc_lo, v[1:2], v[3:4] +v_cndmask_b32_e64 v9, 0, 1, vcc_lo +v_lshl_or_b32 v22, v9, 3, v22 +v_cmp_nle_f64 vcc_lo, v[1:2], v[3:4] +v_cndmask_b32_e64 v9, 0, 1, vcc_lo +v_lshl_or_b32 v23, v9, 0, v23 +v_cmp_neq_f64 vcc_lo, v[1:2], v[3:4] +v_cndmask_b32_e64 v9, 0, 1, vcc_lo +v_lshl_or_b32 v23, v9, 1, v23 +v_cmp_nlt_f64 vcc_lo, v[1:2], v[3:4] +v_cndmask_b32_e64 v9, 0, 1, vcc_lo +v_lshl_or_b32 v23, v9, 2, v23 +v_cmp_tru_f64 vcc_lo, v[1:2], v[3:4] +v_cndmask_b32_e64 v9, 0, 1, vcc_lo +v_lshl_or_b32 v23, v9, 3, v23 +v_mov_b32_e32 v9, 0 +v_cmpx_f_f64 v[5:6], v[7:8] +v_mov_b32_e32 v9, 1 +s_mov_b32 exec_lo, -1 +v_lshl_or_b32 v24, v9, 0, v24 +v_mov_b32_e32 v9, 0 +v_cmpx_lt_f64 v[5:6], v[7:8] +v_mov_b32_e32 v9, 1 +s_mov_b32 exec_lo, -1 +v_lshl_or_b32 v24, v9, 1, v24 +v_mov_b32_e32 v9, 0 +v_cmpx_eq_f64 v[5:6], v[7:8] +v_mov_b32_e32 v9, 1 +s_mov_b32 exec_lo, -1 +v_lshl_or_b32 v24, v9, 2, v24 +v_mov_b32_e32 v9, 0 +v_cmpx_le_f64 v[5:6], v[7:8] +v_mov_b32_e32 v9, 1 +s_mov_b32 exec_lo, -1 +v_lshl_or_b32 v24, v9, 3, v24 +v_mov_b32_e32 v9, 0 +v_cmpx_gt_f64 v[5:6], v[7:8] +v_mov_b32_e32 v9, 1 +s_mov_b32 exec_lo, -1 +v_lshl_or_b32 v25, v9, 0, v25 +v_mov_b32_e32 v9, 0 +v_cmpx_lg_f64 v[5:6], v[7:8] +v_mov_b32_e32 v9, 1 +s_mov_b32 exec_lo, -1 +v_lshl_or_b32 v25, v9, 1, v25 +v_mov_b32_e32 v9, 0 +v_cmpx_ge_f64 v[5:6], v[7:8] +v_mov_b32_e32 v9, 1 +s_mov_b32 exec_lo, -1 +v_lshl_or_b32 v25, v9, 2, v25 +v_mov_b32_e32 v9, 0 +v_cmpx_o_f64 v[5:6], v[7:8] +v_mov_b32_e32 v9, 1 +s_mov_b32 exec_lo, -1 +v_lshl_or_b32 v25, v9, 3, v25 +v_mov_b32_e32 v9, 0 +v_cmpx_u_f64 v[5:6], v[7:8] +v_mov_b32_e32 v9, 1 +s_mov_b32 exec_lo, -1 +v_lshl_or_b32 v26, v9, 0, v26 +v_mov_b32_e32 v9, 0 +v_cmpx_nge_f64 v[5:6], v[7:8] +v_mov_b32_e32 v9, 1 +s_mov_b32 exec_lo, -1 +v_lshl_or_b32 v26, v9, 1, v26 +v_mov_b32_e32 v9, 0 +v_cmpx_nlg_f64 v[5:6], v[7:8] +v_mov_b32_e32 v9, 1 +s_mov_b32 exec_lo, -1 +v_lshl_or_b32 v26, v9, 2, v26 +v_mov_b32_e32 v9, 0 +v_cmpx_ngt_f64 v[5:6], v[7:8] +v_mov_b32_e32 v9, 1 +s_mov_b32 exec_lo, -1 +v_lshl_or_b32 v26, v9, 3, v26 +v_mov_b32_e32 v9, 0 +v_cmpx_nle_f64 v[5:6], v[7:8] +v_mov_b32_e32 v9, 1 +s_mov_b32 exec_lo, -1 +v_lshl_or_b32 v27, v9, 0, v27 +v_mov_b32_e32 v9, 0 +v_cmpx_neq_f64 v[5:6], v[7:8] +v_mov_b32_e32 v9, 1 +s_mov_b32 exec_lo, -1 +v_lshl_or_b32 v27, v9, 1, v27 +v_mov_b32_e32 v9, 0 +v_cmpx_nlt_f64 v[5:6], v[7:8] +v_mov_b32_e32 v9, 1 +s_mov_b32 exec_lo, -1 +v_lshl_or_b32 v27, v9, 2, v27 +v_mov_b32_e32 v9, 0 +v_cmpx_tru_f64 v[5:6], v[7:8] +v_mov_b32_e32 v9, 1 +s_mov_b32 exec_lo, -1 +v_lshl_or_b32 v27, v9, 3, v27 +v_cmpx_eq_u32_e32 0, v0 +v_mov_b32_e32 v10, 0 +buffer_store_dword v20, v10, s[0:3], 0 offen +buffer_store_dword v21, v10, s[0:3], 0 offen offset:4 +buffer_store_dword v22, v10, s[0:3], 0 offen offset:8 +buffer_store_dword v23, v10, s[0:3], 0 offen offset:12 +buffer_store_dword v24, v10, s[0:3], 0 offen offset:16 +buffer_store_dword v25, v10, s[0:3], 0 offen offset:20 +buffer_store_dword v26, v10, s[0:3], 0 offen offset:24 +buffer_store_dword v27, v10, s[0:3], 0 offen offset:28 +s_endpgm diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py index 8ba62104d..cb260010e 100644 --- a/scripts/run_gpu_tests.py +++ b/scripts/run_gpu_tests.py @@ -1201,7 +1201,7 @@ def run_suite(a, work: str) -> int: # Whole-wave mask test, as in check.py: needs a 64-wide subgroup, skipped where the device has none. # With LEONIDA_W64_EMULATE=1 it was translated with --wave64-emulate and runs on any subgroup size. results.append((name,) + wavemask_check(vk_compute, spv, cs_env, w64_emulated())) - elif name in ("cs_smem_vcc_base", "cs_store", "cs_signed_zero_nan", "cs_smem_soffset_imm", "cs_w32_lane_wrap", "cs_movrelsd_2", "cs_w32_permute", "cs_w32_sincos", "cs_w32_buffer_sub16", "cs_w32_buffer_store_sub", "cs_w32_fcmpswap", "cs_w32_permlane_fi", "cs_exec_const", "cs_w32_mask_imm", "cs_w64_mask_imm", "cs_w32_lds_u8_d16", "cs_w32_lds_subdword", "cs_w32_lds_wide", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", "cs_wave64_ballot", "cs_wm_half_ops", "cs_wm_half_cmp", "cs_wm_bfm64", "cs_wm_scc_rfl", "cs_wqm_w64", "cs_wqm_w32", "cs_wqm_w64_half", + elif name in ("cs_smem_vcc_base", "cs_store", "cs_signed_zero_nan", "cs_smem_soffset_imm", "cs_w32_lane_wrap", "cs_movrelsd_2", "cs_w32_permute", "cs_w32_sincos", "cs_w32_buffer_sub16", "cs_w32_buffer_store_sub", "cs_w32_fcmpswap", "cs_w32_permlane_fi", "cs_exec_const", "cs_w32_mask_imm", "cs_w64_mask_imm", "cs_w32_lds_u8_d16", "cs_w32_lds_subdword", "cs_w32_lds_wide", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", "cs_w32_sdst_exec", "cs_global_atomic32_int", "cs_global_atomic32_rtn", "cs_global_atomic32_float", "cs_global_atomic32_x2", "cs_w32_clamp32", "cs_w32_clamp16", "cs_w32_mad_denorm", "cs_w32_vcmp_f64", "cs_wave64_ballot", "cs_wm_half_ops", "cs_wm_half_cmp", "cs_wm_bfm64", "cs_wm_scc_rfl", "cs_wqm_w64", "cs_wqm_w32", "cs_wqm_w64_half", "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", "cs_dpp_ops", "cs_dpp_bank", "cs_dpp_fi", "cs_dpp_bound", "cs_dpp_cmp", "cs_dpp_w64", "cs_w64_mask_detect", @@ -1322,6 +1322,19 @@ 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], + # batch 4: sdst under a partial EXEC (cs_w32_sdst_exec.asm; 16 lanes | 1 << 8), the 32-bit + # GLOBAL atomics with and without glc (cs_global_atomic32_*.asm), integer clamp (#265), + # denormal flush (#379 #380) and the 16 v_cmp/v_cmpx_*_f64 predicates (#381) + "cs_w32_sdst_exec": [272, 272, 272, 272, 272, 272, 272, 272], + "cs_global_atomic32_int": [0x80000004, 2, 0xFFFFFFFB, 3, 3, 0xFFFFFFFB, 0xF000F000, 0xFF0FFF0F], + "cs_global_atomic32_rtn": [0xFFFFFFFF, 0xCAFEF00D, 6, 4, 0x11111111, 0x100, 0xF0F0, 0xAAAA], + "cs_global_atomic32_float": [0x3F800000, 0x40000000, 0x40400000, 0, 0x43, 0x42, 0x55, 0x55], + "cs_global_atomic32_x2": [0xF000F000, 0x0F0F0F0F, 0xFF0FFF0F, 0xFFFFFFFF, + 0x55555555, 0xEDCBA987, 0xAAAABBBB, 0xCCCCDDDD], + "cs_w32_clamp32": [0xFFFFFFFF, 0, 0, 0x7FFFFFFF, 0x80000000, 3, 12, 0], + "cs_w32_clamp16": [0xDEADFFFF, 0xDEAD0000, 0xDEAD0000, 0xFFFFFFFF, 0xFFFFFFFF, 0, 0, 0], + "cs_w32_mad_denorm": [0, 0, 0, 0, 0x40E00000, 0, 0, 0], + "cs_w32_vcmp_f64": [0xC, 0xC, 0xC, 0xC, 0, 0, 0xF, 0xF], } want = cs_dump_wants[name] # Every dump but cs_store / cs_smem_soffset_imm / cs_w32_lane_wrap / cs_movrelsd_2 / cs_w32_permute / @@ -1340,6 +1353,9 @@ def run_suite(a, work: str) -> int: "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_w32_sdst_exec", "cs_global_atomic32_int", "cs_global_atomic32_rtn", + "cs_global_atomic32_float", "cs_global_atomic32_x2", "cs_w32_clamp32", + "cs_w32_clamp16", "cs_w32_mad_denorm", "cs_w32_vcmp_f64", "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 diff --git a/tests/semantic/fixtures/disasm/cs_global_atomic32_float.s b/tests/semantic/fixtures/disasm/cs_global_atomic32_float.s new file mode 100644 index 000000000..6c34117c2 --- /dev/null +++ b/tests/semantic/fixtures/disasm/cs_global_atomic32_float.s @@ -0,0 +1,50 @@ +; cs_global_atomic32_float test fixture generated by tests/semantic/regen_fixtures.py from runtime/test/shaders/cs_global_atomic32_float.asm + v_cmpx_eq_u32_e32 0, v0 + v_mov_b32_e32 v11, 0 + v_mov_b32_e32 v10, 0x3f800000 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x40 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x44 + v_mov_b32_e32 v10, 0x7fc00001 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x48 + v_mov_b32_e32 v10, 0x80000000 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x4c + v_mov_b32_e32 v10, 0x42 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x50 + v_mov_b32_e32 v10, 0x55 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x54 + s_waitcnt vmcnt(0) + s_waitcnt_vscnt null, 0x0 + s_mov_b32 s20, 0 + s_mov_b32 s21, 0 + v_mov_b32 v1, 0 + v_mov_b32 v2, 0x40000000 + global_atomic_fmin v1, v2, s[20:21] offset:0x40 + global_atomic_fmax v1, v2, s[20:21] offset:0x44 + v_mov_b32 v2, 0x40400000 + global_atomic_fmin v1, v2, s[20:21] offset:0x48 + v_mov_b32 v2, 0 + global_atomic_fmax v1, v2, s[20:21] offset:0x4c + v_mov_b32 v2, 0x43 + v_mov_b32 v3, 0x42 + global_atomic_cmpswap v4, v1, v[2:3], s[20:21] offset:0x50 glc + v_mov_b32 v2, 0x43 + v_mov_b32 v3, 0x44 + global_atomic_cmpswap v5, v1, v[2:3], s[20:21] offset:0x54 glc + s_waitcnt vmcnt(0) + s_waitcnt_vscnt null, 0x0 + buffer_load_dword v6, v11, s[0:3], 0 offen offset:0x40 + buffer_load_dword v7, v11, s[0:3], 0 offen offset:0x44 + buffer_load_dword v8, v11, s[0:3], 0 offen offset:0x48 + buffer_load_dword v9, v11, s[0:3], 0 offen offset:0x4c + buffer_load_dword v10, v11, s[0:3], 0 offen offset:0x50 + buffer_load_dword v12, v11, s[0:3], 0 offen offset:0x54 + s_waitcnt vmcnt(0) + buffer_store_dword v6, v11, s[0:3], 0 offen + buffer_store_dword v7, v11, s[0:3], 0 offen offset:4 + buffer_store_dword v8, v11, s[0:3], 0 offen offset:8 + buffer_store_dword v9, v11, s[0:3], 0 offen offset:12 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:16 + buffer_store_dword v4, v11, s[0:3], 0 offen offset:20 + buffer_store_dword v12, v11, s[0:3], 0 offen offset:24 + buffer_store_dword v5, v11, s[0:3], 0 offen offset:28 + s_endpgm diff --git a/tests/semantic/fixtures/disasm/cs_global_atomic32_int.s b/tests/semantic/fixtures/disasm/cs_global_atomic32_int.s new file mode 100644 index 000000000..899eb0298 --- /dev/null +++ b/tests/semantic/fixtures/disasm/cs_global_atomic32_int.s @@ -0,0 +1,54 @@ +; cs_global_atomic32_int test fixture generated by tests/semantic/regen_fixtures.py from runtime/test/shaders/cs_global_atomic32_int.asm + v_cmpx_eq_u32_e32 0, v0 + v_mov_b32_e32 v11, 0 + v_mov_b32_e32 v10, 5 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x40 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x44 + v_mov_b32_e32 v10, 0xfffffffb + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x48 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x4c + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x50 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x54 + v_mov_b32_e32 v10, 0xf0f0f0f0 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x58 + v_mov_b32_e32 v10, 0x0f0f0f0f + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x5c + s_waitcnt vmcnt(0) + s_waitcnt_vscnt null, 0x0 + s_mov_b32 s20, 0 + s_mov_b32 s21, 0 + v_mov_b32 v1, 0 + v_mov_b32 v2, 0x7fffffff + global_atomic_add v1, v2, s[20:21] offset:0x40 + v_mov_b32 v2, 3 + global_atomic_sub v1, v2, s[20:21] offset:0x44 + v_mov_b32 v2, 3 + global_atomic_smin v1, v2, s[20:21] offset:0x48 + global_atomic_umin v1, v2, s[20:21] offset:0x4c + global_atomic_smax v1, v2, s[20:21] offset:0x50 + global_atomic_umax v1, v2, s[20:21] offset:0x54 + v_mov_b32 v2, 0xff00ff00 + global_atomic_and v1, v2, s[20:21] offset:0x58 + global_atomic_or v1, v2, s[20:21] offset:0x5c + s_waitcnt vmcnt(0) + s_waitcnt_vscnt null, 0x0 + buffer_load_dword v3, v11, s[0:3], 0 offen offset:0x40 + buffer_load_dword v4, v11, s[0:3], 0 offen offset:0x44 + buffer_load_dword v5, v11, s[0:3], 0 offen offset:0x48 + buffer_load_dword v6, v11, s[0:3], 0 offen offset:0x4c + buffer_load_dword v7, v11, s[0:3], 0 offen offset:0x50 + buffer_load_dword v8, v11, s[0:3], 0 offen offset:0x54 + buffer_load_dword v9, v11, s[0:3], 0 offen offset:0x58 + buffer_load_dword v10, v11, s[0:3], 0 offen offset:0x5c + s_waitcnt vmcnt(0) + v_cmpx_eq_u32_e32 0, v0 + v_mov_b32_e32 v11, 0 + buffer_store_dword v3, v11, s[0:3], 0 offen + buffer_store_dword v4, v11, s[0:3], 0 offen offset:4 + buffer_store_dword v5, v11, s[0:3], 0 offen offset:8 + buffer_store_dword v6, v11, s[0:3], 0 offen offset:12 + buffer_store_dword v7, v11, s[0:3], 0 offen offset:16 + buffer_store_dword v8, v11, s[0:3], 0 offen offset:20 + buffer_store_dword v9, v11, s[0:3], 0 offen offset:24 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:28 + s_endpgm diff --git a/tests/semantic/fixtures/disasm/cs_global_atomic32_rtn.s b/tests/semantic/fixtures/disasm/cs_global_atomic32_rtn.s new file mode 100644 index 000000000..88c336b86 --- /dev/null +++ b/tests/semantic/fixtures/disasm/cs_global_atomic32_rtn.s @@ -0,0 +1,54 @@ +; cs_global_atomic32_rtn test fixture generated by tests/semantic/regen_fixtures.py from runtime/test/shaders/cs_global_atomic32_rtn.asm + v_cmpx_eq_u32_e32 0, v0 + v_mov_b32_e32 v11, 0 + v_mov_b32_e32 v10, 0xf0f0f0f0 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x40 + v_mov_b32_e32 v10, 0x12345678 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x44 + v_mov_b32_e32 v10, 5 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x48 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x4c + v_mov_b32_e32 v10, 0x11111111 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x50 + v_mov_b32_e32 v10, 0x100 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x54 + v_mov_b32_e32 v10, 0xf0f0 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x58 + v_mov_b32_e32 v10, 0xaaaa + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x5c + s_waitcnt vmcnt(0) + s_waitcnt_vscnt null, 0x0 + s_mov_b32 s20, 0 + s_mov_b32 s21, 0 + v_mov_b32 v1, 0 + v_mov_b32 v2, 0x0f0f0f0f + global_atomic_xor v1, v2, s[20:21] offset:0x40 + v_mov_b32 v2, 0xcafef00d + global_atomic_swap v1, v2, s[20:21] offset:0x44 + v_mov_b32 v2, 10 + global_atomic_inc v1, v2, s[20:21] offset:0x48 + global_atomic_dec v1, v2, s[20:21] offset:0x4c + v_mov_b32 v2, 0x22222222 + global_atomic_add v6, v1, v2, s[20:21] offset:0x50 glc + v_mov_b32 v2, 1 + global_atomic_sub v7, v1, v2, s[20:21] offset:0x54 glc + v_mov_b32 v2, 0x0ff0 + global_atomic_xor v8, v1, v2, s[20:21] offset:0x58 glc + v_mov_b32 v2, 0x5555 + global_atomic_swap v9, v1, v2, s[20:21] offset:0x5c glc + s_waitcnt vmcnt(0) + s_waitcnt_vscnt null, 0x0 + buffer_load_dword v3, v11, s[0:3], 0 offen offset:0x40 + buffer_load_dword v4, v11, s[0:3], 0 offen offset:0x44 + buffer_load_dword v5, v11, s[0:3], 0 offen offset:0x48 + buffer_load_dword v10, v11, s[0:3], 0 offen offset:0x4c + s_waitcnt vmcnt(0) + buffer_store_dword v3, v11, s[0:3], 0 offen + buffer_store_dword v4, v11, s[0:3], 0 offen offset:4 + buffer_store_dword v5, v11, s[0:3], 0 offen offset:8 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:12 + buffer_store_dword v6, v11, s[0:3], 0 offen offset:16 + buffer_store_dword v7, v11, s[0:3], 0 offen offset:20 + buffer_store_dword v8, v11, s[0:3], 0 offen offset:24 + buffer_store_dword v9, v11, s[0:3], 0 offen offset:28 + s_endpgm diff --git a/tests/semantic/fixtures/disasm/cs_global_atomic32_x2.s b/tests/semantic/fixtures/disasm/cs_global_atomic32_x2.s new file mode 100644 index 000000000..c3e8f6104 --- /dev/null +++ b/tests/semantic/fixtures/disasm/cs_global_atomic32_x2.s @@ -0,0 +1,56 @@ +; cs_global_atomic32_x2 test fixture generated by tests/semantic/regen_fixtures.py from runtime/test/shaders/cs_global_atomic32_x2.asm + v_cmpx_eq_u32_e32 0, v0 + v_mov_b32_e32 v11, 0 + v_mov_b32_e32 v10, 0xf0f0f0f0 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x40 + v_mov_b32_e32 v10, 0xffffffff + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x44 + v_mov_b32_e32 v10, 0x0f0f0f0f + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x48 + v_mov_b32_e32 v10, 0 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x4c + v_mov_b32_e32 v10, 0xaaaa5555 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x50 + v_mov_b32_e32 v10, 0x12345678 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x54 + v_mov_b32_e32 v10, 0x11112222 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x58 + v_mov_b32_e32 v10, 0x33334444 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:0x5c + s_waitcnt vmcnt(0) + s_waitcnt_vscnt null, 0x0 + s_mov_b32 s20, 0 + s_mov_b32 s21, 0 + v_mov_b32 v1, 0 + v_mov_b32 v2, 0xff00ff00 + v_mov_b32 v3, 0x0f0f0f0f + global_atomic_and_x2 v1, v[2:3], s[20:21] offset:0x40 + v_mov_b32 v2, 0xff00ff00 + v_mov_b32 v3, 0xffffffff + global_atomic_or_x2 v1, v[2:3], s[20:21] offset:0x48 + v_mov_b32 v2, 0xffff0000 + v_mov_b32 v3, 0xffffffff + global_atomic_xor_x2 v1, v[2:3], s[20:21] offset:0x50 + v_mov_b32 v2, 0xaaaabbbb + v_mov_b32 v3, 0xccccdddd + global_atomic_swap_x2 v1, v[2:3], s[20:21] offset:0x58 + s_waitcnt vmcnt(0) + s_waitcnt_vscnt null, 0x0 + buffer_load_dword v4, v11, s[0:3], 0 offen offset:0x40 + buffer_load_dword v5, v11, s[0:3], 0 offen offset:0x44 + buffer_load_dword v6, v11, s[0:3], 0 offen offset:0x48 + buffer_load_dword v7, v11, s[0:3], 0 offen offset:0x4c + buffer_load_dword v8, v11, s[0:3], 0 offen offset:0x50 + buffer_load_dword v9, v11, s[0:3], 0 offen offset:0x54 + buffer_load_dword v10, v11, s[0:3], 0 offen offset:0x58 + buffer_load_dword v12, v11, s[0:3], 0 offen offset:0x5c + s_waitcnt vmcnt(0) + buffer_store_dword v4, v11, s[0:3], 0 offen + buffer_store_dword v5, v11, s[0:3], 0 offen offset:4 + buffer_store_dword v6, v11, s[0:3], 0 offen offset:8 + buffer_store_dword v7, v11, s[0:3], 0 offen offset:12 + buffer_store_dword v8, v11, s[0:3], 0 offen offset:16 + buffer_store_dword v9, v11, s[0:3], 0 offen offset:20 + buffer_store_dword v10, v11, s[0:3], 0 offen offset:24 + buffer_store_dword v12, v11, s[0:3], 0 offen offset:28 + s_endpgm diff --git a/tests/semantic/fixtures/disasm/cs_w32_clamp16.s b/tests/semantic/fixtures/disasm/cs_w32_clamp16.s new file mode 100644 index 000000000..a9faa8cd7 --- /dev/null +++ b/tests/semantic/fixtures/disasm/cs_w32_clamp16.s @@ -0,0 +1,41 @@ +; cs_w32_clamp16 test fixture generated by tests/semantic/regen_fixtures.py from runtime/test/shaders/cs_w32_clamp16.asm + v_mov_b32_e32 v3, 0xdead0000 + v_mov_b32_e32 v4, 0xdead0000 + v_mov_b32_e32 v5, 0xdead0000 + v_mov_b32_e32 v1, 0xffff + v_mov_b32_e32 v2, 1 + v_add_nc_u16 v3, v1, v2 clamp + v_mov_b32_e32 v1, 1 + v_mov_b32_e32 v2, 2 + v_sub_nc_u16 v4, v1, v2 clamp + v_mov_b32_e32 v1, 0xffff + v_mov_b32_e32 v2, 1 + v_add_nc_u16 v5, v1, v2 + v_mov_b32_e32 v1, 0xffffffff + v_mov_b32_e32 v2, 1 + v_add_co_u32 v6, vcc_lo, v1, v2 clamp + s_mov_b32 vcc_lo, -1 + v_mov_b32_e32 v1, 0xffffffff + v_mov_b32_e32 v2, 0 + v_add_co_ci_u32_e64 v7, vcc_lo, v1, v2, vcc_lo clamp + v_mov_b32_e32 v1, 0 + v_mov_b32_e32 v2, 1 + v_sub_co_u32 v8, vcc_lo, v1, v2 clamp + s_mov_b32 vcc_lo, -1 + v_mov_b32_e32 v1, 0 + v_mov_b32_e32 v2, 0 + v_sub_co_ci_u32_e64 v9, vcc_lo, v1, v2, vcc_lo clamp + v_mov_b32_e32 v1, 1 + v_mov_b32_e32 v2, 0 + v_subrev_co_u32 v10, vcc_lo, v1, v2 clamp + v_cmpx_eq_u32_e32 0, v0 + v_mov_b32_e32 v20, 0 + buffer_store_dword v3, v20, s[0:3], 0 offen + buffer_store_dword v4, v20, s[0:3], 0 offen offset:4 + buffer_store_dword v5, v20, s[0:3], 0 offen offset:8 + buffer_store_dword v6, v20, s[0:3], 0 offen offset:12 + buffer_store_dword v7, v20, s[0:3], 0 offen offset:16 + buffer_store_dword v8, v20, s[0:3], 0 offen offset:20 + buffer_store_dword v9, v20, s[0:3], 0 offen offset:24 + buffer_store_dword v10, v20, s[0:3], 0 offen offset:28 + s_endpgm diff --git a/tests/semantic/fixtures/disasm/cs_w32_clamp32.s b/tests/semantic/fixtures/disasm/cs_w32_clamp32.s new file mode 100644 index 000000000..e1a672652 --- /dev/null +++ b/tests/semantic/fixtures/disasm/cs_w32_clamp32.s @@ -0,0 +1,36 @@ +; cs_w32_clamp32 test fixture generated by tests/semantic/regen_fixtures.py from runtime/test/shaders/cs_w32_clamp32.asm + v_mov_b32_e32 v1, 0xfffffffe + v_mov_b32_e32 v2, 5 + v_add_nc_u32 v3, v1, v2 clamp + v_mov_b32_e32 v1, 5 + v_mov_b32_e32 v2, 10 + v_sub_nc_u32 v4, v1, v2 clamp + v_mov_b32_e32 v1, 10 + v_mov_b32_e32 v2, 5 + v_subrev_nc_u32 v5, v1, v2 clamp + v_mov_b32_e32 v1, 0x7fffffff + v_mov_b32_e32 v2, 1 + v_add_nc_i32 v6, v1, v2 clamp + v_mov_b32_e32 v1, 0x80000000 + v_sub_nc_i32 v7, v1, v2 clamp + v_mov_b32_e32 v1, 0xfffffffe + v_mov_b32_e32 v2, 5 + v_add_nc_u32 v8, v1, v2 + v_mov_b32_e32 v1, 5 + v_mov_b32_e32 v2, 7 + v_add_nc_i32 v9, v1, v2 clamp + s_mov_b32 vcc_lo, -1 + v_mov_b32_e32 v1, 0 + v_mov_b32_e32 v2, 0 + v_subrev_co_ci_u32_e64 v10, vcc_lo, v1, v2, vcc_lo clamp + v_cmpx_eq_u32_e32 0, v0 + v_mov_b32_e32 v20, 0 + buffer_store_dword v3, v20, s[0:3], 0 offen + buffer_store_dword v4, v20, s[0:3], 0 offen offset:4 + buffer_store_dword v5, v20, s[0:3], 0 offen offset:8 + buffer_store_dword v6, v20, s[0:3], 0 offen offset:12 + buffer_store_dword v7, v20, s[0:3], 0 offen offset:16 + buffer_store_dword v8, v20, s[0:3], 0 offen offset:20 + buffer_store_dword v9, v20, s[0:3], 0 offen offset:24 + buffer_store_dword v10, v20, s[0:3], 0 offen offset:28 + s_endpgm diff --git a/tests/semantic/fixtures/disasm/cs_w32_mad_denorm.s b/tests/semantic/fixtures/disasm/cs_w32_mad_denorm.s new file mode 100644 index 000000000..1b3ee11da --- /dev/null +++ b/tests/semantic/fixtures/disasm/cs_w32_mad_denorm.s @@ -0,0 +1,38 @@ +; cs_w32_mad_denorm test fixture generated by tests/semantic/regen_fixtures.py from runtime/test/shaders/cs_w32_mad_denorm.asm + v_mov_b32_e32 v1, 1 + v_mov_b32_e32 v2, 0x4b000000 + v_mov_b32_e32 v4, 0 + v_mad_f32 v3, v1, v2, v4 + v_mov_b32_e32 v1, 0x00800000 + v_mov_b32_e32 v2, 0.5 + v_mad_f32 v5, v1, v2, v4 + v_mov_b32_e32 v1, 1 + v_mov_b32_e32 v2, 0x4b000000 + v_mad_f32 v6, v1, v2, v4 clamp + v_mov_b32_e32 v7, 0 + v_mac_f32 v7, v1, v2 + v_mov_b32_e32 v8, 1.0 + v_mov_b32_e32 v1, 2.0 + v_mov_b32_e32 v2, 3.0 + v_mac_f32 v8, v1, v2 + v_mov_b32_e32 v1, 1 + v_mov_b32_e32 v2, 0x4b000000 + v_mad_legacy_f32 v9, v1, v2, v4 + v_mov_b32_e32 v1, 0x00800000 + v_mov_b32_e32 v2, 0.5 + v_mad_legacy_f32 v10, v1, v2, v4 + v_mov_b32_e32 v1, 1 + v_mov_b32_e32 v2, 0x4b000000 + v_mov_b32_e32 v11, 0 + v_mac_legacy_f32 v11, v1, v2 + v_cmpx_eq_u32_e32 0, v0 + v_mov_b32_e32 v20, 0 + buffer_store_dword v3, v20, s[0:3], 0 offen + buffer_store_dword v5, v20, s[0:3], 0 offen offset:4 + buffer_store_dword v6, v20, s[0:3], 0 offen offset:8 + buffer_store_dword v7, v20, s[0:3], 0 offen offset:12 + buffer_store_dword v8, v20, s[0:3], 0 offen offset:16 + buffer_store_dword v9, v20, s[0:3], 0 offen offset:20 + buffer_store_dword v10, v20, s[0:3], 0 offen offset:24 + buffer_store_dword v11, v20, s[0:3], 0 offen offset:28 + s_endpgm diff --git a/tests/semantic/fixtures/disasm/cs_w32_sdst_exec.s b/tests/semantic/fixtures/disasm/cs_w32_sdst_exec.s new file mode 100644 index 000000000..381ebf057 --- /dev/null +++ b/tests/semantic/fixtures/disasm/cs_w32_sdst_exec.s @@ -0,0 +1,117 @@ +; cs_w32_sdst_exec test fixture generated by tests/semantic/regen_fixtures.py from runtime/test/shaders/cs_w32_sdst_exec.asm + v_mov_b32_e32 v1, 0xffffffff + v_mov_b32_e32 v2, 1 + s_mov_b32 exec_lo, 0xaaaaaaaa + v_add_co_u32 v3, vcc_lo, v1, v2 + s_mov_b32 exec_lo, -1 + v_cndmask_b32_e64 v20, 0, 1, vcc_lo + v_cmp_ne_u32_e32 vcc_lo, 0, v20 + s_bcnt1_i32_b32 s20, vcc_lo + s_ff1_i32_b32 s21, vcc_lo + s_lshl_b32 s21, s21, 8 + s_or_b32 s20, s20, s21 + s_mov_b32 vcc_lo, -1 + v_mov_b32_e32 v2, 0 + s_mov_b32 exec_lo, 0xaaaaaaaa + v_add_co_ci_u32_e32 v3, vcc_lo, v1, v2, vcc_lo + s_mov_b32 exec_lo, -1 + v_cndmask_b32_e64 v20, 0, 1, vcc_lo + v_cmp_ne_u32_e32 vcc_lo, 0, v20 + s_bcnt1_i32_b32 s22, vcc_lo + s_ff1_i32_b32 s23, vcc_lo + s_lshl_b32 s23, s23, 8 + s_or_b32 s22, s22, s23 + v_mov_b32_e32 v4, 0 + v_mov_b32_e32 v5, 1 + s_mov_b32 exec_lo, 0xaaaaaaaa + v_sub_co_u32 v3, s10, v4, v5 + s_mov_b32 exec_lo, -1 + v_cndmask_b32_e64 v20, 0, 1, s10 + v_cmp_ne_u32_e32 vcc_lo, 0, v20 + s_bcnt1_i32_b32 s24, vcc_lo + s_ff1_i32_b32 s25, vcc_lo + s_lshl_b32 s25, s25, 8 + s_or_b32 s24, s24, s25 + s_mov_b32 s12, -1 + v_mov_b32_e32 v6, 0 + s_mov_b32 exec_lo, 0xaaaaaaaa + v_sub_co_ci_u32_e64 v3, s10, v6, v6, s12 + s_mov_b32 exec_lo, -1 + v_cndmask_b32_e64 v20, 0, 1, s10 + v_cmp_ne_u32_e32 vcc_lo, 0, v20 + s_bcnt1_i32_b32 s26, vcc_lo + s_ff1_i32_b32 s27, vcc_lo + s_lshl_b32 s27, s27, 8 + s_or_b32 s26, s26, s27 + v_mov_b32_e32 v7, 1 + v_mov_b32_e32 v8, 0 + s_mov_b32 exec_lo, 0xaaaaaaaa + v_subrev_co_u32 v3, s10, v7, v8 + s_mov_b32 exec_lo, -1 + v_cndmask_b32_e64 v20, 0, 1, s10 + v_cmp_ne_u32_e32 vcc_lo, 0, v20 + s_bcnt1_i32_b32 s28, vcc_lo + s_ff1_i32_b32 s29, vcc_lo + s_lshl_b32 s29, s29, 8 + s_or_b32 s28, s28, s29 + s_mov_b32 exec_lo, 0xaaaaaaaa + v_subrev_co_ci_u32_e64 v3, s10, v6, v6, s12 + s_mov_b32 exec_lo, -1 + v_cndmask_b32_e64 v20, 0, 1, s10 + v_cmp_ne_u32_e32 vcc_lo, 0, v20 + s_bcnt1_i32_b32 s30, vcc_lo + s_ff1_i32_b32 s31, vcc_lo + s_lshl_b32 s31, s31, 8 + s_or_b32 s30, s30, s31 + v_mov_b32_e32 v9, 0xffffffff + v_mov_b32_e32 v10, 1 + v_mov_b32_e32 v12, 0xffffffff + v_mov_b32_e32 v13, 0xffffffff + s_mov_b32 exec_lo, 0xaaaaaaaa + v_mad_u64_u32 v[24:25], s10, v9, v10, v[12:13] + s_mov_b32 exec_lo, -1 + v_cndmask_b32_e64 v20, 0, 1, s10 + v_cmp_ne_u32_e32 vcc_lo, 0, v20 + s_bcnt1_i32_b32 s32, vcc_lo + s_ff1_i32_b32 s33, vcc_lo + s_lshl_b32 s33, s33, 8 + s_or_b32 s32, s32, s33 + v_mov_b32_e32 v14, -1 + v_mov_b32_e32 v15, 1 + v_mov_b32_e32 v16, 0 + v_mov_b32_e32 v17, 0 + s_mov_b32 exec_lo, 0xaaaaaaaa + v_mad_i64_i32 v[24:25], s10, v14, v15, v[16:17] + s_mov_b32 exec_lo, -1 + v_cndmask_b32_e64 v20, 0, 1, s10 + v_cmp_ne_u32_e32 vcc_lo, 0, v20 + s_bcnt1_i32_b32 s34, vcc_lo + s_ff1_i32_b32 s35, vcc_lo + s_lshl_b32 s35, s35, 8 + s_or_b32 s34, s34, s35 + v_cmpx_eq_u32_e32 0, v0 + v_mov_b32_e32 v1, s20 + v_mov_b32_e32 v2, 0 + buffer_store_dword v1, v2, s[0:3], 0 offen + v_mov_b32_e32 v1, s22 + v_mov_b32_e32 v2, 4 + buffer_store_dword v1, v2, s[0:3], 0 offen + v_mov_b32_e32 v1, s24 + v_mov_b32_e32 v2, 8 + buffer_store_dword v1, v2, s[0:3], 0 offen + v_mov_b32_e32 v1, s26 + v_mov_b32_e32 v2, 12 + buffer_store_dword v1, v2, s[0:3], 0 offen + v_mov_b32_e32 v1, s28 + v_mov_b32_e32 v2, 16 + buffer_store_dword v1, v2, s[0:3], 0 offen + v_mov_b32_e32 v1, s30 + v_mov_b32_e32 v2, 20 + buffer_store_dword v1, v2, s[0:3], 0 offen + v_mov_b32_e32 v1, s32 + v_mov_b32_e32 v2, 24 + buffer_store_dword v1, v2, s[0:3], 0 offen + v_mov_b32_e32 v1, s34 + v_mov_b32_e32 v2, 28 + buffer_store_dword v1, v2, s[0:3], 0 offen + s_endpgm diff --git a/tests/semantic/fixtures/disasm/cs_w32_vcmp_f64.s b/tests/semantic/fixtures/disasm/cs_w32_vcmp_f64.s new file mode 100644 index 000000000..6847cbeaf --- /dev/null +++ b/tests/semantic/fixtures/disasm/cs_w32_vcmp_f64.s @@ -0,0 +1,156 @@ +; cs_w32_vcmp_f64 test fixture generated by tests/semantic/regen_fixtures.py from runtime/test/shaders/cs_w32_vcmp_f64.asm + v_mov_b32_e32 v1, 0 + v_mov_b32_e32 v2, 0x80000000 + v_mov_b32_e32 v3, 0 + v_mov_b32_e32 v4, 0 + v_mov_b32_e32 v5, 0 + v_mov_b32_e32 v6, 0x7ff80000 + v_mov_b32_e32 v7, 0 + v_mov_b32_e32 v8, 0x3ff00000 + v_mov_b32_e32 v20, 0 + v_mov_b32_e32 v21, 0 + v_mov_b32_e32 v22, 0 + v_mov_b32_e32 v23, 0 + v_mov_b32_e32 v24, 0 + v_mov_b32_e32 v25, 0 + v_mov_b32_e32 v26, 0 + v_mov_b32_e32 v27, 0 + v_cmp_f_f64 vcc_lo, v[1:2], v[3:4] + v_cndmask_b32_e64 v9, 0, 1, vcc_lo + v_lshl_or_b32 v20, v9, 0, v20 + v_cmp_lt_f64 vcc_lo, v[1:2], v[3:4] + v_cndmask_b32_e64 v9, 0, 1, vcc_lo + v_lshl_or_b32 v20, v9, 1, v20 + v_cmp_eq_f64 vcc_lo, v[1:2], v[3:4] + v_cndmask_b32_e64 v9, 0, 1, vcc_lo + v_lshl_or_b32 v20, v9, 2, v20 + v_cmp_le_f64 vcc_lo, v[1:2], v[3:4] + v_cndmask_b32_e64 v9, 0, 1, vcc_lo + v_lshl_or_b32 v20, v9, 3, v20 + v_cmp_gt_f64 vcc_lo, v[1:2], v[3:4] + v_cndmask_b32_e64 v9, 0, 1, vcc_lo + v_lshl_or_b32 v21, v9, 0, v21 + v_cmp_lg_f64 vcc_lo, v[1:2], v[3:4] + v_cndmask_b32_e64 v9, 0, 1, vcc_lo + v_lshl_or_b32 v21, v9, 1, v21 + v_cmp_ge_f64 vcc_lo, v[1:2], v[3:4] + v_cndmask_b32_e64 v9, 0, 1, vcc_lo + v_lshl_or_b32 v21, v9, 2, v21 + v_cmp_o_f64 vcc_lo, v[1:2], v[3:4] + v_cndmask_b32_e64 v9, 0, 1, vcc_lo + v_lshl_or_b32 v21, v9, 3, v21 + v_cmp_u_f64 vcc_lo, v[1:2], v[3:4] + v_cndmask_b32_e64 v9, 0, 1, vcc_lo + v_lshl_or_b32 v22, v9, 0, v22 + v_cmp_nge_f64 vcc_lo, v[1:2], v[3:4] + v_cndmask_b32_e64 v9, 0, 1, vcc_lo + v_lshl_or_b32 v22, v9, 1, v22 + v_cmp_nlg_f64 vcc_lo, v[1:2], v[3:4] + v_cndmask_b32_e64 v9, 0, 1, vcc_lo + v_lshl_or_b32 v22, v9, 2, v22 + v_cmp_ngt_f64 vcc_lo, v[1:2], v[3:4] + v_cndmask_b32_e64 v9, 0, 1, vcc_lo + v_lshl_or_b32 v22, v9, 3, v22 + v_cmp_nle_f64 vcc_lo, v[1:2], v[3:4] + v_cndmask_b32_e64 v9, 0, 1, vcc_lo + v_lshl_or_b32 v23, v9, 0, v23 + v_cmp_neq_f64 vcc_lo, v[1:2], v[3:4] + v_cndmask_b32_e64 v9, 0, 1, vcc_lo + v_lshl_or_b32 v23, v9, 1, v23 + v_cmp_nlt_f64 vcc_lo, v[1:2], v[3:4] + v_cndmask_b32_e64 v9, 0, 1, vcc_lo + v_lshl_or_b32 v23, v9, 2, v23 + v_cmp_tru_f64 vcc_lo, v[1:2], v[3:4] + v_cndmask_b32_e64 v9, 0, 1, vcc_lo + v_lshl_or_b32 v23, v9, 3, v23 + v_mov_b32_e32 v9, 0 + v_cmpx_f_f64 v[5:6], v[7:8] + v_mov_b32_e32 v9, 1 + s_mov_b32 exec_lo, -1 + v_lshl_or_b32 v24, v9, 0, v24 + v_mov_b32_e32 v9, 0 + v_cmpx_lt_f64 v[5:6], v[7:8] + v_mov_b32_e32 v9, 1 + s_mov_b32 exec_lo, -1 + v_lshl_or_b32 v24, v9, 1, v24 + v_mov_b32_e32 v9, 0 + v_cmpx_eq_f64 v[5:6], v[7:8] + v_mov_b32_e32 v9, 1 + s_mov_b32 exec_lo, -1 + v_lshl_or_b32 v24, v9, 2, v24 + v_mov_b32_e32 v9, 0 + v_cmpx_le_f64 v[5:6], v[7:8] + v_mov_b32_e32 v9, 1 + s_mov_b32 exec_lo, -1 + v_lshl_or_b32 v24, v9, 3, v24 + v_mov_b32_e32 v9, 0 + v_cmpx_gt_f64 v[5:6], v[7:8] + v_mov_b32_e32 v9, 1 + s_mov_b32 exec_lo, -1 + v_lshl_or_b32 v25, v9, 0, v25 + v_mov_b32_e32 v9, 0 + v_cmpx_lg_f64 v[5:6], v[7:8] + v_mov_b32_e32 v9, 1 + s_mov_b32 exec_lo, -1 + v_lshl_or_b32 v25, v9, 1, v25 + v_mov_b32_e32 v9, 0 + v_cmpx_ge_f64 v[5:6], v[7:8] + v_mov_b32_e32 v9, 1 + s_mov_b32 exec_lo, -1 + v_lshl_or_b32 v25, v9, 2, v25 + v_mov_b32_e32 v9, 0 + v_cmpx_o_f64 v[5:6], v[7:8] + v_mov_b32_e32 v9, 1 + s_mov_b32 exec_lo, -1 + v_lshl_or_b32 v25, v9, 3, v25 + v_mov_b32_e32 v9, 0 + v_cmpx_u_f64 v[5:6], v[7:8] + v_mov_b32_e32 v9, 1 + s_mov_b32 exec_lo, -1 + v_lshl_or_b32 v26, v9, 0, v26 + v_mov_b32_e32 v9, 0 + v_cmpx_nge_f64 v[5:6], v[7:8] + v_mov_b32_e32 v9, 1 + s_mov_b32 exec_lo, -1 + v_lshl_or_b32 v26, v9, 1, v26 + v_mov_b32_e32 v9, 0 + v_cmpx_nlg_f64 v[5:6], v[7:8] + v_mov_b32_e32 v9, 1 + s_mov_b32 exec_lo, -1 + v_lshl_or_b32 v26, v9, 2, v26 + v_mov_b32_e32 v9, 0 + v_cmpx_ngt_f64 v[5:6], v[7:8] + v_mov_b32_e32 v9, 1 + s_mov_b32 exec_lo, -1 + v_lshl_or_b32 v26, v9, 3, v26 + v_mov_b32_e32 v9, 0 + v_cmpx_nle_f64 v[5:6], v[7:8] + v_mov_b32_e32 v9, 1 + s_mov_b32 exec_lo, -1 + v_lshl_or_b32 v27, v9, 0, v27 + v_mov_b32_e32 v9, 0 + v_cmpx_neq_f64 v[5:6], v[7:8] + v_mov_b32_e32 v9, 1 + s_mov_b32 exec_lo, -1 + v_lshl_or_b32 v27, v9, 1, v27 + v_mov_b32_e32 v9, 0 + v_cmpx_nlt_f64 v[5:6], v[7:8] + v_mov_b32_e32 v9, 1 + s_mov_b32 exec_lo, -1 + v_lshl_or_b32 v27, v9, 2, v27 + v_mov_b32_e32 v9, 0 + v_cmpx_tru_f64 v[5:6], v[7:8] + v_mov_b32_e32 v9, 1 + s_mov_b32 exec_lo, -1 + v_lshl_or_b32 v27, v9, 3, v27 + v_cmpx_eq_u32_e32 0, v0 + v_mov_b32_e32 v10, 0 + buffer_store_dword v20, v10, s[0:3], 0 offen + buffer_store_dword v21, v10, s[0:3], 0 offen offset:4 + buffer_store_dword v22, v10, s[0:3], 0 offen offset:8 + buffer_store_dword v23, v10, s[0:3], 0 offen offset:12 + buffer_store_dword v24, v10, s[0:3], 0 offen offset:16 + buffer_store_dword v25, v10, s[0:3], 0 offen offset:20 + buffer_store_dword v26, v10, s[0:3], 0 offen offset:24 + buffer_store_dword v27, v10, s[0:3], 0 offen offset:28 + s_endpgm diff --git a/tests/semantic/test_batch4_gpu_fixtures.py b/tests/semantic/test_batch4_gpu_fixtures.py new file mode 100644 index 000000000..c52bc3596 --- /dev/null +++ b/tests/semantic/test_batch4_gpu_fixtures.py @@ -0,0 +1,113 @@ +"""CPU checks for the batch-4 GPU fixtures (docs/design.md rows 218, 226, 265, 379/380, 381). + +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 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 = { + # sdst under EXEC = 0xAAAAAAAA: 16 set lanes | lowest lane 1 << 8 + "cs_w32_sdst_exec": (272, 272, 272, 272, 272, 272, 272, 272), + "cs_global_atomic32_int": (0x80000004, 2, 0xFFFFFFFB, 3, 3, 0xFFFFFFFB, 0xF000F000, 0xFF0FFF0F), + "cs_global_atomic32_rtn": (0xFFFFFFFF, 0xCAFEF00D, 6, 4, 0x11111111, 0x100, 0xF0F0, 0xAAAA), + "cs_global_atomic32_float": (0x3F800000, 0x40000000, 0x40400000, 0, 0x43, 0x42, 0x55, 0x55), + "cs_global_atomic32_x2": (0xF000F000, 0x0F0F0F0F, 0xFF0FFF0F, 0xFFFFFFFF, + 0x55555555, 0xEDCBA987, 0xAAAABBBB, 0xCCCCDDDD), + "cs_w32_clamp32": (0xFFFFFFFF, 0, 0, 0x7FFFFFFF, 0x80000000, 3, 12, 0), + "cs_w32_clamp16": (0xDEADFFFF, 0xDEAD0000, 0xDEAD0000, 0xFFFFFFFF, 0xFFFFFFFF, 0, 0, 0), + "cs_w32_mad_denorm": (0, 0, 0, 0, 0x40E00000, 0, 0, 0), + "cs_w32_vcmp_f64": (0xC, 0xC, 0xC, 0xC, 0, 0, 0xF, 0xF), +} +# The atomic fixtures also seed and rewrite words at 0x40..0x5C through the global pointer; the others write only +# the eight output dwords. +ATOMIC = tuple(n for n in FIXTURES if n.startswith("cs_global_atomic32")) +# 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 decimal words of the fixture's "; Run:" line.""" + m = re.search(r"out\[0\.\.7\] = ((?:[0-9]+ ){7}[0-9]+)", read(name)) + if not m: + raise AssertionError(f"{name}.asm has no '; Run:' words") + return tuple(int(w) for w in m.group(1).split()) + + +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).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 Batch4GpuFixtureTests(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) + if name not in ATOMIC: + # 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) + if name in ATOMIC or name == "cs_w32_sdst_exec": + # 32 EXEC bits wide, and the atomics are not idempotent: one wave must hold the only lane 0 + self.assertIn(name, check.WAVE32_LANE_DUMPS) + else: + self.assertNotIn(name, check.WAVE32_LANE_DUMPS) + + +if __name__ == "__main__": + unittest.main()