omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / tools / uxl / run_all.py
| 1 | #!/usr/bin/env python3 |
| 2 | """One entry point for the UXL checks. Python 3.8+ standard library only. |
| 3 | |
| 4 | python3 tools/uxl/run_all.py |
| 5 | py tools\\uxl\\run_all.py |
| 6 | |
| 7 | Optional: --level1 DIR, --evidence URL (Zenodo API record; default 24237047), |
| 8 | --install-deps (run this distro's one install command; the only path that uses sudo). |
| 9 | SKIP, NOT_RUN, and MISSING are reported and do not count as passes. |
| 10 | Exit 0 only when nothing FAILed. |
| 11 | """ |
| 12 | from __future__ import annotations |
| 13 | |
| 14 | import argparse |
| 15 | import datetime |
| 16 | import hashlib |
| 17 | import json |
| 18 | import os |
| 19 | import platform |
| 20 | import re |
| 21 | import shlex |
| 22 | import shutil |
| 23 | import subprocess |
| 24 | import sys |
| 25 | import tempfile |
| 26 | import urllib.error |
| 27 | import urllib.request |
| 28 | from pathlib import Path |
| 29 | |
| 30 | ROOT = Path(__file__).resolve().parents[2] |
| 31 | ZENODO_API = "https://zenodo.org/api/records/24237047" |
| 32 | ZENODO_DOI = "10.5281/zenodo.24237047" |
| 33 | def _read_pinned_omc_sha256(): |
| 34 | pin = ROOT / "seed/out/omc.sha256" |
| 35 | if pin.is_file(): |
| 36 | toks = pin.read_text(encoding="utf-8").strip().split() |
| 37 | if toks: |
| 38 | return toks[0] |
| 39 | return "210c52566e782cf15ece6e478d45bfb67f1ad338f29e41546dad9b6c4f85b54c" |
| 40 | |
| 41 | |
| 42 | PINNED_OMC_SHA256 = _read_pinned_omc_sha256() |
| 43 | SHA256_RE = re.compile(r"sha256=([0-9a-fA-F]{64})") |
| 44 | MACHINE = None |
| 45 | |
| 46 | |
| 47 | class Tee(object): |
| 48 | def __init__(self, path): |
| 49 | self.file = path.open("w", encoding="utf-8", newline="\n") |
| 50 | self.stdout = sys.stdout |
| 51 | |
| 52 | def write(self, text): |
| 53 | self.stdout.write(text) |
| 54 | self.stdout.flush() |
| 55 | self.file.write(text) |
| 56 | self.file.flush() |
| 57 | |
| 58 | def flush(self): |
| 59 | self.stdout.flush() |
| 60 | self.file.flush() |
| 61 | |
| 62 | |
| 63 | def run(cmd, cwd=None, timeout=120): |
| 64 | try: |
| 65 | return subprocess.run( |
| 66 | cmd, |
| 67 | cwd=None if cwd is None else str(cwd), |
| 68 | stdout=subprocess.PIPE, |
| 69 | stderr=subprocess.PIPE, |
| 70 | timeout=timeout, |
| 71 | ) |
| 72 | except OSError as exc: |
| 73 | proc = subprocess.CompletedProcess(cmd, 127, b"", str(exc).encode()) |
| 74 | return proc |
| 75 | except subprocess.TimeoutExpired as exc: |
| 76 | out = exc.stdout or b"" |
| 77 | err = exc.stderr or b"timeout" |
| 78 | return subprocess.CompletedProcess(cmd, 124, out, err) |
| 79 | |
| 80 | |
| 81 | def text_of(proc): |
| 82 | return proc.stdout.decode("utf-8", "replace") |
| 83 | |
| 84 | |
| 85 | def sha256_file(path): |
| 86 | digest = hashlib.sha256() |
| 87 | with path.open("rb") as handle: |
| 88 | while True: |
| 89 | block = handle.read(1024 * 1024) |
| 90 | if not block: |
| 91 | break |
| 92 | digest.update(block) |
| 93 | return digest.hexdigest() |
| 94 | |
| 95 | |
| 96 | def git_head(): |
| 97 | proc = run(["git", "rev-parse", "HEAD"], ROOT) |
| 98 | if proc.returncode != 0: |
| 99 | return "unknown" |
| 100 | return text_of(proc).strip() |
| 101 | |
| 102 | |
| 103 | def git_autocrlf(): |
| 104 | values = [] |
| 105 | for args in ( |
| 106 | ["git", "config", "--local", "--get", "core.autocrlf"], |
| 107 | ["git", "config", "--global", "--get", "core.autocrlf"], |
| 108 | ): |
| 109 | proc = run(args, ROOT) |
| 110 | got = text_of(proc).strip() |
| 111 | if proc.returncode == 0 and got: |
| 112 | values.append(got) |
| 113 | if not values: |
| 114 | return "unset" |
| 115 | return values[0] |
| 116 | |
| 117 | |
| 118 | def tool_version(cmd): |
| 119 | proc = run(cmd, timeout=30) |
| 120 | if proc.returncode not in (0, 1): |
| 121 | return "not found" |
| 122 | line = text_of(proc).strip().splitlines() |
| 123 | err = proc.stderr.decode("utf-8", "replace").strip().splitlines() |
| 124 | if line: |
| 125 | return line[0] |
| 126 | if err: |
| 127 | return err[0] |
| 128 | return "not found" |
| 129 | |
| 130 | |
| 131 | def binfmt_aarch64(): |
| 132 | path = Path("/proc/sys/fs/binfmt_misc/qemu-aarch64") |
| 133 | if not path.is_file(): |
| 134 | return "not registered" |
| 135 | try: |
| 136 | body = path.read_text(encoding="utf-8", errors="replace") |
| 137 | except OSError as exc: |
| 138 | return "unreadable (%s)" % exc |
| 139 | first = body.splitlines()[0] if body else "present" |
| 140 | return first |
| 141 | |
| 142 | |
| 143 | def qemu_note(): |
| 144 | names = [] |
| 145 | for name in ("qemu-aarch64", "qemu-aarch64-static"): |
| 146 | found = shutil.which(name) |
| 147 | if found: |
| 148 | names.append(found) |
| 149 | binfmt = binfmt_aarch64() |
| 150 | if names: |
| 151 | return "binfmt=%s; qemu=%s" % (binfmt, ", ".join(names)) |
| 152 | return "binfmt=%s; qemu=not on PATH" % binfmt |
| 153 | |
| 154 | |
| 155 | def opencl_probe(): |
| 156 | details = [] |
| 157 | present_gpu = False |
| 158 | present_runtime = False |
| 159 | clinfo = shutil.which("clinfo") |
| 160 | if clinfo: |
| 161 | proc = run([clinfo], timeout=40) |
| 162 | body = text_of(proc) + proc.stderr.decode("utf-8", "replace") |
| 163 | present_runtime = True |
| 164 | details.append("clinfo exit %s" % proc.returncode) |
| 165 | for line in body.splitlines(): |
| 166 | low = line.lower() |
| 167 | if "intel" in low and ("device" in low or "name" in low or "vendor" in low): |
| 168 | present_gpu = True |
| 169 | details.append(line.strip()) |
| 170 | break |
| 171 | if not present_gpu and "intel" in body.lower(): |
| 172 | present_gpu = True |
| 173 | details.append("clinfo output mentions Intel") |
| 174 | else: |
| 175 | details.append("clinfo not on PATH") |
| 176 | icd_dirs = [ |
| 177 | Path("/etc/OpenCL/vendors"), |
| 178 | Path("/usr/lib/x86_64-linux-gnu/OpenCL/vendors"), |
| 179 | ] |
| 180 | icds = [] |
| 181 | for directory in icd_dirs: |
| 182 | if directory.is_dir(): |
| 183 | icds.extend(sorted(directory.glob("*.icd"))) |
| 184 | if icds: |
| 185 | present_runtime = True |
| 186 | details.append("ICD " + ", ".join(path.name for path in icds)) |
| 187 | for path in icds: |
| 188 | try: |
| 189 | blob = path.read_text(encoding="utf-8", errors="replace").lower() |
| 190 | except OSError: |
| 191 | blob = path.name.lower() |
| 192 | if "intel" in blob or "intel" in path.name.lower(): |
| 193 | present_gpu = True |
| 194 | loader = shutil.which("libOpenCL.so") |
| 195 | if loader: |
| 196 | present_runtime = True |
| 197 | details.append(loader) |
| 198 | return present_gpu, present_runtime, "; ".join(details) if details else "no OpenCL probe data" |
| 199 | |
| 200 | |
| 201 | def identity(): |
| 202 | omc = ROOT / "seed/out/omc" |
| 203 | omc_hash = sha256_file(omc) if omc.is_file() else "MISSING" |
| 204 | print("git HEAD %s" % git_head()) |
| 205 | print("omc sha256 %s" % omc_hash) |
| 206 | print("python %s" % sys.version.replace("\n", " ")) |
| 207 | print("git %s" % tool_version(["git", "--version"])) |
| 208 | print("qemu %s" % tool_version(["qemu-aarch64-static", "--version"])) |
| 209 | print("uname %s %s %s" % (platform.system(), platform.release(), platform.machine())) |
| 210 | print("") |
| 211 | |
| 212 | |
| 213 | def stage(title): |
| 214 | print("") |
| 215 | print("=== %s ===" % title, flush=True) |
| 216 | |
| 217 | |
| 218 | def host_stage(): |
| 219 | stage("1. host check") |
| 220 | system = platform.system() |
| 221 | arch = platform.machine() |
| 222 | print("os %s %s" % (system, platform.release())) |
| 223 | print("arch %s" % arch) |
| 224 | print("python %s" % platform.python_version()) |
| 225 | print("git core.autocrlf %s" % git_autocrlf()) |
| 226 | print("qemu-aarch64/binfmt %s" % qemu_note()) |
| 227 | gpu, runtime, detail = opencl_probe() |
| 228 | print("intel gpu %s" % ("present" if gpu else "not present")) |
| 229 | print("opencl runtime %s" % ("present" if runtime else "not present")) |
| 230 | print("opencl detail %s" % detail) |
| 231 | omc = ROOT / "seed/out/omc" |
| 232 | got = sha256_file(omc) if omc.is_file() else "MISSING" |
| 233 | verdict = "MATCH" if got == PINNED_OMC_SHA256 else "MISMATCH" |
| 234 | print("HASH seed/out/omc expected %s computed %s %s" % (PINNED_OMC_SHA256, got, verdict)) |
| 235 | scan = subprocess.run([sys.executable, str(ROOT / "tools/uxl/windows_paths.py")]) |
| 236 | if got != PINNED_OMC_SHA256: |
| 237 | print("host counts: pass=0 fail=1 skip=0") |
| 238 | return "FAIL", "seed/out/omc sha256 %s" % verdict, 0, 1, 0 |
| 239 | if scan.returncode: |
| 240 | print("host counts: pass=0 fail=1 skip=0") |
| 241 | return "FAIL", "windows-paths reported findings", 0, 1, 0 |
| 242 | print("host counts: pass=1 fail=0 skip=0") |
| 243 | return "PASS", "os=%s arch=%s autocrlf=%s" % (system, arch, git_autocrlf()), 1, 0, 0 |
| 244 | |
| 245 | |
| 246 | def level1_dir(arg): |
| 247 | if arg: |
| 248 | return Path(arg).resolve() |
| 249 | return ROOT / "tools/uxl/level1" |
| 250 | |
| 251 | |
| 252 | def level1_stage(directory): |
| 253 | stage("2. Level 1 hash checks") |
| 254 | print("source %s" % directory) |
| 255 | manifest = directory / "SHA256.json" |
| 256 | verify = directory / "verify.py" |
| 257 | if not manifest.is_file() or not verify.is_file(): |
| 258 | print("SKIP Level 1: %s has no SHA256.json and verify.py" % directory) |
| 259 | print("level1 counts: pass=0 fail=0 skip=1") |
| 260 | return "SKIP", "Level 1 file set not found at %s" % directory, 0, 0, 1 |
| 261 | hashes = json.loads(manifest.read_text(encoding="utf-8")) |
| 262 | on_disk = set() |
| 263 | for path in directory.rglob("*"): |
| 264 | if path.is_file() and path.name != "SHA256.json": |
| 265 | on_disk.add(path.relative_to(directory).as_posix()) |
| 266 | passed = 0 |
| 267 | failed = 0 |
| 268 | missing = sorted(set(hashes) - on_disk) |
| 269 | extra = sorted(on_disk - set(hashes)) |
| 270 | for name in sorted(hashes): |
| 271 | expected = hashes[name] |
| 272 | path = directory.joinpath(*name.split("/")) |
| 273 | if not path.is_file(): |
| 274 | print("HASH %s expected %s computed MISSING MISMATCH" % (name, expected)) |
| 275 | failed += 1 |
| 276 | continue |
| 277 | computed = sha256_file(path) |
| 278 | verdict = "MATCH" if computed == expected else "MISMATCH" |
| 279 | print("HASH %s expected %s computed %s %s" % (name, expected, computed, verdict)) |
| 280 | if verdict == "MATCH": |
| 281 | passed += 1 |
| 282 | else: |
| 283 | failed += 1 |
| 284 | for name in extra: |
| 285 | print("HASH %s expected ABSENT computed %s MISMATCH" % (name, sha256_file(directory.joinpath(*name.split("/"))))) |
| 286 | failed += 1 |
| 287 | if missing: |
| 288 | print("level1 paths missing from disk: %s" % ", ".join(missing)) |
| 289 | proc = subprocess.run( |
| 290 | [sys.executable, "-I", str(verify)], |
| 291 | cwd=str(directory), |
| 292 | stdout=subprocess.PIPE, |
| 293 | stderr=subprocess.STDOUT, |
| 294 | ) |
| 295 | body = text_of(proc).rstrip("\n") |
| 296 | if body: |
| 297 | print(body) |
| 298 | if proc.returncode != 0: |
| 299 | failed += 1 |
| 300 | print("FAIL verify.py exit %s" % proc.returncode) |
| 301 | print("level1 counts: pass=%d fail=%d skip=0" % (passed, failed)) |
| 302 | if failed: |
| 303 | return "FAIL", "%d hash or verify failures" % failed, passed, failed, 0 |
| 304 | return "PASS", "%d hashed files; verify.py exit 0" % passed, passed, 0, 0 |
| 305 | |
| 306 | |
| 307 | def level2_stage(): |
| 308 | stage("3. Level 2 rebuild") |
| 309 | if MACHINE is not None and MACHINE.omc == "not-run": |
| 310 | hint = omc_hint(MACHINE) |
| 311 | print("NOT_RUN Level 2: %s" % hint) |
| 312 | print("level2 counts: pass=0 fail=0 not_run=1") |
| 313 | if MACHINE.arch == "arm64": |
| 314 | arm = ("NOT_RUN", hint, 0, 0, 0) |
| 315 | else: |
| 316 | print("SKIP trace.c is arm64-only and was not run") |
| 317 | arm = ("SKIP", "1 arm64-only test(s) not run", 0, 0, 1) |
| 318 | return ("NOT_RUN", hint, 0, 0, 0), arm |
| 319 | print("driver tests/amd-kfd-launch/check.py") |
| 320 | print("hashes gpu/amd/card.tsv, cross-checked against Zenodo %s for launch-x86 and vadd" % ZENODO_DOI) |
| 321 | proc = subprocess.Popen( |
| 322 | [sys.executable, str(ROOT / "tests/amd-kfd-launch/check.py")], |
| 323 | cwd=str(ROOT), |
| 324 | stdout=subprocess.PIPE, |
| 325 | stderr=subprocess.STDOUT, |
| 326 | ) |
| 327 | assert proc.stdout is not None |
| 328 | lines = [] |
| 329 | for raw in proc.stdout: |
| 330 | line = raw.decode("utf-8", "replace").rstrip("\n") |
| 331 | print(line, flush=True) |
| 332 | lines.append(line) |
| 333 | code = proc.wait() |
| 334 | counts = "" |
| 335 | skips = [] |
| 336 | for line in lines: |
| 337 | if line.startswith("LEVEL2_COUNTS "): |
| 338 | counts = line |
| 339 | if line.startswith("SKIP "): |
| 340 | skips.append(line) |
| 341 | stage("4. arm64-only tests") |
| 342 | arm_skips = [line for line in skips if "trace.c" in line] |
| 343 | if arm_skips: |
| 344 | for line in arm_skips: |
| 345 | print(line) |
| 346 | print("arm64 counts: pass=0 fail=0 skip=%d" % len(arm_skips)) |
| 347 | arm = ("SKIP", "%d arm64-only test(s) not run" % len(arm_skips), 0, 0, len(arm_skips)) |
| 348 | elif code == 0: |
| 349 | print("arm64 counts: pass=0 fail=0 skip=0") |
| 350 | arm = ("PASS", "no arm64-only skip on this host", 0, 0, 0) |
| 351 | else: |
| 352 | print("arm64 counts: pass=0 fail=0 skip=0") |
| 353 | arm = ("SKIP", "Level 2 did not reach the arch check", 0, 0, 1) |
| 354 | if code == 77: |
| 355 | reason = "omc cannot execute on this host" |
| 356 | for line in skips: |
| 357 | if line.startswith("SKIP Level 2"): |
| 358 | reason = line[len("SKIP "):] |
| 359 | print("level2 counts: pass=0 fail=0 skip=1") |
| 360 | return ("SKIP", reason, 0, 0, 1), arm |
| 361 | if code != 0: |
| 362 | print("level2 counts: pass=0 fail=1 skip=0") |
| 363 | return ("FAIL", "check.py exit %s %s" % (code, counts), 0, 1, 0), arm |
| 364 | print("level2 counts: pass=1 fail=0 skip=0") |
| 365 | return ("PASS", counts or "check.py exit 0", 1, 0, 0), arm |
| 366 | |
| 367 | |
| 368 | def omc_can_run(omc): |
| 369 | if not omc.is_file(): |
| 370 | return False, "seed/out/omc is not in this checkout" |
| 371 | try: |
| 372 | proc = subprocess.run( |
| 373 | [str(omc)], |
| 374 | input=b"fn main to int\nret 7\nend\n", |
| 375 | stdout=subprocess.PIPE, |
| 376 | stderr=subprocess.PIPE, |
| 377 | timeout=180, |
| 378 | ) |
| 379 | except OSError as exc: |
| 380 | return False, "cannot execute seed/out/omc (%s)" % exc |
| 381 | except subprocess.TimeoutExpired: |
| 382 | return False, "seed/out/omc timed out" |
| 383 | err = proc.stderr.decode("utf-8", "replace").strip().splitlines() |
| 384 | if proc.returncode != 0 or not proc.stdout.startswith(b"\x7fELF"): |
| 385 | detail = err[0] if err else "no ELF output" |
| 386 | return False, "seed/out/omc did not run (%s)" % detail |
| 387 | return True, "seed/out/omc executed" |
| 388 | |
| 389 | |
| 390 | def qemu_install_line(): |
| 391 | if MACHINE is not None and MACHINE.omc == "not-run": |
| 392 | return omc_hint(MACHINE) |
| 393 | return ( |
| 394 | "omc is the pinned AArch64 binary sha256 %s. On x86 Linux install " |
| 395 | "qemu-user-static and binfmt-support, mount binfmt_misc, and register " |
| 396 | "/usr/lib/binfmt.d/qemu-aarch64.conf so the kernel runs qemu-aarch64. " |
| 397 | "On Windows, use WSL with that binfmt setup." |
| 398 | % PINNED_OMC_SHA256 |
| 399 | ) |
| 400 | |
| 401 | |
| 402 | class Machine(object): |
| 403 | def __init__(self): |
| 404 | self.os = "linux" |
| 405 | self.wsl = "" |
| 406 | self.arch = "x86_64" |
| 407 | self.distro = "linux" |
| 408 | self.omc = "not-run" |
| 409 | self.spirv_val = "no" |
| 410 | self.omega_spirv = "no" |
| 411 | self.opencl_intel = "no" |
| 412 | self.levelzero = "no" |
| 413 | self.install = "" |
| 414 | |
| 415 | |
| 416 | def norm_arch(name): |
| 417 | low = (name or "").lower() |
| 418 | if low in ("x86_64", "amd64", "x64"): |
| 419 | return "x86_64" |
| 420 | if low in ("aarch64", "arm64", "armv8l"): |
| 421 | return "arm64" |
| 422 | return low or "unknown" |
| 423 | |
| 424 | |
| 425 | def read_os_release(): |
| 426 | data = {} |
| 427 | path = Path("/etc/os-release") |
| 428 | if not path.is_file(): |
| 429 | return data |
| 430 | try: |
| 431 | lines = path.read_text(encoding="utf-8", errors="replace").splitlines() |
| 432 | except OSError: |
| 433 | return data |
| 434 | for line in lines: |
| 435 | if "=" not in line: |
| 436 | continue |
| 437 | key, value = line.split("=", 1) |
| 438 | data[key] = value.strip().strip('"') |
| 439 | return data |
| 440 | |
| 441 | |
| 442 | def wsl_name(): |
| 443 | name = os.environ.get("WSL_DISTRO_NAME") or "" |
| 444 | if name: |
| 445 | return name |
| 446 | try: |
| 447 | version = Path("/proc/version").read_text(encoding="utf-8", errors="replace").lower() |
| 448 | except OSError: |
| 449 | return "" |
| 450 | if "microsoft" in version or "wsl" in version: |
| 451 | return "yes" |
| 452 | return "" |
| 453 | |
| 454 | |
| 455 | def spirv_val_present(): |
| 456 | name = os.environ.get("SPIRV_VAL", "spirv-val") |
| 457 | if shutil.which(name) or Path(name).is_file(): |
| 458 | return "yes" |
| 459 | return "no" |
| 460 | |
| 461 | |
| 462 | def levelzero_backend(): |
| 463 | names = ( |
| 464 | "/usr/lib/x86_64-linux-gnu/libze_loader.so.1", |
| 465 | "/usr/lib/aarch64-linux-gnu/libze_loader.so.1", |
| 466 | "/usr/lib/libze_loader.so.1", |
| 467 | ) |
| 468 | for name in names: |
| 469 | if Path(name).is_file(): |
| 470 | return "yes" |
| 471 | if shutil.which("ze_info"): |
| 472 | return "yes" |
| 473 | return "no" |
| 474 | |
| 475 | |
| 476 | def binfmt_register_command(): |
| 477 | # One sh -c. The kernel decodes the \x escapes. No-op when qemu-aarch64 is already enabled. |
| 478 | body = ( |
| 479 | "grep -q ^enabled /proc/sys/fs/binfmt_misc/qemu-aarch64 2>/dev/null || " |
| 480 | "{ mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc 2>/dev/null || true; " |
| 481 | "interp=/usr/libexec/qemu-binfmt/aarch64-binfmt-P; " |
| 482 | '[ -x "$interp" ] || interp=/usr/bin/qemu-aarch64-static; ' |
| 483 | 'printf "%s%s\\n" ":qemu-aarch64:M::\\x7fELF\\x02\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\xb7\\x00:' |
| 484 | '\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xfe\\xff\\xff\\xff:" ' |
| 485 | '"$interp:OPF" > /proc/sys/fs/binfmt_misc/register; }' |
| 486 | ) |
| 487 | return "sh -c '%s'" % body |
| 488 | |
| 489 | |
| 490 | def install_command(machine): |
| 491 | if machine.os == "windows": |
| 492 | return "wsl --install -d Ubuntu" |
| 493 | if machine.os == "macos": |
| 494 | return "brew install spirv-tools" |
| 495 | release = read_os_release() |
| 496 | ident = (release.get("ID") or "").lower() |
| 497 | like = (release.get("ID_LIKE") or "").lower() |
| 498 | family = ident + " " + like |
| 499 | if "debian" in family or "ubuntu" in family or ident in ("debian", "ubuntu"): |
| 500 | packages = ["python3"] |
| 501 | if machine.arch == "x86_64": |
| 502 | packages[1:1] = ["qemu-user-static", "binfmt-support"] |
| 503 | command = ( |
| 504 | "sudo sh -c '" |
| 505 | "if [ -f /etc/apt/sources.list.d/ubuntu.sources ]; then " |
| 506 | "sed -i \"s/^Components: .*/Components: main universe/\" /etc/apt/sources.list.d/ubuntu.sources; " |
| 507 | "fi; " |
| 508 | "if [ -f /etc/apt/sources.list ]; then " |
| 509 | "sed -i \"s/ main$/ main universe/\" /etc/apt/sources.list; " |
| 510 | "fi' && " |
| 511 | "sudo DEBIAN_FRONTEND=noninteractive apt-get update && " |
| 512 | "sudo DEBIAN_FRONTEND=noninteractive apt-get install -y " + " ".join(packages) |
| 513 | ) |
| 514 | if machine.arch == "x86_64": |
| 515 | command += " && sudo " + binfmt_register_command() |
| 516 | return command |
| 517 | if "fedora" in family or "rhel" in family or ident in ("fedora", "rhel", "centos"): |
| 518 | packages = "python3" |
| 519 | if machine.arch == "x86_64": |
| 520 | packages = "qemu-user-static " + packages |
| 521 | return "sudo dnf install -y " + packages |
| 522 | if ident == "arch" or "arch" in like.split(): |
| 523 | packages = "python" |
| 524 | if machine.arch == "x86_64": |
| 525 | packages = "qemu-user-static " + packages |
| 526 | return "sudo pacman -Sy --needed --noconfirm " + packages |
| 527 | return "" |
| 528 | |
| 529 | |
| 530 | def toolchain_gap(machine): |
| 531 | if machine.os == "windows": |
| 532 | return not machine.wsl |
| 533 | if machine.os == "macos": |
| 534 | return False |
| 535 | if machine.omc == "not-run": |
| 536 | return True |
| 537 | return False |
| 538 | |
| 539 | |
| 540 | def omc_hint(machine): |
| 541 | if machine.os == "macos": |
| 542 | return ( |
| 543 | "omc is an AArch64 Linux binary and cannot exec on macOS. " |
| 544 | "Use a Linux VM. NOT_RUN is not a failure." |
| 545 | ) |
| 546 | if machine.os == "windows": |
| 547 | return ( |
| 548 | "omc is an AArch64 Linux binary and cannot exec on native Windows. " |
| 549 | "Install WSL2 Ubuntu and rerun .\\uxl-run.ps1, which hands off to ./uxl-run.sh. " |
| 550 | "wsl --install -d Ubuntu" |
| 551 | ) |
| 552 | if machine.install: |
| 553 | return machine.install |
| 554 | return ( |
| 555 | "omc is the pinned AArch64 binary sha256 %s and did not execute." |
| 556 | % PINNED_OMC_SHA256 |
| 557 | ) |
| 558 | |
| 559 | |
| 560 | def detect(): |
| 561 | machine = Machine() |
| 562 | system = platform.system().lower() |
| 563 | if system == "darwin": |
| 564 | machine.os = "macos" |
| 565 | machine.distro = "macos" |
| 566 | elif system == "windows": |
| 567 | machine.os = "windows" |
| 568 | machine.distro = "windows" |
| 569 | else: |
| 570 | machine.os = "linux" |
| 571 | release = read_os_release() |
| 572 | ident = release.get("ID") or "linux" |
| 573 | version = release.get("VERSION_ID") or "" |
| 574 | machine.distro = (ident + " " + version).strip() |
| 575 | machine.wsl = wsl_name() |
| 576 | machine.arch = norm_arch(platform.machine()) |
| 577 | machine.spirv_val = spirv_val_present() |
| 578 | gpu, _runtime, _detail = opencl_probe() |
| 579 | machine.opencl_intel = "yes" if gpu else "no" |
| 580 | machine.levelzero = levelzero_backend() |
| 581 | if machine.os in ("macos", "windows"): |
| 582 | machine.omc = "not-run" |
| 583 | else: |
| 584 | ok, _detail = omc_can_run(ROOT / "seed/out/omc") |
| 585 | if ok and machine.arch == "arm64": |
| 586 | machine.omc = "native" |
| 587 | elif ok: |
| 588 | machine.omc = "qemu" |
| 589 | else: |
| 590 | machine.omc = "not-run" |
| 591 | machine.omega_spirv = "yes" if machine.omc != "not-run" else "no" |
| 592 | if toolchain_gap(machine): |
| 593 | machine.install = install_command(machine) |
| 594 | return machine |
| 595 | |
| 596 | |
| 597 | def print_detected(machine): |
| 598 | print("detected") |
| 599 | print(" os %s" % machine.os) |
| 600 | print(" wsl %s" % (machine.wsl or "no")) |
| 601 | print(" arch %s" % machine.arch) |
| 602 | print(" distro %s" % machine.distro) |
| 603 | print(" omc %s" % machine.omc) |
| 604 | print(" spirv-val %s" % machine.spirv_val) |
| 605 | print(" omega-spirv %s" % machine.omega_spirv) |
| 606 | print(" opencl-intel %s" % machine.opencl_intel) |
| 607 | print(" levelzero %s" % machine.levelzero) |
| 608 | hint = omc_hint(machine) if machine.omc == "not-run" else "" |
| 609 | if hint and hint != machine.install: |
| 610 | print("hint %s" % hint) |
| 611 | if machine.install: |
| 612 | print("install %s" % machine.install) |
| 613 | elif hint: |
| 614 | print("hint %s" % hint) |
| 615 | |
| 616 | |
| 617 | def execute_install(command): |
| 618 | if hasattr(os, "geteuid") and os.geteuid() == 0: |
| 619 | command = command.replace("sudo ", "") |
| 620 | print(command, flush=True) |
| 621 | proc = subprocess.run(["sh", "-c", command]) |
| 622 | return proc.returncode == 0 |
| 623 | |
| 624 | |
| 625 | def spirv_val_install_line(): |
| 626 | return ( |
| 627 | "spirv-val is not on PATH. Install SPIRV-Tools " |
| 628 | "(Debian/Ubuntu: sudo apt-get install spirv-tools), which provides spirv-val." |
| 629 | ) |
| 630 | |
| 631 | |
| 632 | def child_env(): |
| 633 | env = dict(os.environ) |
| 634 | env["OMC"] = "seed/out/omc" |
| 635 | env["PYTHONDONTWRITEBYTECODE"] = "1" |
| 636 | return env |
| 637 | |
| 638 | |
| 639 | def stream(cmd, cwd): |
| 640 | try: |
| 641 | proc = subprocess.Popen( |
| 642 | cmd, |
| 643 | cwd=str(cwd), |
| 644 | env=child_env(), |
| 645 | stdout=subprocess.PIPE, |
| 646 | stderr=subprocess.STDOUT, |
| 647 | ) |
| 648 | except OSError as exc: |
| 649 | print("MISMATCH %s (%s)" % (" ".join(cmd), exc), flush=True) |
| 650 | return 127, ["%s" % exc] |
| 651 | assert proc.stdout is not None |
| 652 | lines = [] |
| 653 | for raw in proc.stdout: |
| 654 | line = raw.decode("utf-8", "replace").rstrip("\n") |
| 655 | print(line, flush=True) |
| 656 | if line.startswith("PASS "): |
| 657 | print("MATCH %s" % line[5:], flush=True) |
| 658 | elif line.startswith("FAIL "): |
| 659 | print("MISMATCH %s" % line[5:], flush=True) |
| 660 | elif line.startswith("CONFORM ") and "wrong=0" in line: |
| 661 | print("MATCH %s" % line, flush=True) |
| 662 | elif line.startswith("CONFORM "): |
| 663 | print("MISMATCH %s" % line, flush=True) |
| 664 | lines.append(line) |
| 665 | return proc.wait(), lines |
| 666 | |
| 667 | |
| 668 | def sha_from_lines(lines): |
| 669 | found = None |
| 670 | for line in lines: |
| 671 | for match in SHA256_RE.finditer(line): |
| 672 | found = match.group(1).lower() |
| 673 | return found |
| 674 | |
| 675 | |
| 676 | def parse_plan(path): |
| 677 | rows = [] |
| 678 | lines = path.read_text(encoding="utf-8").splitlines() |
| 679 | if not lines: |
| 680 | return rows, "empty" |
| 681 | header = lines[0].split("\t") |
| 682 | required = ("id", "command", "expect_sha256") |
| 683 | for name in required: |
| 684 | if name not in header: |
| 685 | return [], "header missing %s" % name |
| 686 | for raw in lines[1:]: |
| 687 | if not raw.strip() or raw.startswith("#"): |
| 688 | continue |
| 689 | cols = raw.split("\t") |
| 690 | if len(cols) < len(header): |
| 691 | cols = cols + [""] * (len(header) - len(cols)) |
| 692 | rows.append({header[i]: cols[i] for i in range(len(header))}) |
| 693 | return rows, None |
| 694 | |
| 695 | |
| 696 | def omc_did_not_start(lines): |
| 697 | text = "\n".join(lines) |
| 698 | if "NOT_RUN rmsnorm: cannot execute" in text: |
| 699 | return True |
| 700 | if "seed/out/omc" in text or "Exec format error" in text: |
| 701 | if ( |
| 702 | "Exec format error" in text |
| 703 | or "Errno 8" in text |
| 704 | or "WinError 193" in text |
| 705 | or "not a valid Win32 application" in text |
| 706 | or "cannot execute" in text |
| 707 | ): |
| 708 | return True |
| 709 | return False |
| 710 | |
| 711 | |
| 712 | def row_argv(command): |
| 713 | argv = shlex.split(command) |
| 714 | if argv and argv[0] in ("python3", "python", "py"): |
| 715 | argv[0] = sys.executable |
| 716 | return argv |
| 717 | |
| 718 | |
| 719 | def run_plan(path): |
| 720 | rows, err = parse_plan(path) |
| 721 | passed = 0 |
| 722 | failed = 0 |
| 723 | not_run = 0 |
| 724 | if err: |
| 725 | print("MISMATCH %s %s" % (path.name, err)) |
| 726 | return passed, failed + 1, not_run |
| 727 | for row in rows: |
| 728 | name = row.get("id") or path.name |
| 729 | prereq = row.get("prerequisite") or "" |
| 730 | expected = (row.get("expect_sha256") or "").lower() |
| 731 | phrase = row.get("pass") or "" |
| 732 | stdout_need = phrase.split("stdout ", 1)[1] if "stdout " in phrase else "" |
| 733 | print("ROW %s prerequisite %s" % (name, prereq or "none"), flush=True) |
| 734 | print("reference sha256 %s" % (expected or "none"), flush=True) |
| 735 | argv = row_argv(row.get("command") or "") |
| 736 | print("RUN %s" % " ".join(argv), flush=True) |
| 737 | if not argv: |
| 738 | print("HASH %s expected %s computed MALFORMED MISMATCH" % (name, expected or "exit 0")) |
| 739 | failed += 1 |
| 740 | continue |
| 741 | code, lines = stream(argv, ROOT) |
| 742 | digest = sha_from_lines(lines) |
| 743 | computed = digest if digest else "NONE" |
| 744 | if code == 2 or omc_did_not_start(lines): |
| 745 | why = "prerequisite %s missing" % (prereq or "runtime") |
| 746 | if omc_did_not_start(lines): |
| 747 | why = "omc cannot run" |
| 748 | if not any(qemu_install_line() in line for line in lines): |
| 749 | print(qemu_install_line()) |
| 750 | print( |
| 751 | "HASH %s expected %s computed NOT_RUN NOT_RUN" % (name, expected or "sha256"), |
| 752 | flush=True, |
| 753 | ) |
| 754 | print("NOT_RUN %s exit %s (%s; not a pass)" % (name, code, why)) |
| 755 | not_run += 1 |
| 756 | continue |
| 757 | phrase_ok = (not stdout_need) or any(stdout_need in line for line in lines) |
| 758 | hash_ok = (not expected) or computed == expected |
| 759 | if code == 0 and phrase_ok and hash_ok: |
| 760 | print( |
| 761 | "HASH %s expected %s computed %s MATCH" % (name, expected or "exit 0", computed), |
| 762 | flush=True, |
| 763 | ) |
| 764 | passed += 1 |
| 765 | else: |
| 766 | print( |
| 767 | "HASH %s expected %s computed %s MISMATCH" % (name, expected or "exit 0", computed), |
| 768 | flush=True, |
| 769 | ) |
| 770 | print("FAIL %s exit %s" % (name, code)) |
| 771 | failed += 1 |
| 772 | return passed, failed, not_run |
| 773 | |
| 774 | |
| 775 | def plan_status(passed, failed, not_run, empty_reason): |
| 776 | if failed: |
| 777 | return "FAIL", "%d failed, %d not_run, %d passed" % (failed, not_run, passed), passed, failed, not_run |
| 778 | if not_run: |
| 779 | return "NOT_RUN", "%d not_run, %d passed (NOT_RUN is not a pass)" % (not_run, passed), passed, 0, not_run |
| 780 | if passed == 0: |
| 781 | return "MISSING", empty_reason, 0, 0, 0 |
| 782 | return "PASS", "%d rows matched" % passed, passed, 0, 0 |
| 783 | |
| 784 | |
| 785 | def spirv_stage(): |
| 786 | stage("5. SPIR-V omega-val, omega-run, mutants, conform") |
| 787 | check = ROOT / "gpu/spirv/check.sh" |
| 788 | if not check.is_file(): |
| 789 | print("MISSING gpu/spirv/check.sh") |
| 790 | print("spirv counts: pass=0 fail=0 skip=0") |
| 791 | return "MISSING", "gpu/spirv/check.sh is not in this checkout", 0, 0, 0 |
| 792 | if MACHINE is not None and MACHINE.omc == "not-run": |
| 793 | hint = omc_hint(MACHINE) |
| 794 | print("NOT_RUN %s" % hint) |
| 795 | print("spirv counts: pass=0 fail=0 not_run=1") |
| 796 | return "NOT_RUN", hint, 0, 0, 0 |
| 797 | omc = ROOT / "seed/out/omc" |
| 798 | ok, detail = omc_can_run(omc) |
| 799 | print("OMC %s" % detail) |
| 800 | if not ok: |
| 801 | hint = qemu_install_line() |
| 802 | print("NOT_RUN %s. %s" % (detail, hint)) |
| 803 | print("spirv counts: pass=0 fail=0 not_run=1") |
| 804 | return "NOT_RUN", "%s. %s" % (detail, hint), 0, 0, 0 |
| 805 | print("RUN OMC=seed/out/omc sh gpu/spirv/check.sh", flush=True) |
| 806 | code, _lines = stream(["sh", "gpu/spirv/check.sh"], ROOT) |
| 807 | verdict = "MATCH" if code == 0 else "MISMATCH" |
| 808 | print("HASH gpu/spirv/check.sh expected exit 0 computed exit %s %s" % (code, verdict)) |
| 809 | print("spirv counts: pass=%d fail=%d skip=0" % (1 if code == 0 else 0, 0 if code == 0 else 1)) |
| 810 | if code == 0: |
| 811 | return "PASS", "gpu/spirv/check.sh exit 0", 1, 0, 0 |
| 812 | return "FAIL", "gpu/spirv/check.sh exit %s" % code, 0, 1, 0 |
| 813 | |
| 814 | |
| 815 | def spirv_rmsnorm_stage(): |
| 816 | stage("6. SPIR-V RMSNorm (gpu/spirv/intel-rmsnorm.tsv)") |
| 817 | path = ROOT / "gpu/spirv/intel-rmsnorm.tsv" |
| 818 | print( |
| 819 | "reference sha256 144c89820d5d005af741dfcace8f9882bae481d72f1745aef36b5014cbaadb46" |
| 820 | ) |
| 821 | if not path.is_file(): |
| 822 | print("MISSING gpu/spirv/intel-rmsnorm.tsv") |
| 823 | print("spirv-rmsnorm counts: pass=0 fail=0 not_run=0") |
| 824 | return "MISSING", "gpu/spirv/intel-rmsnorm.tsv is not in this checkout", 0, 0, 0 |
| 825 | print("PLAN gpu/spirv/intel-rmsnorm.tsv") |
| 826 | passed, failed, not_run = run_plan(path) |
| 827 | print("spirv-rmsnorm counts: pass=%d fail=%d not_run=%d" % (passed, failed, not_run)) |
| 828 | return plan_status(passed, failed, not_run, "gpu/spirv/intel-rmsnorm.tsv has no rows") |
| 829 | |
| 830 | |
| 831 | def intel_opencl_stage(): |
| 832 | stage("7. Intel OpenCL vadd/fsum16/gemm16") |
| 833 | plan = ROOT / "gpu/spirv/intel-opencl.tsv" |
| 834 | print( |
| 835 | "reference sha256 vadd 72d0c1b2928779e83518f0b4c7d101d933cf89f210cd4627e138c33c9ce9b6a6" |
| 836 | ) |
| 837 | print( |
| 838 | "reference sha256 fsum16 6a6de93787e333d506d50996589af3e025c16b9bfc7c9493e1af34578e076290" |
| 839 | ) |
| 840 | print( |
| 841 | "reference sha256 gemm16 d1e02b7d8dd06cd84ee45294b0525000cf7c61e6f6fa32bfa81d3719e47a6987" |
| 842 | ) |
| 843 | if not plan.is_file(): |
| 844 | print("MISSING gpu/spirv/intel-opencl.tsv") |
| 845 | print("intel counts: pass=0 fail=0 not_run=0 missing=1") |
| 846 | return "MISSING", "gpu/spirv/intel-opencl.tsv is not in this checkout", 0, 0, 0 |
| 847 | print("PLAN gpu/spirv/intel-opencl.tsv") |
| 848 | passed, failed, not_run = run_plan(plan) |
| 849 | print("intel counts: pass=%d fail=%d not_run=%d" % (passed, failed, not_run)) |
| 850 | return plan_status(passed, failed, not_run, "gpu/spirv/intel-opencl.tsv has no rows") |
| 851 | |
| 852 | |
| 853 | def zenodo_record(api): |
| 854 | try: |
| 855 | with urllib.request.urlopen(api, timeout=45) as response: |
| 856 | payload = json.loads(response.read().decode("utf-8")) |
| 857 | except Exception as exc: |
| 858 | return None, str(exc) |
| 859 | return payload, None |
| 860 | |
| 861 | |
| 862 | def file_digest(path, algo): |
| 863 | digest = hashlib.new(algo) |
| 864 | with path.open("rb") as handle: |
| 865 | while True: |
| 866 | block = handle.read(1024 * 1024) |
| 867 | if not block: |
| 868 | break |
| 869 | digest.update(block) |
| 870 | return digest.hexdigest() |
| 871 | |
| 872 | |
| 873 | def evidence_stage(argument): |
| 874 | stage("8. Zenodo record file checksums") |
| 875 | api = argument or ZENODO_API |
| 876 | print("GET %s" % api) |
| 877 | payload, err = zenodo_record(api) |
| 878 | if err or payload is None: |
| 879 | print("SKIP Zenodo %s could not be read (%s). Offline: no file was checked." % (ZENODO_DOI, err)) |
| 880 | print("evidence counts: pass=0 fail=0 skip=1") |
| 881 | return "SKIP", "Zenodo record unreadable: %s" % err, 0, 0, 1 |
| 882 | files = payload.get("files") or [] |
| 883 | if not files: |
| 884 | print("SKIP Zenodo %s returned no files" % ZENODO_DOI) |
| 885 | print("evidence counts: pass=0 fail=0 skip=1") |
| 886 | return "SKIP", "Zenodo record has no files", 0, 0, 1 |
| 887 | names = [item.get("key", "") for item in files] |
| 888 | print("zenodo files: %s" % ", ".join(names)) |
| 889 | print("no evidence archive is published on this record; each file is checked against its API checksum") |
| 890 | work = Path(tempfile.mkdtemp(prefix="uxl-zenodo-")) |
| 891 | passed = 0 |
| 892 | failed = 0 |
| 893 | try: |
| 894 | for item in files: |
| 895 | key = item.get("key") or "file" |
| 896 | checksum = item.get("checksum") or "" |
| 897 | link = (item.get("links") or {}).get("self") or "" |
| 898 | if ":" not in checksum or not link: |
| 899 | print("HASH %s expected %s computed MALFORMED MISMATCH" % (key, checksum or "MISSING")) |
| 900 | failed += 1 |
| 901 | continue |
| 902 | algo, expected = checksum.split(":", 1) |
| 903 | expected = expected.lower() |
| 904 | dest = work / key |
| 905 | dest.parent.mkdir(parents=True, exist_ok=True) |
| 906 | print("download %s" % key, flush=True) |
| 907 | try: |
| 908 | with urllib.request.urlopen(link, timeout=120) as response: |
| 909 | dest.write_bytes(response.read()) |
| 910 | except (urllib.error.URLError, TimeoutError, OSError) as exc: |
| 911 | print("SKIP download %s failed (%s)" % (key, exc)) |
| 912 | print("evidence counts: pass=%d fail=%d skip=1" % (passed, failed)) |
| 913 | return "SKIP", "offline or download failed for %s: %s" % (key, exc), passed, failed, 1 |
| 914 | try: |
| 915 | computed = file_digest(dest, algo) |
| 916 | except ValueError as exc: |
| 917 | print("HASH %s expected %s computed UNSUPPORTED MISMATCH" % (key, checksum)) |
| 918 | print("MISMATCH %s (%s)" % (key, exc)) |
| 919 | failed += 1 |
| 920 | continue |
| 921 | verdict = "MATCH" if computed == expected else "MISMATCH" |
| 922 | print("HASH %s expected %s computed %s:%s %s" % (key, checksum, algo, computed, verdict)) |
| 923 | if verdict == "MATCH": |
| 924 | passed += 1 |
| 925 | else: |
| 926 | failed += 1 |
| 927 | finally: |
| 928 | shutil.rmtree(work, ignore_errors=True) |
| 929 | print("evidence counts: pass=%d fail=%d skip=0" % (passed, failed)) |
| 930 | if failed: |
| 931 | return "FAIL", "%d Zenodo files mismatched" % failed, passed, failed, 0 |
| 932 | return "PASS", "%d Zenodo files matched their API checksums" % passed, passed, 0, 0 |
| 933 | |
| 934 | |
| 935 | def summary(rows): |
| 936 | stage("summary") |
| 937 | print("%-16s %-8s %s" % ("STEP", "RESULT", "REASON")) |
| 938 | fails = 0 |
| 939 | for name, status, reason, _passed, failed, _skipped in rows: |
| 940 | print("%-16s %-8s %s" % (name, status, reason)) |
| 941 | fails += failed |
| 942 | status_fails = sum(1 for row in rows if row[1] == "FAIL") |
| 943 | |
| 944 | def count(status): |
| 945 | return sum(1 for row in rows if row[1] == status) |
| 946 | |
| 947 | print("") |
| 948 | print( |
| 949 | "steps pass=%d fail=%d skip=%d not_run=%d missing=%d" |
| 950 | % (count("PASS"), status_fails, count("SKIP"), count("NOT_RUN"), count("MISSING")) |
| 951 | ) |
| 952 | print("SKIP is not a pass. NOT_RUN is not a pass. MISSING is not a pass.") |
| 953 | return 1 if status_fails or fails else 0 |
| 954 | |
| 955 | |
| 956 | def log_path(): |
| 957 | host = platform.node() or "host" |
| 958 | safe = "".join(ch if ch.isalnum() or ch in ("-", "_") else "-" for ch in host) |
| 959 | stamp = datetime.datetime.now(datetime.timezone.utc).strftime("%Y%m%dT%H%M%SZ") |
| 960 | return Path.cwd() / ("uxl-run-%s-%s.log" % (safe or "host", stamp)) |
| 961 | |
| 962 | |
| 963 | def main(argv): |
| 964 | sys.dont_write_bytecode = True |
| 965 | os.environ["PYTHONDONTWRITEBYTECODE"] = "1" |
| 966 | parser = argparse.ArgumentParser(description="Run the UXL checks") |
| 967 | parser.add_argument("--level1", help="directory with SHA256.json and verify.py") |
| 968 | parser.add_argument("--evidence", help="Zenodo API record URL (default: record 24237047)") |
| 969 | parser.add_argument( |
| 970 | "--install-deps", |
| 971 | action="store_true", |
| 972 | help="run the distro install command printed for missing tools (uses sudo)", |
| 973 | ) |
| 974 | args = parser.parse_args(argv) |
| 975 | path = log_path() |
| 976 | tee = Tee(path) |
| 977 | sys.stdout = tee |
| 978 | try: |
| 979 | global MACHINE |
| 980 | print("uxl-run log") |
| 981 | print("spirv executor omega (gpu/spirv/run.om)") |
| 982 | MACHINE = detect() |
| 983 | print_detected(MACHINE) |
| 984 | if args.install_deps: |
| 985 | if not MACHINE.install: |
| 986 | print("install-deps: already present") |
| 987 | else: |
| 988 | print("install-deps running", flush=True) |
| 989 | if not execute_install(MACHINE.install): |
| 990 | print("FAIL install-deps") |
| 991 | print("") |
| 992 | print("log %s" % path.resolve()) |
| 993 | return 1 |
| 994 | MACHINE = detect() |
| 995 | print_detected(MACHINE) |
| 996 | identity() |
| 997 | rows = [] |
| 998 | rows.append(("host",) + host_stage()) |
| 999 | rows.append(("level1",) + level1_stage(level1_dir(args.level1))) |
| 1000 | level2, arm = level2_stage() |
| 1001 | rows.append(("level2",) + level2) |
| 1002 | rows.append(("arm64-only",) + arm) |
| 1003 | rows.append(("spirv",) + spirv_stage()) |
| 1004 | rows.append(("spirv-rmsnorm",) + spirv_rmsnorm_stage()) |
| 1005 | rows.append(("intel-opencl",) + intel_opencl_stage()) |
| 1006 | rows.append(("evidence",) + evidence_stage(args.evidence)) |
| 1007 | code = summary(rows) |
| 1008 | print("") |
| 1009 | print("log %s" % path.resolve()) |
| 1010 | return code |
| 1011 | finally: |
| 1012 | sys.stdout = tee.stdout |
| 1013 | tee.file.close() |
| 1014 | |
| 1015 | |
| 1016 | if __name__ == "__main__": |
| 1017 | sys.exit(main(sys.argv[1:])) |