interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / gpu / qual / gate.sh

106 lines · 5276 bytes Raw Blame History
1#!/bin/sh
2# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3# gpu/qual/gate.sh: compile and run pure-Omega x86 Linux & non-NVIDIA GPU qualification units.
4# Strictly separates HOST_TESTED / EMULATED from PHYSICAL hardware qualification:
5# - On non-x86_64 hosts (e.g. AArch64 Spark), x86linux_qual MUST refuse default execution (exit 3,
6# BLOCKED_HARDWARE) under qemu-x86_64, and only pass its selftest with --allow-emulated-selftest.
7# - On NVIDIA-only or CPU-only hosts, non_nvidia_qual MUST exit 3 (BLOCKED_HARDWARE).
8set -eu
9
10ROOT=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd)
11OMC=${OMC:-"$ROOT/seed/out/omc"}
12WORK=$(mktemp -d "${TMPDIR:-/tmp}/omega-gpu-qual.XXXXXX")
13trap 'rm -rf "$WORK"' EXIT
14
15if [ ! -x "$OMC" ]; then
16 echo "OMEGA-GPU-QUAL NOT_RUN: compiler missing at $OMC" >&2
17 exit 3
18fi
19
20WANT=$(awk '{print $1; exit}' "$ROOT/seed/out/omc.sha256")
21GOT=$(sha256sum "$OMC" | awk '{print $1}')
22if [ "$GOT" != "$WANT" ]; then
23 echo "OMEGA-GPU-QUAL REFUSED: omc sha256 $GOT != $WANT" >&2
24 exit 69
25fi
26
27# 1. Host classification test (AArch64 or native host)
28HOST_ARCH=$(uname -m)
29HDR=""
30if [ "$HOST_ARCH" = "x86_64" ]; then
31 HDR="target x86linux\n"
32fi
33{ printf "${HDR}om2\n"; grep -v '^om2$' "$ROOT/gpu/qual/qual_test.om"; } | "$OMC" > "$WORK/qual_test" 2> "$WORK/qual_test.err"
34[ ! -s "$WORK/qual_test.err" ] || { cat "$WORK/qual_test.err" >&2; exit 1; }
35chmod 700 "$WORK/qual_test"
36"$WORK/qual_test"
37
38# 2. Build non_nvidia_qual for BOTH AArch64 and x86linux (reproducible cross-compile)
39{ printf 'om2\n'; grep -v '^om2$' "$ROOT/gpu/qual/non_nvidia_qual.om"; } | "$OMC" > "$WORK/nnq_a64" 2> "$WORK/nnq_a64.err"
40[ ! -s "$WORK/nnq_a64.err" ] || { cat "$WORK/nnq_a64.err" >&2; exit 1; }
41{ printf 'target x86linux\nom2\n'; grep -v '^om2$' "$ROOT/gpu/qual/non_nvidia_qual.om"; } | "$OMC" > "$WORK/nnq_x86" 2> "$WORK/nnq_x86.err"
42[ ! -s "$WORK/nnq_x86.err" ] || { cat "$WORK/nnq_x86.err" >&2; exit 1; }
43chmod 700 "$WORK/nnq_a64" "$WORK/nnq_x86"
44
45NNQ="$WORK/nnq_a64"
46[ "$HOST_ARCH" = "x86_64" ] && NNQ="$WORK/nnq_x86"
47
48# Synthetic fixture positive controls: AMD MI300X and Intel Panther Lake
49mkdir -p "$WORK/fix-amd/sys/bus/pci/devices/0000:c1:00.0" "$WORK/fix-amd/dev"
50printf '0x1002\n' > "$WORK/fix-amd/sys/bus/pci/devices/0000:c1:00.0/vendor"
51printf '0x74a1\n' > "$WORK/fix-amd/sys/bus/pci/devices/0000:c1:00.0/device"
52printf '0x038000\n' > "$WORK/fix-amd/sys/bus/pci/devices/0000:c1:00.0/class"
53: > "$WORK/fix-amd/dev/kfd"
54"$NNQ" --root "$WORK/fix-amd" > "$WORK/amd.out"
55grep -q 'VERDICT=NON_NVIDIA_HARDWARE_PRESENT' "$WORK/amd.out"
56
57mkdir -p "$WORK/fix-intel/sys/bus/pci/devices/0000:00:02.0" "$WORK/fix-intel/dev/dri"
58printf '0x8086\n' > "$WORK/fix-intel/sys/bus/pci/devices/0000:00:02.0/vendor"
59printf '0xb080\n' > "$WORK/fix-intel/sys/bus/pci/devices/0000:00:02.0/device"
60printf '0x030000\n' > "$WORK/fix-intel/sys/bus/pci/devices/0000:00:02.0/class"
61: > "$WORK/fix-intel/dev/dri/renderD128"
62"$NNQ" --root "$WORK/fix-intel" > "$WORK/intel.out"
63grep -q 'VERDICT=NON_NVIDIA_HARDWARE_PRESENT' "$WORK/intel.out"
64
65# Synthetic fixture negative control: NVIDIA-only GB10 must exit 3 (BLOCKED_HARDWARE)
66mkdir -p "$WORK/fix-nv/sys/bus/pci/devices/000f:01:00.0"
67printf '0x10de\n' > "$WORK/fix-nv/sys/bus/pci/devices/000f:01:00.0/vendor"
68printf '0x2e12\n' > "$WORK/fix-nv/sys/bus/pci/devices/000f:01:00.0/device"
69printf '0x030000\n' > "$WORK/fix-nv/sys/bus/pci/devices/000f:01:00.0/class"
70rc=0
71"$NNQ" --root "$WORK/fix-nv" > "$WORK/nv.out" || rc=$?
72[ "$rc" -eq 3 ] || { echo "FAIL: NVIDIA-only fixture returned $rc, expected 3" >&2; exit 1; }
73grep -q 'VERDICT=BLOCKED_HARDWARE' "$WORK/nv.out"
74
75# Live host inventory (informational; records real hardware state)
76LIVE_NNQ_RC=0
77"$NNQ" > "$WORK/live_nnq.out" || LIVE_NNQ_RC=$?
78echo "--- live non_nvidia_qual (exit=$LIVE_NNQ_RC) ---"
79cat "$WORK/live_nnq.out"
80
81# 3. Build x86linux_qual (target x86linux + sha256)
82{ printf 'target x86linux\nom2\n'; cat "$ROOT/seed/ng/sha256.om"; grep -v '^target x86linux$' "$ROOT/gpu/qual/x86linux_qual.om" | grep -v '^om2$'; } | "$OMC" > "$WORK/x86linux_qual" 2> "$WORK/x86.err"
83[ ! -s "$WORK/x86.err" ] || { cat "$WORK/x86.err" >&2; exit 1; }
84chmod 700 "$WORK/x86linux_qual"
85
86X86_STATUS="NOT_RUN"
87if [ "$HOST_ARCH" = "x86_64" ]; then
88 "$WORK/x86linux_qual" > "$WORK/x86.out"
89 cat "$WORK/x86.out"
90 grep -q 'EXEC_CLASS=PHYSICAL_X86_64' "$WORK/x86.out"
91 X86_STATUS="PHYSICAL_X86_64_PASS"
92elif command -v qemu-x86_64 >/dev/null 2>&1; then
93 # Default invocation under QEMU MUST refuse with exit 3 (BLOCKED_HARDWARE)
94 rc=0
95 qemu-x86_64 "$WORK/x86linux_qual" > "$WORK/x86_def.out" || rc=$?
96 [ "$rc" -eq 3 ] || { echo "FAIL: x86linux_qual under QEMU returned $rc, expected 3 (BLOCKED_HARDWARE)" >&2; exit 1; }
97 grep -q 'EXEC_CLASS=EMULATED' "$WORK/x86_def.out"
98 grep -q 'VERDICT=BLOCKED_HARDWARE' "$WORK/x86_def.out"
99 # Explicit emulated selftest verifies x86_64 codegen, floats, sha256, and traps 1/2/3/5
100 qemu-x86_64 "$WORK/x86linux_qual" --allow-emulated-selftest > "$WORK/x86_emu.out"
101 cat "$WORK/x86_emu.out"
102 grep -q 'VERDICT=EMULATED_SELFTEST_PASS' "$WORK/x86_emu.out"
103 X86_STATUS="EMULATED_SELFTEST_PASS_PHYSICAL_NOT_RUN"
104fi
105
106echo "OMEGA-GPU-QUAL PASS host_controls=all x86linux=$X86_STATUS non_nvidia_live_exit=$LIVE_NNQ_RC"