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 / divsqrt_nvdisasm_check.sh
| 1 | #!/bin/bash |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | # Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # divsqrt_nvdisasm_check.sh -- offline provenance for the E1 row 7 kernels. |
| 18 | # Builds the CPU-only test, dumps every whole-program kernel (DIV, SQRT and the transcendentals) Omega's own encoder |
| 19 | # emits, disassembles every word with Omega's own sm121dis (C6; it agrees with nvdisasm on every library |
| 20 | # kernel) and compares the text line by line with omega_ds_listing (what the encoder says each word is). |
| 21 | # Any difference fails. The disassembler is an offline decoder only; nothing it prints |
| 22 | # is copied into the kernel. No device is opened. |
| 23 | # Run: make test-divsqrt-nvdisasm (or run this file). Writes only to a temp dir. |
| 24 | set -u |
| 25 | HERE=$(cd -P "$(dirname "$0")/.." && pwd) |
| 26 | DISASM=${DISASM:-$HERE/build/sm121dis} # Omega's own sm_121 disassembler (C6, src/omega_sm121_disasm.c) |
| 27 | TMP=$(mktemp -d) |
| 28 | trap 'rm -rf "$TMP"' EXIT |
| 29 | make -s -C "$HERE" build/sm121dis >/dev/null || { echo "VERDICT FAIL: build sm121dis"; exit 1; } |
| 30 | make -s -C "$HERE" build/test_omega_divsqrt_gb10_cpu >/dev/null || { echo "VERDICT FAIL: build"; exit 1; } |
| 31 | "$HERE/build/test_omega_divsqrt_gb10_cpu" --dump "$TMP" || { echo "VERDICT FAIL: dump"; exit 1; } |
| 32 | echo "disassembler: $("$DISASM" --version)" |
| 33 | rc=0 |
| 34 | for op in div sqrt exp2 log2 sigmoid tanh sin cos erf gelu rsqrt exp log; do |
| 35 | "$DISASM" -b SM121 "$TMP/$op.bin" > "$TMP/$op.raw" 2> "$TMP/$op.err" || { echo "[FAIL] $op: disassembler error"; cat "$TMP/$op.err"; rc=1; continue; } |
| 36 | # keep "/*addr*/ text ;" lines, normalise spacing, drop the hex comments |
| 37 | sed -n 's|^[[:space:]]*/\*\([0-9a-f]\{4\}\)\*/[[:space:]]*\(.*;\).*$|\1 \2|p' "$TMP/$op.raw" \ |
| 38 | | sed 's/[[:space:]]\{1,\}/ /g; s/ ;$/ ;/' > "$TMP/$op.got" |
| 39 | words=$(wc -l < "$TMP/$op.lst") |
| 40 | if grep -q 'MUFU' "$TMP/$op.got"; then |
| 41 | echo "[FAIL] $op: the disassembly contains MUFU"; rc=1 |
| 42 | elif diff -u "$TMP/$op.lst" "$TMP/$op.got" > "$TMP/$op.diff"; then |
| 43 | echo "[PASS] $op: all $words words decode to the encoder's text, no MUFU" |
| 44 | else |
| 45 | echo "[FAIL] $op: disassembler text differs from the encoder's listing"; head -40 "$TMP/$op.diff"; rc=1 |
| 46 | fi |
| 47 | done |
| 48 | [ $rc = 0 ] && echo "VERDICT PASS" || echo "VERDICT FAIL" |
| 49 | exit $rc |