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 / tools / ldst_nvdisasm_check.sh

46 lines · 2564 bytes Raw Blame History
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# ldst_nvdisasm_check.sh -- offline provenance for the E1 row 2 load/store kernels.
18# Builds the CPU-only test, dumps every table kernel (src/omega_numeric_ldst_gb10.c: load/store
19# kinds, offsets, strides), disassembles each with Omega's own sm121dis and compares the text line by
20# line with omega_ldst_listing (what the encoder says each word is). Any difference fails.
21# The disassembler is an offline decoder only; nothing it prints is copied into a kernel. No device.
22# Run: make test-ldst-nvdisasm Writes only to a temp dir.
23set -u
24HERE=$(cd -P "$(dirname "$0")/.." && pwd)
25DISASM=${DISASM:-$HERE/build/sm121dis} # Omega's own sm_121 disassembler (C6, src/omega_sm121_disasm.c)
26TMP=$(mktemp -d)
27trap 'rm -rf "$TMP"' EXIT
28make -s -C "$HERE" build/sm121dis >/dev/null || { echo "VERDICT FAIL: build sm121dis"; exit 1; }
29make -s -C "$HERE" build/test_omega_ldst_gb10_cpu >/dev/null || { echo "VERDICT FAIL: build"; exit 1; }
30"$HERE/build/test_omega_ldst_gb10_cpu" --dump "$TMP" >/dev/null || { echo "VERDICT FAIL: dump"; exit 1; }
31echo "disassembler: $("$DISASM" --version)"
32rc=0; n=0; bad=0
33for bin in "$TMP"/k*.bin; do
34 k=$(basename "$bin" .bin)
35 "$DISASM" -b SM121 "$bin" > "$TMP/$k.raw" 2> "$TMP/$k.err" || { echo "[FAIL] $k: disassembler error"; cat "$TMP/$k.err"; rc=1; bad=$((bad+1)); continue; }
36 sed -n 's|^[[:space:]]*/\*\([0-9a-f]\{4\}\)\*/[[:space:]]*\(.*;\).*$|\1 \2|p' "$TMP/$k.raw" \
37 | sed 's/[[:space:]]\{1,\}/ /g; s/ ;$/ ;/' > "$TMP/$k.got"
38 n=$((n+1))
39 if ! diff -u "$TMP/$k.lst" "$TMP/$k.got" > "$TMP/$k.diff"; then
40 echo "[FAIL] $k: disassembler text differs from the encoder's listing"; head -20 "$TMP/$k.diff"; rc=1; bad=$((bad+1))
41 fi
42done
43echo "[$([ $bad = 0 ] && echo PASS || echo FAIL)] ldst: $((n-bad)) of $n kernels decode, every word, to the encoder's text"
44[ $n -gt 0 ] || rc=1
45[ $rc = 0 ] && echo "VERDICT PASS" || echo "VERDICT FAIL"
46exit $rc