upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/scripts/run_gpu_tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/run_gpu_tests.py')
-rw-r--r--scripts/run_gpu_tests.py46
1 files changed, 39 insertions, 7 deletions
diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py
index a075c876a..8f17a4028 100644
--- a/scripts/run_gpu_tests.py
+++ b/scripts/run_gpu_tests.py
@@ -36,6 +36,7 @@ from check import (CMPX_CLASS_WORDS, CVT_F32_SAT_CASES, CVT_PK_U8_WORDS, PK_MUL_
36from check import SIGNED_MIP_TEST, UINT_MIP_TEST 36from check import SIGNED_MIP_TEST, UINT_MIP_TEST
37from check import cbv_modulate_test 37from check import cbv_modulate_test
38from check import HEAP_INIT_EXPECTED, heap_init_env # cs_heap_init: vk_compute_test's VKC_HEAP_INIT 38from check import HEAP_INIT_EXPECTED, heap_init_env # cs_heap_init: vk_compute_test's VKC_HEAP_INIT
39from check import shift64_test # dynamic 64-bit vector shifts and overlapping destinations
39from check import judged_words, words_match # dump words not judged on some devices (cs_signed_zero_nan) 40from check import judged_words, words_match # dump words not judged on some devices (cs_signed_zero_nan)
40from check import TEXOFF_ARGS, texoff_problem # ps_texoff's expected words and arguments live in check.py 41from check import TEXOFF_ARGS, texoff_problem # ps_texoff's expected words and arguments live in check.py
41from check import TEXOFF_FALLBACK, texoff_env # LEONIDA_TEXOFF_FALLBACK=1: texel offsets without maintenance8 42from check import TEXOFF_FALLBACK, texoff_env # LEONIDA_TEXOFF_FALLBACK=1: texel offsets without maintenance8
@@ -93,10 +94,23 @@ def make_ms_psv0(threads_x: int, maxv: int, maxp: int, topology: int = 2, group_
93 return struct.pack("<I", len(r)) + bytes(r) 94 return struct.pack("<I", len(r)) + bytes(r)
94 95
95 96
97# A comment line a .asm carries when llvm-mc cannot assemble it (cs_dpp_cmp.asm: a VOPC compare in DPP form).
98TEXT_ONLY_MARK = "; run_gpu_tests: text only, llvm-mc has no gfx1013 encoding for an instruction here"
99
100
96def assemble_to_s(llvm_mc: str, asm_path: str, s_path: str, name: str) -> None: 101def assemble_to_s(llvm_mc: str, asm_path: str, s_path: str, name: str) -> None:
97 """Assemble raw RDNA2 .asm with llvm-mc -show-encoding into .s format for rdna2spirv.py.""" 102 """Assemble raw RDNA2 .asm with llvm-mc -show-encoding into .s format for rdna2spirv.py."""
98 with open(asm_path, encoding="utf-8") as source: 103 with open(asm_path, encoding="utf-8") as source:
99 raw = source.read() 104 raw = source.read()
105 if any(ln.strip() == TEXT_ONLY_MARK for ln in raw.splitlines()):
106 # The source holds an instruction llvm-mc has no gfx1013 encoding for. The translator reads straight-line
107 # code from its text alone (tests/semantic/regen_fixtures.py writes such listings), so the lines go through
108 # as they are.
109 lines = [f"; {name} code 0x0..0x0 (synthetic), gfx1013, 0 invalid words"]
110 lines += ["\t" + ln.strip() for ln in raw.splitlines() if ln.strip() and not ln.lstrip().startswith(";")]
111 with open(s_path, "w", encoding="utf-8", newline="\n") as f:
112 f.write("\n".join(lines) + "\n")
113 return
100 cmd = mc_command.mc_command(llvm_mc) + ["-triple=amdgcn--amdpal", "-mcpu=gfx1013"] 114 cmd = mc_command.mc_command(llvm_mc) + ["-triple=amdgcn--amdpal", "-mcpu=gfx1013"]
101 for ln in raw.splitlines(): 115 for ln in raw.splitlines():
102 s = ln.strip() 116 s = ln.strip()
@@ -149,8 +163,13 @@ def spirv_as(asm_text: str, out_spv: str, assembler: str = "spirv-as") -> None:
149 with open(out_spv, "wb") as f: 163 with open(out_spv, "wb") as f:
150 f.write(spv_bytes) 164 f.write(spv_bytes)
151 return 165 return
152 p = subprocess.run(["spirv-as", "--target-env", "vulkan1.2", "-o", out_spv, "-"], 166 try:
153 input=asm_text, capture_output=True, text=True) 167 p = subprocess.run(["spirv-as", "--target-env", "vulkan1.2", "-o", out_spv, "-"],
168 input=asm_text, capture_output=True, text=True)
169 except FileNotFoundError:
170 raise RuntimeError("spirv-as not found on PATH (use --assembler python to assemble with tools/spirv_asm.py)") from None
171 except OSError as exc:
172 raise RuntimeError(f"spirv-as could not be started: {exc.strerror or exc}") from None
154 if p.returncode != 0: 173 if p.returncode != 0:
155 raise RuntimeError(f"spirv-as failed for {out_spv}:\n{p.stderr}") 174 raise RuntimeError(f"spirv-as failed for {out_spv}:\n{p.stderr}")
156 175
@@ -258,6 +277,8 @@ def read_raw_u32(path: str) -> list[tuple[int, int, int, int]]:
258 return [struct.unpack_from("<4I", data, 16 * i) for i in range(n)] 277 return [struct.unpack_from("<4I", data, 16 * i) for i in range(n)]
259 278
260 279
280# cs_div_fmas_f64_rt's operands a = 1 + 2^-30, c = -(1 + 2^-29) as s4..s7 (low word first).
281DIV_FMAS_F64_SGPRS = "0x00400000,0x3ff00000,0x00800000,0xbff00000"
261UNSUPPORTED = 77 # vk_harness: the device lacks a stage the test draws with (geometry or mesh shaders) 282UNSUPPORTED = 77 # vk_harness: the device lacks a stage the test draws with (geometry or mesh shaders)
262 283
263 284
@@ -975,6 +996,10 @@ def run_suite(a, work: str) -> int:
975 if name in CLIP_CASES: 996 if name in CLIP_CASES:
976 detail = clip_test(a.build, spirv_dir, name) 997 detail = clip_test(a.build, spirv_dir, name)
977 results.append((name, None if isinstance(detail, Skip) else not detail, detail or "four pixel masks exact")) 998 results.append((name, None if isinstance(detail, Skip) else not detail, detail or "four pixel masks exact"))
999 elif name == "cs_w32_shift64":
1000 detail = shift64_test(a.build, spirv_dir, cs_env)
1001 results.append((name, None if isinstance(detail, Skip) else not detail,
1002 detail or "640 words exact (64 shift cases and unchanged inputs)"))
978 elif name == "cs_workgroup_yz": 1003 elif name == "cs_workgroup_yz":
979 rc, msg = run_cmd([vk_compute, spv, "2x3x4", "workgroup_yz"], env=cs_env) 1004 rc, msg = run_cmd([vk_compute, spv, "2x3x4", "workgroup_yz"], env=cs_env)
980 results.append((name,) + compute_result(rc, msg, rc == 0 and "2x3x4 workgroup Y/Z: 0 mismatches" 1005 results.append((name,) + compute_result(rc, msg, rc == 0 and "2x3x4 workgroup Y/Z: 0 mismatches"
@@ -1092,10 +1117,12 @@ def run_suite(a, work: str) -> int:
1092 ok, detail = judge_cs_dump(rc, msg, [0, 0x40040000], wave64=False, partial=False, emulated=False, 1117 ok, detail = judge_cs_dump(rc, msg, [0, 0x40040000], wave64=False, partial=False, emulated=False,
1093 hexwords=True) 1118 hexwords=True)
1094 results.append((name, ok, detail)) 1119 results.append((name, ok, detail))
1095 elif name == "cs_div_fmas_f64": 1120 elif name in ("cs_div_fmas_f64", "cs_div_fmas_f64_rt"):
1096 # One-rounding binary64 FMA: strict where the translator emitted OpFmaKHR on doubles (shaderFmaFloat64, 1121 # One-rounding binary64 FMA: strict where the translator emitted OpFmaKHR on doubles (shaderFmaFloat64,
1097 # --fma khr); under the default GLSL Fma the split result (0) is allowed, as cs_fma_fused allows it. 1122 # --fma khr); under the default GLSL Fma the split result (0) is allowed, as cs_fma_fused allows it.
1098 rc, msg = run_cmd([vk_compute, spv, "1", "dump"], env=cs_env) 1123 # The _rt fixture reads the same operands from s4..s7, so the driver cannot fold the Fma at compile time.
1124 env = dict(cs_env or os.environ, VKC_SGPRS=DIV_FMAS_F64_SGPRS) if name.endswith("_rt") else cs_env
1125 rc, msg = run_cmd([vk_compute, spv, "1", "dump"], env=env)
1099 if rc == UNSUPPORTED: # no shaderFloat64, or (--fma khr) no shaderFmaFloat64 1126 if rc == UNSUPPORTED: # no shaderFloat64, or (--fma khr) no shaderFmaFloat64
1100 results.append((name, None, unsupported_skip(msg))) 1127 results.append((name, None, unsupported_skip(msg)))
1101 else: 1128 else:
@@ -1105,7 +1132,8 @@ def run_suite(a, work: str) -> int:
1105 ok = rc == 0 and (words == fused or (not strict and words == split)) 1132 ok = rc == 0 and (words == fused or (not strict and words == split))
1106 detail = " ".join(hex(x) for x in words) if words else msg 1133 detail = " ".join(hex(x) for x in words) if words else msg
1107 if ok and words == split: 1134 if ok and words == split:
1108 detail += " (split: the driver rounds GLSL Fma on doubles twice; --fma khr fixes it)" 1135 detail += (" (split: the driver rounded GLSL Fma on doubles twice%s; --fma khr fixes it)"
1136 % ("" if name.endswith("_rt") else " when folding the constants"))
1109 results.append((name, ok, detail)) 1137 results.append((name, ok, detail))
1110 elif name == "cs_cvt_f32_sat": 1138 elif name == "cs_cvt_f32_sat":
1111 # #300's saturating float -> int conversions: one dispatch per input word in s4 (VKC_SGPRS). 1139 # #300's saturating float -> int conversions: one dispatch per input word in s4 (VKC_SGPRS).
@@ -1152,7 +1180,7 @@ def run_suite(a, work: str) -> int:
1152 results.append((name,) + wavemask_check(vk_compute, spv, cs_env, w64_emulated())) 1180 results.append((name,) + wavemask_check(vk_compute, spv, cs_env, w64_emulated()))
1153 elif name in ("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", 1181 elif name in ("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",
1154 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", "cs_dpp_ops", "cs_dpp_bank", "cs_dpp_fi", 1182 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", "cs_dpp_ops", "cs_dpp_bank", "cs_dpp_fi",
1155 "cs_dpp_bound", "cs_dpp_w64", 1183 "cs_dpp_bound", "cs_dpp_cmp", "cs_dpp_w64",
1156 "cs_w64_mask_detect", 1184 "cs_w64_mask_detect",
1157 "cs_w64x_readlane", "cs_w64x_writelane", "cs_w64x_readfirstlane", "cs_w64x_bpermute", "cs_w64x_permute", 1185 "cs_w64x_readlane", "cs_w64x_writelane", "cs_w64x_readfirstlane", "cs_w64x_bpermute", "cs_w64x_permute",
1158 "cs_w64x_branch", "cs_w64x_ballot", "cs_w64x_wg128_branches", "cs_w64x_lds_raw", 1186 "cs_w64x_branch", "cs_w64x_ballot", "cs_w64x_wg128_branches", "cs_w64x_lds_raw",
@@ -1213,6 +1241,7 @@ def run_suite(a, work: str) -> int:
1213 "cs_dpp_bound": [10, 10, 11, 12, 13, 14, 15, 16], 1241 "cs_dpp_bound": [10, 10, 11, 12, 13, 14, 15, 16],
1214 "cs_dpp_bank": [0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFD, 0xFFFFFFFC, 7, 7, 7, 7], 1242 "cs_dpp_bank": [0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFD, 0xFFFFFFFC, 7, 7, 7, 7],
1215 "cs_dpp_fi": [1, 2, 3, 0x7777, 5, 6, 7, 0x7777], 1243 "cs_dpp_fi": [1, 2, 3, 0x7777, 5, 6, 7, 0x7777],
1244 "cs_dpp_cmp": [3, 2, 3, 2, 1, 0, 1, 0],
1216 "cs_dpp_w64": [1, 0, 3, 2, 5, 4, 7, 6], 1245 "cs_dpp_w64": [1, 0, 3, 2, 5, 4, 7, 6],
1217 # SHADER-99: -0 and NaN survive (SignedZeroInfNanPreserve, cs_signed_zero_nan.asm); 0 in out[4..7] 1246 # SHADER-99: -0 and NaN survive (SignedZeroInfNanPreserve, cs_signed_zero_nan.asm); 0 in out[4..7]
1218 # without it 1247 # without it
@@ -1287,7 +1316,7 @@ def run_suite(a, work: str) -> int:
1287 "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", 1316 "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",
1288 "cs_lds_b64_cmpst", "cs_lds_xchg64_ext", "cs_lds_atomics_ext", "cs_exec_const", "cs_w32_mask_imm", "cs_mask_vgpr_exec", 1317 "cs_lds_b64_cmpst", "cs_lds_xchg64_ext", "cs_lds_atomics_ext", "cs_exec_const", "cs_w32_mask_imm", "cs_mask_vgpr_exec",
1289 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", 1318 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8",
1290 "cs_dpp_ops", "cs_dpp_bound", "cs_dpp_bank", "cs_dpp_fi", "cs_w32_andn2_exec", 1319 "cs_dpp_ops", "cs_dpp_bound", "cs_dpp_bank", "cs_dpp_fi", "cs_dpp_cmp", "cs_w32_andn2_exec",
1291 "cs_w32_exec_computed") and not emulated and not partial 1320 "cs_w32_exec_computed") and not emulated and not partial
1292 if partial and not emulated: 1321 if partial and not emulated:
1293 cs_env = dict(os.environ, VKC_SUBGROUP_SIZE="64") 1322 cs_env = dict(os.environ, VKC_SUBGROUP_SIZE="64")
@@ -1320,6 +1349,9 @@ def run_suite(a, work: str) -> int:
1320 elif name == "cs_imgstore": 1349 elif name == "cs_imgstore":
1321 rc, msg = run_cmd([vk_store, spv]) 1350 rc, msg = run_cmd([vk_store, spv])
1322 results.append((name, *helper_result(rc, msg))) 1351 results.append((name, *helper_result(rc, msg)))
1352 elif name == "cs_imgstore_cube": # GPU-CUBE-STORE: six-layer 2D-array views at bindings 11/12/13
1353 rc, msg = run_cmd([vk_store, spv, "cube"])
1354 results.append((name, *helper_result(rc, msg)))
1323 elif name in ("cs_imgload", "cs_imgload_tfe", "cs_imgload_d16", "cs_imgload_d16_tfe", "cs_sample_lz_int_d16"): 1355 elif name in ("cs_imgload", "cs_imgload_tfe", "cs_imgload_d16", "cs_imgload_d16_tfe", "cs_sample_lz_int_d16"):
1324 rc, msg = run_cmd([vk_store, spv, "load" if name in ("cs_imgload", "cs_imgload_tfe") else "load-d16"]) 1356 rc, msg = run_cmd([vk_store, spv, "load" if name in ("cs_imgload", "cs_imgload_tfe") else "load-d16"])
1325 results.append((name, *helper_result(rc, msg))) 1357 results.append((name, *helper_result(rc, msg)))