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.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py
index 38047321c..edd5cad19 100644
--- a/scripts/run_gpu_tests.py
+++ b/scripts/run_gpu_tests.py
@@ -1,7 +1,9 @@
1"""Assemble, translate, and run the synthetic RDNA2->SPIR-V GPU test suite on Vulkan. 1"""Assemble, translate, and run the synthetic RDNA2->SPIR-V GPU test suite on Vulkan.
2 2
3Usage: 3Usage:
4 python -I scripts/run_gpu_tests.py [--llvm-mc PATH] [--build DIR] [--work DIR] [--filter SUBSTR] 4 python -I scripts/run_gpu_tests.py [--llvm-mc CMD] [--build DIR] [--work DIR] [--filter SUBSTR]
5
6--llvm-mc (or LLVM_MC) is a path or a whole command, e.g. "wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc".
5""" 7"""
6import argparse 8import argparse
7import json 9import json
@@ -16,6 +18,8 @@ import tempfile
16ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 18ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17SHADER_DIR = os.path.join(ROOT, "runtime", "test", "shaders") 19SHADER_DIR = os.path.join(ROOT, "runtime", "test", "shaders")
18TRANSLATOR = os.path.join(ROOT, "tools", "rdna2spirv.py") 20TRANSLATOR = os.path.join(ROOT, "tools", "rdna2spirv.py")
21sys.path.insert(0, os.path.join(ROOT, "tools"))
22import mc_command # noqa: E402
19sys.path.insert(0, SHADER_DIR) 23sys.path.insert(0, SHADER_DIR)
20from compute_fixture import compute_header 24from compute_fixture import compute_header
21 25
@@ -61,7 +65,7 @@ def make_ms_psv0(threads_x: int, maxv: int, maxp: int, topology: int = 2) -> byt
61def assemble_to_s(llvm_mc: str, asm_path: str, s_path: str, name: str) -> None: 65def assemble_to_s(llvm_mc: str, asm_path: str, s_path: str, name: str) -> None:
62 """Assemble raw RDNA2 .asm with llvm-mc -show-encoding into .s format for rdna2spirv.py.""" 66 """Assemble raw RDNA2 .asm with llvm-mc -show-encoding into .s format for rdna2spirv.py."""
63 raw = open(asm_path, encoding="utf-8").read() 67 raw = open(asm_path, encoding="utf-8").read()
64 cmd = [llvm_mc, "-triple=amdgcn--amdpal", "-mcpu=gfx1013"] 68 cmd = mc_command.mc_command(llvm_mc) + ["-triple=amdgcn--amdpal", "-mcpu=gfx1013"]
65 for ln in raw.splitlines(): 69 for ln in raw.splitlines():
66 s = ln.strip() 70 s = ln.strip()
67 if not s: 71 if not s:
@@ -338,7 +342,8 @@ def check_clip_half(raw_path: str, want_b: float, want_a: float) -> tuple[bool,
338 342
339def main() -> int: 343def main() -> int:
340 ap = argparse.ArgumentParser() 344 ap = argparse.ArgumentParser()
341 ap.add_argument("--llvm-mc", default=os.environ.get("LLVM_MC", "llvm-mc")) 345 ap.add_argument("--llvm-mc", default=os.environ.get("LLVM_MC", "llvm-mc"),
346 help="llvm-mc path, or a whole command such as 'wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc'")
342 ap.add_argument("--build", default=os.path.join(ROOT, "runtime", "build")) 347 ap.add_argument("--build", default=os.path.join(ROOT, "runtime", "build"))
343 ap.add_argument("--work", default=None) 348 ap.add_argument("--work", default=None)
344 ap.add_argument("--filter", default="") 349 ap.add_argument("--filter", default="")
@@ -372,9 +377,13 @@ def run_suite(a, work: str) -> int:
372 asm_files = sorted(f for f in os.listdir(SHADER_DIR) if f.endswith(".asm")) 377 asm_files = sorted(f for f in os.listdir(SHADER_DIR) if f.endswith(".asm"))
373 if a.filter: 378 if a.filter:
374 asm_files = [f for f in asm_files if a.filter in f] 379 asm_files = [f for f in asm_files if a.filter in f]
380 # Shaders a selected test draws with are built even when the filter leaves them out (#192): ps_flat uses vs_ids.
381 build_files = list(asm_files)
382 if any(f.startswith("ps_flat") for f in asm_files) and "vs_ids.asm" not in build_files:
383 build_files.append("vs_ids.asm")
375 384
376 # 1. Create synthetic DXBC / FSSM metadata + assemble .asm -> .s 385 # 1. Create synthetic DXBC / FSSM metadata + assemble .asm -> .s
377 for fname in asm_files: 386 for fname in build_files:
378 name = os.path.splitext(fname)[0] 387 name = os.path.splitext(fname)[0]
379 if name == "gs_tri": 388 if name == "gs_tri":
380 dxbc = make_dxbc([ 389 dxbc = make_dxbc([
@@ -461,12 +470,15 @@ def run_suite(a, work: str) -> int:
461 results.append((name, False, "64-wide subgroup was not confirmed (rebuild vk_compute_test)")) 470 results.append((name, False, "64-wide subgroup was not confirmed (rebuild vk_compute_test)"))
462 else: 471 else:
463 results.append((name, rc == 0, msg.splitlines()[-1] if msg else "")) 472 results.append((name, rc == 0, msg.splitlines()[-1] if msg else ""))
464 elif name in ("cs_store", "cs_wave64_ballot", "cs_wm_half_ops", "cs_wm_half_cmp", "cs_wm_bfm64", "cs_wm_scc_rfl", 473 elif name in ("cs_store", "cs_smem_soffset_imm", "cs_wave64_ballot", "cs_wm_half_ops", "cs_wm_half_cmp", "cs_wm_bfm64", "cs_wm_scc_rfl",
465 "cs_w64x_readlane", "cs_w64x_writelane", "cs_w64x_readfirstlane", "cs_w64x_bpermute", 474 "cs_w64x_readlane", "cs_w64x_writelane", "cs_w64x_readfirstlane", "cs_w64x_bpermute",
466 "cs_w64x_branch", "cs_w64x_ballot", "cs_w64x_wg128_branches", "cs_w64x_lds_raw", 475 "cs_w64x_branch", "cs_w64x_ballot", "cs_w64x_wg128_branches", "cs_w64x_lds_raw",
467 "cs_w64x_lds_war", "cs_w64x_partial", "cs_w64x_sbarrier", "cs_w64x_load_ballot_load"): 476 "cs_w64x_lds_war", "cs_w64x_partial", "cs_w64x_sbarrier", "cs_w64x_load_ballot_load"):
468 cs_dump_wants = { 477 cs_dump_wants = {
469 "cs_store": [0x400080FF, 0xE00003FF, 0x3C004000, 0xEEEEEEEE, 0x40003C00, 0xBC003800], 478 "cs_store": [0x400080FF, 0xE00003FF, 0x3C004000, 0xEEEEEEEE, 0x40003C00, 0xBC003800],
479 # base + soffset + imm (cs_smem_soffset_imm.asm); out[4..7] are seeds the shader leaves alone
480 "cs_smem_soffset_imm": [0x5EED0024, 0x5EED0028, 0x5EED002C, 0x5EED0030,
481 0x5EED0010, 0x5EED0014, 0x5EED0018, 0x5EED001C],
470 "cs_wave64_ballot": [32, 16, 24, 40, 8, 48], 482 "cs_wave64_ballot": [32, 16, 24, 40, 8, 48],
471 "cs_wm_half_ops": [32, 16, 16, 0, 16], 483 "cs_wm_half_ops": [32, 16, 16, 0, 16],
472 "cs_wm_half_cmp": [1, 0, 1, 1], 484 "cs_wm_half_cmp": [1, 0, 1, 1],
@@ -487,13 +499,13 @@ def run_suite(a, work: str) -> int:
487 "cs_w64x_load_ballot_load": [43, 74, 75, 42, 42, 18, 41, 32], 499 "cs_w64x_load_ballot_load": [43, 74, 75, 42, 42, 18, 41, 32],
488 } 500 }
489 want = cs_dump_wants[name] 501 want = cs_dump_wants[name]
490 # Every dump but cs_store is a whole-wave (wave64) mask test: ask for a 64-wide subgroup and skip, as 502 # Every dump but cs_store and cs_smem_soffset_imm is a whole-wave (wave64) mask test: ask for a 64-wide subgroup and skip, as
491 # check.py does, where the device has none (vk_compute_test exits 77) instead of reporting a failure. 503 # check.py does, where the device has none (vk_compute_test exits 77) instead of reporting a failure.
492 # With LEONIDA_W64_EMULATE=1 they were translated with --wave64-emulate and run on any subgroup size. 504 # With LEONIDA_W64_EMULATE=1 they were translated with --wave64-emulate and run on any subgroup size.
493 # cs_w64x_partial (a 40-thread group) can't have full subgroups: it asks for size 64 without them. 505 # cs_w64x_partial (a 40-thread group) can't have full subgroups: it asks for size 64 without them.
494 emulated = os.environ.get("LEONIDA_W64_EMULATE") == "1" 506 emulated = os.environ.get("LEONIDA_W64_EMULATE") == "1"
495 partial = name == "cs_w64x_partial" 507 partial = name == "cs_w64x_partial"
496 wave64 = name != "cs_store" and not emulated and not partial 508 wave64 = name not in ("cs_store", "cs_smem_soffset_imm") and not emulated and not partial
497 if partial and not emulated: 509 if partial and not emulated:
498 cs_env = dict(os.environ, VKC_SUBGROUP_SIZE="64") 510 cs_env = dict(os.environ, VKC_SUBGROUP_SIZE="64")
499 rc, msg = run_cmd([vk_compute, spv, "1", "dump"] + (["--require-wave64"] if wave64 else []), env=cs_env) 511 rc, msg = run_cmd([vk_compute, spv, "1", "dump"] + (["--require-wave64"] if wave64 else []), env=cs_env)
@@ -504,7 +516,7 @@ def run_suite(a, work: str) -> int:
504 elif rc == 0 and dump_line: 516 elif rc == 0 and dump_line:
505 vals = [int(x) for x in dump_line.split("=")[1].split()[:len(want)]] 517 vals = [int(x) for x in dump_line.split("=")[1].split()[:len(want)]]
506 ok = vals == want 518 ok = vals == want
507 fmt = hex if name == "cs_store" else str 519 fmt = hex if name in ("cs_store", "cs_smem_soffset_imm") else str
508 results.append((name, ok, " ".join(fmt(x) for x in vals))) 520 results.append((name, ok, " ".join(fmt(x) for x in vals)))
509 else: 521 else:
510 results.append((name, False, msg)) 522 results.append((name, False, msg))