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 / seed / spirv / vk-replay.sh
| 1 | #!/bin/sh |
| 2 | # Replays a gate-vkspirv.sh run on another Vulkan driver. DIR is a copy of the |
| 3 | # gate's build/seed/vkspirv directory (modules, inputs, native expected outputs |
| 4 | # and replay.tsv); HOST is vk-host built for the target driver (VKSPIRV_TARGET). |
| 5 | # Modules and expectations are produced on AArch64 Linux by seeded omc and the |
| 6 | # native programs; this script only executes and compares them, so a driver |
| 7 | # without omc (MoltenVK on macOS, a GPU box) is checked against the same bytes. |
| 8 | # replay.tsv: MODULE ENTRY NPARAMS INPUT EXPECTED match|mismatch (tab-separated, |
| 9 | # paths relative to DIR). A "mismatch" row is a negative control (opcode mutant) |
| 10 | # that must differ. Exit 0 all rows as required, 1 any failure, 2 usage. |
| 11 | set -eu |
| 12 | [ $# = 2 ] || { echo 'usage: vk-replay.sh HOST DIR' >&2; exit 2; } |
| 13 | HOST=$1; D=$2 |
| 14 | [ -x "$HOST" ] && [ -f "$D/replay.tsv" ] || { echo 'vk-replay: HOST or DIR/replay.tsv missing' >&2; exit 2; } |
| 15 | tab=$(printf '\t'); rows=0; passed=0; controls=0; first=1 |
| 16 | while IFS="$tab" read -r module entry np input expected want; do |
| 17 | rows=$((rows+1)) |
| 18 | if "$HOST" "$D/$module" "$entry" "$np" < "$D/$input" > "$D/$input.replay" 2> "$D/$input.replay.err"; then :; else |
| 19 | rc=$?; cat "$D/$input.replay.err" >&2 |
| 20 | echo "FAIL $module $entry host exited $rc"; exit 1 |
| 21 | fi |
| 22 | if [ "$first" = 1 ]; then grep '^vk-host: \(target\|device\)' "$D/$input.replay.err"; first=0; fi |
| 23 | if cmp -s "$D/$expected" "$D/$input.replay"; then got=match; else got=mismatch; fi |
| 24 | [ "$got" = "$want" ] || { echo "FAIL $module $entry got=$got want=$want"; exit 1; } |
| 25 | [ "$want" = match ] || controls=$((controls+1)) |
| 26 | passed=$((passed+1)) |
| 27 | echo "PASS $module $entry rows=$(wc -l < "$D/$input" | tr -d ' ') $got" |
| 28 | done < "$D/replay.tsv" |
| 29 | [ "$rows" -gt 0 ] && [ "$controls" -gt 0 ] || { echo 'FAIL empty replay or no negative control'; exit 1; } |
| 30 | echo "PASS VKREPLAY dispatches=$passed negative_controls=$controls" |