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.py71
1 files changed, 66 insertions, 5 deletions
diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py
index f43967fb4..c4e14703d 100644
--- a/scripts/run_gpu_tests.py
+++ b/scripts/run_gpu_tests.py
@@ -38,7 +38,7 @@ from check import TEXOFF_FALLBACK, texoff_env # LEONIDA_TEXOFF_FALLBACK=1: tex
38from check import gpu_test_timeout, timed_out # per-program time limit (LEONIDA_GPU_TEST_TIMEOUT) 38from check import gpu_test_timeout, timed_out # per-program time limit (LEONIDA_GPU_TEST_TIMEOUT)
39from check import MESH_COMPUTE, mesh_env # LEONIDA_MESH_COMPUTE=1: mesh shaders as compute + a generated VS 39from check import MESH_COMPUTE, mesh_env # LEONIDA_MESH_COMPUTE=1: mesh shaders as compute + a generated VS
40from check import (WAVE32_LANE_DUMPS, WAVE32_LANE_ENV, bitmask_perm_narrow_skip, narrow_subgroup_skip, 40from check import (WAVE32_LANE_DUMPS, WAVE32_LANE_ENV, bitmask_perm_narrow_skip, narrow_subgroup_skip,
41 vcmpx_forms_narrow_skip, wave32_lane_skip) # as in check.py 41 unpinned_subgroup_skip, vcmpx_forms_narrow_skip, wave32_lane_skip) # as in check.py
42from check import PIXEL_VERTEX, VINT_ENV, interp_f16_high_problem, ij_computed_problem, mandelbrot_problem # pixel producers and checks 42from check import PIXEL_VERTEX, VINT_ENV, interp_f16_high_problem, ij_computed_problem, mandelbrot_problem # pixel producers and checks
43from check import GET_LOD_TESTS, STORE_WORDS, get_lod_test, store_words_problem # TEST-184: image atomics and queries 43from check import GET_LOD_TESTS, STORE_WORDS, get_lod_test, store_words_problem # TEST-184: image atomics and queries
44from check import wide_pixel_skip # ps_w64x_readlane: judged only where the fragment stage was required 64-wide 44from check import wide_pixel_skip # ps_w64x_readlane: judged only where the fragment stage was required 64-wide
@@ -294,6 +294,11 @@ def w64_emulated() -> bool:
294 # subgroup, matching check.py (W64_EMULATED). Accepts "1"/"true"/"yes"/"on" and tolerates 294 # subgroup, matching check.py (W64_EMULATED). Accepts "1"/"true"/"yes"/"on" and tolerates
295 # the trailing space cmd.exe's `set VAR=1 &` leaves in the value. 295 # the trailing space cmd.exe's `set VAR=1 &` leaves in the value.
296 return (os.environ.get("LEONIDA_W64_EMULATE") or "").strip().lower() in ("1", "true", "yes", "on") 296 return (os.environ.get("LEONIDA_W64_EMULATE") or "").strip().lower() in ("1", "true", "yes", "on")
297def pc_tail_ubo() -> bool:
298 # LEONIDA_PC_TAIL_UBO=1: translate with --pc-tail-ubo (s0..s31 in 128 push-constant bytes, the tail in a uniform
299 # block at set 1), for devices whose maxPushConstantsSize is 128. The test programs read the same variable
300 # (runtime/test/vk_pc_tail.h) and bind the block; same accepted values as LEONIDA_W64_EMULATE.
301 return (os.environ.get("LEONIDA_PC_TAIL_UBO") or "").strip().lower() in ("1", "true", "yes", "on")
297def wavemask_check(vk_compute: str, spv: str, env: dict | None, emulated: bool) -> tuple[bool | None, str]: 302def wavemask_check(vk_compute: str, spv: str, env: dict | None, emulated: bool) -> tuple[bool | None, str]:
298 """cs_wavemask, as in check.py: (passed, detail), passed None for a skip. The native build needs a 64-wide 303 """cs_wavemask, as in check.py: (passed, detail), passed None for a skip. The native build needs a 64-wide
299 subgroup and skips where the device has none; with LEONIDA_W64_EMULATE=1 it was translated with 304 subgroup and skips where the device has none; with LEONIDA_W64_EMULATE=1 it was translated with
@@ -312,6 +317,22 @@ def dump_words(msg: str) -> list[int] | None:
312 return [int(x) for x in m.group(1).split()] if m else None 317 return [int(x) for x in m.group(1).split()] if m else None
313 318
314 319
320def subgroup_pin_skip(msg: str, cs_env: dict | None) -> Skip | None:
321 """A Skip when the runner asked for a subgroup size (VKC_SUBGROUP_SIZE) and vk_compute_test says this device
322 cannot pin it, so the dispatched words are not the ones the fixture was written for. Only for the dumps in
323 WAVE32_PIN_DUMPS: everything else the runner judges at the device's own width, which is how cs_store and the
324 cs_w32_* fixtures keep being tested on a 64-only device (check.py is conservative and skips all of them)."""
325 if cs_env and "VKC_SUBGROUP_SIZE" in cs_env:
326 return unpinned_subgroup_skip(msg)
327 return None
328
329
330# Dumps whose expected words depend on the wave width but are not lane-mask dumps (those are WAVE32_LANE_DUMPS):
331# cs_barrier_loop's trip count is 4 waves of 32, so at 64 lanes it writes a different pattern and the words would
332# report a failure that is really an unpinnable wave size (GCN3/GCN4 expose 64..64 only).
333WAVE32_PIN_DUMPS = ("cs_barrier_loop",)
334
335
315def judge_cs_dump(rc: int, msg: str, want: list[int], *, wave64: bool, partial: bool, emulated: bool, 336def judge_cs_dump(rc: int, msg: str, want: list[int], *, wave64: bool, partial: bool, emulated: bool,
316 hexwords: bool = False) -> tuple[bool | None, str]: 337 hexwords: bool = False) -> tuple[bool | None, str]:
317 """Judge one vk_compute_test "dump" run: (True, words), (False, why), or (None, why) when the device can't run it. 338 """Judge one vk_compute_test "dump" run: (True, words), (False, why), or (None, why) when the device can't run it.
@@ -563,7 +584,8 @@ DRAWN_WITH = {GATHER_LOD_TEST: "vs_ids.asm", "ps_flat": "vs_ids.asm", "ps_textur
563 **{name: "vs_ids.asm" for name in GRADIENT_TESTS}, "vs_clip": "ps_clip_color.asm", 584 **{name: "vs_ids.asm" for name in GRADIENT_TESTS}, "vs_clip": "ps_clip_color.asm",
564 "ps_interp_f16_high": "vs_f16_pack.asm", "ms_f16_pack": "ps_interp_f16_high.asm", 585 "ps_interp_f16_high": "vs_f16_pack.asm", "ms_f16_pack": "ps_interp_f16_high.asm",
565 "ps_interp_f32_mods": "vs_interp_consts.asm", "ps_interp_mov_mods": "vs_interp_consts.asm", 586 "ps_interp_f32_mods": "vs_interp_consts.asm", "ps_interp_mov_mods": "vs_interp_consts.asm",
566 SIGNED_MIP_TEST: "vs_ids.asm"} 587 SIGNED_MIP_TEST: "vs_ids.asm",
588 "vs_base_ids": "ps_flat.asm"}
567DRAWN_WITH.update({name: "vs_ids.asm" for name in GET_LOD_TESTS}) 589DRAWN_WITH.update({name: "vs_ids.asm" for name in GET_LOD_TESTS})
568 590
569 591
@@ -727,6 +749,8 @@ def run_suite(a, work: str) -> int:
727 cmd.append("--texel-offset-fallback") 749 cmd.append("--texel-offset-fallback")
728 if MESH_COMPUTE: # mesh shaders as compute writing to a buffer, drawn by tools/mesh_compute_vs.py 750 if MESH_COMPUTE: # mesh shaders as compute writing to a buffer, drawn by tools/mesh_compute_vs.py
729 cmd.append("--mesh-compute") 751 cmd.append("--mesh-compute")
752 if pc_tail_ubo(): # 128 push-constant bytes; heap base and code base from a uniform block at set 1
753 cmd.append("--pc-tail-ubo")
730 if os.environ.get("LEONIDA_FMA") in ("glsl", "khr"): # fused multiply-add: GLSL Fma or OpFmaKHR (docs/design.md) 754 if os.environ.get("LEONIDA_FMA") in ("glsl", "khr"): # fused multiply-add: GLSL Fma or OpFmaKHR (docs/design.md)
731 cmd += ["--fma", os.environ["LEONIDA_FMA"]] 755 cmd += ["--fma", os.environ["LEONIDA_FMA"]]
732 rc, out = run_cmd(cmd, gpu=False) 756 rc, out = run_cmd(cmd, gpu=False)
@@ -815,7 +839,7 @@ def run_suite(a, work: str) -> int:
815 results.append((name, ok, problem or f"4096 pixels in each of {len(GET_LOD_TESTS[name])} draw(s): the " 839 results.append((name, ok, problem or f"4096 pixels in each of {len(GET_LOD_TESTS[name])} draw(s): the "
816 "clamped and the calculated LOD within 1/16")) 840 "clamped and the calculated LOD within 1/16"))
817 elif name in ("cs_bounds", "cs_smem_bounds", "cs_smem_stride_align", "cs_smem_sload_neg", "cs_buf_tail", "cs_oob_select", "cs_oob_tail", 841 elif name in ("cs_bounds", "cs_smem_bounds", "cs_smem_stride_align", "cs_smem_sload_neg", "cs_buf_tail", "cs_oob_select", "cs_oob_tail",
818 "cs_buf_swizzle", "cs_cmpx_class_f32", "cs_cvt_pk_u8"): 842 "cs_buf_swizzle", "cs_cmpx_class_f32", "cs_cvt_pk_u8", "cs_buf_load_sub", "cs_buf_fmt8"):
819 # num_records bounds check (cs_bounds.asm): the out-of-bounds store is dropped and the out-of-bounds 843 # num_records bounds check (cs_bounds.asm): the out-of-bounds store is dropped and the out-of-bounds
820 # load reads 0, so thread 0's four output words are fixed. One thread, no wave64 requirement. 844 # load reads 0, so thread 0's four output words are fixed. One thread, no wave64 requirement.
821 # cs_cmpx_class_f32 and cs_cvt_pk_u8 are per-lane and need no particular subgroup width either. 845 # cs_cmpx_class_f32 and cs_cvt_pk_u8 are per-lane and need no particular subgroup width either.
@@ -837,6 +861,9 @@ def run_suite(a, work: str) -> int:
837 0xBEEF0001], 861 0xBEEF0001],
838 "cs_cmpx_class_f32": CMPX_CLASS_WORDS, 862 "cs_cmpx_class_f32": CMPX_CLASS_WORDS,
839 "cs_cvt_pk_u8": CVT_PK_U8_WORDS, 863 "cs_cvt_pk_u8": CVT_PK_U8_WORDS,
864 # TEST-510: sub-dword MUBUF loads (RAW end check by element size) and GFX10_FORMAT_8_UINT
865 "cs_buf_load_sub": [0x80, 0xFFFFFF80, 0x1FF, 0xFFFF807F, 0xAB01, 0xCD, 0, 0],
866 "cs_buf_fmt8": [0x7F, 0x80, 0xFF, 0x01, 0, 0, 0xFF, 1],
840 }[name] 867 }[name]
841 words = dump_words(msg) 868 words = dump_words(msg)
842 vals = words[:len(want)] if words else [] 869 vals = words[:len(want)] if words else []
@@ -873,6 +900,14 @@ def run_suite(a, work: str) -> int:
873 vals = words[:len(USER_SGPRS_WORDS)] if words else [] 900 vals = words[:len(USER_SGPRS_WORDS)] if words else []
874 results.append((name, rc == 0 and vals == USER_SGPRS_WORDS, 901 results.append((name, rc == 0 and vals == USER_SGPRS_WORDS,
875 " ".join(hex(x) for x in vals) if vals else msg)) 902 " ".join(hex(x) for x in vals) if vals else msg))
903 elif name == "cs_f64_add":
904 rc, msg = run_cmd([vk_compute, spv, "1", "dump"], env=cs_env)
905 if rc == 77:
906 results.append((name, None, "SKIP (no shaderFloat64 on this device)"))
907 else:
908 ok, detail = judge_cs_dump(rc, msg, [0, 0x40040000], wave64=False, partial=False, emulated=False,
909 hexwords=True)
910 results.append((name, ok, detail))
876 elif name == "cs_cvt_f32_sat": 911 elif name == "cs_cvt_f32_sat":
877 # #300's saturating float -> int conversions: one dispatch per input word in s4 (VKC_SGPRS). 912 # #300's saturating float -> int conversions: one dispatch per input word in s4 (VKC_SGPRS).
878 wrong = [] 913 wrong = []
@@ -1009,6 +1044,10 @@ def run_suite(a, work: str) -> int:
1009 cs_env = dict(os.environ, **WAVE32_LANE_ENV) 1044 cs_env = dict(os.environ, **WAVE32_LANE_ENV)
1010 rc, msg = run_cmd([vk_compute, spv, "1", "dump"] + (["--require-wave64"] if wave64 else []), env=cs_env) 1045 rc, msg = run_cmd([vk_compute, spv, "1", "dump"] + (["--require-wave64"] if wave64 else []), env=cs_env)
1011 skip = wave32_lane_skip(msg) if name in WAVE32_LANE_DUMPS else None 1046 skip = wave32_lane_skip(msg) if name in WAVE32_LANE_DUMPS else None
1047 if skip is None and name in WAVE32_PIN_DUMPS:
1048 # the device may not be able to run the wave size this fixture was written for (a 64-only device
1049 # can't pin 32, so cs_barrier_loop's words mean nothing); check.py skips it too
1050 skip = subgroup_pin_skip(msg, cs_env)
1012 if skip: # e.g. Mesa llvmpipe's 8-wide subgroups: these 32-lane masks can't come out right 1051 if skip: # e.g. Mesa llvmpipe's 8-wide subgroups: these 32-lane masks can't come out right
1013 ok, detail = None, str(skip) 1052 ok, detail = None, str(skip)
1014 else: 1053 else:
@@ -1086,7 +1125,7 @@ def run_suite(a, work: str) -> int:
1086 problem = sampler_test(a.build, spirv_dir) 1125 problem = sampler_test(a.build, spirv_dir)
1087 results.append((name, None if isinstance(problem, Skip) else not problem, 1126 results.append((name, None if isinstance(problem, Skip) else not problem,
1088 problem or f"{len(SAMPLER_CASES)} S#/T# cases, 4096 pixels each exact")) 1127 problem or f"{len(SAMPLER_CASES)} S#/T# cases, 4096 pixels each exact"))
1089 elif name in ("ps_texoff", "ps_texoff_implicit"): 1128 elif name in ("ps_texoff", "ps_texoff_implicit", "ps_texoff_forms"):
1090 # Texel offsets: needs vk_texture_test's texture, sampler and descriptor table (vk_harness binds none), 1129 # Texel offsets: needs vk_texture_test's texture, sampler and descriptor table (vk_harness binds none),
1091 # and VK_KHR_maintenance8 for the non-constant Offset; the tool exits 77 without it. 1130 # and VK_KHR_maintenance8 for the non-constant Offset; the tool exits 77 without it.
1092 raw = os.path.join(raw_dir, f"{name}.raw") 1131 raw = os.path.join(raw_dir, f"{name}.raw")
@@ -1098,7 +1137,7 @@ def run_suite(a, work: str) -> int:
1098 results.append((name, False, msg)) 1137 results.append((name, False, msg))
1099 else: 1138 else:
1100 with open(raw, "rb") as f: 1139 with open(raw, "rb") as f:
1101 problem, covered = texoff_problem(f.read(), msg) 1140 problem, covered = texoff_problem(f.read(), msg, name=name)
1102 results.append((name, not problem, problem or f"4096/4096 pixels exact ({covered})")) 1141 results.append((name, not problem, problem or f"4096/4096 pixels exact ({covered})"))
1103 elif name in OTHER_HARNESS: 1142 elif name in OTHER_HARNESS:
1104 results.append((name, None, f"SKIP (run by {OTHER_HARNESS[name]})")) 1143 results.append((name, None, f"SKIP (run by {OTHER_HARNESS[name]})"))
@@ -1131,6 +1170,7 @@ def run_suite(a, work: str) -> int:
1131 "ps_ops4": (0x34000010, 0x00120800, 0xBEEF0000, 0x12343C00), 1170 "ps_ops4": (0x34000010, 0x00120800, 0xBEEF0000, 0x12343C00),
1132 "ps_scc": (1, 1, 3, 0x80000000), 1171 "ps_scc": (1, 1, 3, 0x80000000),
1133 "ps_sdwa": (0x000000F1, 0xBFFEFFF2, 0x3C003344, 0xBFF70000), 1172 "ps_sdwa": (0x000000F1, 0xBFFEFFF2, 0x3C003344, 0xBFF70000),
1173 "ps_sdwa_dword_hi": (0x00004000, 0x00000003, 0x00004700, 0x0000C000), # 16-bit SDWA, dst_sel:DWORD
1134 "ps_legacy_mul": (0, 0, 0, 0x40C00000), # same expectation as check.py 1174 "ps_legacy_mul": (0, 0, 0, 0x40C00000), # same expectation as check.py
1135 "ps_ops5": (0x12340010, 0xBEEF0800, 0xAAAAFFFF, 0xDEADBC00), # from the .asm headers 1175 "ps_ops5": (0x12340010, 0xBEEF0800, 0xAAAAFFFF, 0xDEADBC00), # from the .asm headers
1136 "ps_ops6": (0xF800FFFF, 0x01000010, 0x00800800, 0x8000FFF0), 1176 "ps_ops6": (0xF800FFFF, 0x01000010, 0x00800800, 0x8000FFF0),
@@ -1163,6 +1203,10 @@ def run_suite(a, work: str) -> int:
1163 "ps_fnan_fract": (0x3F7FFFFF, 0x00003BFF, 0xC0200000, 0xC0200000), 1203 "ps_fnan_fract": (0x3F7FFFFF, 0x00003BFF, 0xC0200000, 0xC0200000),
1164 # TEST-175: docs/design.md rules that were checked on the CPU only (derivations in the .asm headers) 1204 # TEST-175: docs/design.md rules that were checked on the CPU only (derivations in the .asm headers)
1165 "ps_cmp_nlg": (0x40000037, 0x40000007, 0x40000001, 0x3F800000), 1205 "ps_cmp_nlg": (0x40000037, 0x40000007, 0x40000001, 0x3F800000),
1206 "ps_vcmp_f16": (0x48A12080, 0x4CE9B1A2, 0x4BA72C98, 0x4FEFBDBA), # 16-bit float v_cmp e32 (.asm header)
1207 "ps_vcmp_f16_e64": (0x44C11100, 0x4CF171C1, 0x47C71D18, 0x4FF77DD9), # same, e64 with swapped operands
1208 "ps_vcmpx_f16": (0x68A12080, 0x6CE9B1A2, 0x6BA72C98, 0x6FEFBDBA), # 16-bit float v_cmpx e32 (.asm header)
1209 "ps_vcmpx_f16_e64": (0x64C11100, 0x6CF171C1, 0x67C71D18, 0x6FF77DD9), # same, e64 with swapped operands
1166 "ps_cvt_off": (0xBF000000, 0x3EE00000, 0xBE800000, 0x3F800000), 1210 "ps_cvt_off": (0xBF000000, 0x3EE00000, 0xBE800000, 0x3F800000),
1167 "ps_fmac_f16_mods": (0xAAAA3C00, 0xAAAA3E00, 0xAAAA0000, 0xAAAA4000), 1211 "ps_fmac_f16_mods": (0xAAAA3C00, 0xAAAA3E00, 0xAAAA0000, 0xAAAA4000),
1168 "ps_vop3_const_mods": (0xC0000000, 0xBF800000, 0x3F800000, 0xAAAABC00), 1212 "ps_vop3_const_mods": (0xC0000000, 0xBF800000, 0x3F800000, 0xAAAABC00),
@@ -1280,6 +1324,19 @@ def run_suite(a, work: str) -> int:
1280 else: 1324 else:
1281 ok, detail = check_clip_half(raw, 0.5, 1.0) 1325 ok, detail = check_clip_half(raw, 0.5, 1.0)
1282 results.append((name, ok, detail)) 1326 results.append((name, ok, detail))
1327 elif name == "vs_base_ids":
1328 # Zero-based v0 / v3 (the hardware's VS input VGPRs): drawn with firstVertex 16 and firstInstance 7,
1329 # ps_flat must still see vertex 0 of instance 0 (0x101), as check.py checks.
1330 raw = os.path.join(raw_dir, f"{name}.raw")
1331 env = dict(gfx_env or os.environ, VKH_DRAW="16,7")
1332 rc, msg = run_cmd([vk_harness, spv, os.path.join(spirv_dir, "ps_flat.spv"), raw], env=env)
1333 if rc == UNSUPPORTED:
1334 results.append((name, None, unsupported_skip(msg)))
1335 elif rc != 0:
1336 results.append((name, False, msg))
1337 else:
1338 ok, detail = check_flat(raw)
1339 results.append((name, ok, detail))
1283 1340
1284 if a.filter and not results: # the filter matched only inputs/partners: say so rather than "0/0 passed" 1341 if a.filter and not results: # the filter matched only inputs/partners: say so rather than "0/0 passed"
1285 names = [os.path.splitext(f)[0] for f in asm_files] 1342 names = [os.path.splitext(f)[0] for f in asm_files]
@@ -1309,4 +1366,8 @@ def run_suite(a, work: str) -> int:
1309 1366
1310 1367
1311if __name__ == "__main__": 1368if __name__ == "__main__":
1369 try: # a redirected stdout is strict ANSI code page under -I; write '?' for what it cannot encode
1370 sys.stdout.reconfigure(errors="replace")
1371 except (AttributeError, ValueError, OSError):
1372 pass
1312 sys.exit(main()) 1373 sys.exit(main())