Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/tests/host-trace/run-host-trace.sh # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / tests / host-trace / run-host-trace.sh` 139 lines · 9174 bytes Raw Blame History 1 #!/bin/sh 2 # Host checks for the unified trace (docs/trace/UNIFIED_TRACE.md). No device is opened. 3 # 4 # Every check is a seeded Omega program compiled by the pinned seed compiler; this script only 5 # composes units, runs them and compares exit codes and output lines. It also applies ten 6 # deliberate source mutations (four trace, six batch) and requires each to make a check fail 7 # (negative controls). 8 # 9 # Usage: OMEGA_COMPILER=/path/to/seed/out/omc sh tests/host-trace/run-host-trace.sh [OUTDIR] 10 # OUTDIR keeps the sample trace files (default: a temporary directory, removed on exit). 11 set -eu 12 root=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) 13 compiler=${OMEGA_COMPILER:-} 14 [ -n "$compiler" ] && [ -x "$compiler" ] || { 15 echo 'OMEGA_COMPILER must name the pinned seed compiler (seed/out/omc)' >&2 16 exit 69 17 } 18 work=${TMPDIR:-/tmp}/cudapp-host-trace.$$ 19 mkdir -p "$work" 20 trap 'rm -rf -- "$work"' EXIT HUP INT TERM 21 out=${1:-$work/out} 22 mkdir -p "$out" 23 t=$root/tests/host-trace 24 n=$root/native 25 echo "compiler $(sha256sum "$compiler" | cut -d' ' -f1)" 26 fail() { echo "FAIL: $*" >&2; exit 1; } 27 build() { # build NAME FILE... 28 name=$1; shift 29 cat "$@" > "$work/$name.om" 30 "$compiler" < "$work/$name.om" > "$work/$name" || return 1 31 chmod +x "$work/$name" 32 } 33 launch_units="$t/fakenv.om $n/blackwell/vector.om $n/blackwell/launch.om $t/fakedev.om $n/trace/htrec.om $n/trace/htlaunch.om $t/launch-test.om" 34 35 # 1. recorder 36 build recorder "$n/trace/htrec.om" "$t/recorder-test.om" || fail 'recorder-test does not compile' 37 "$work/recorder" > "$work/recorder.out" || fail "recorder-test exit $?: $(cat "$work/recorder.out")" 38 grep -qx 'HOSTTRACE_RECORDER_PASS [0-9]*' "$work/recorder.out" || fail 'recorder-test' 39 echo "recorder: $(cat "$work/recorder.out")" 40 41 # 2. omtrace itself, then the launch test traced end to end (compile phases + runtime fragment) 42 build omtrace "$n/trace/htrec.om" "$root/tools/omtrace/omtrace.om" || fail 'omtrace does not compile' 43 cd "$root" 44 # shellcheck disable=SC2086 45 "$work/omtrace" f "$compiler" "$out/launch" "$out/launch.otr" $launch_units > "$work/launch.out" 2>&1 || 46 fail "omtrace f exit $?: $(cat "$work/launch.out")" 47 grep -qx 'HOSTTRACE_LAUNCH_PASS [0-9]*' "$work/launch.out" || fail "launch-test: $(cat "$work/launch.out")" 48 grep -qx 'OMTRACE_OK [0-9]*' "$work/launch.out" || fail 'omtrace f did not report OK' 49 echo "launch: $(paste -sd' ' "$work/launch.out")" 50 for k in '"cat":"kernel.launch"' '"stage_name":"host.wait"' '"cat":"mem.copy"' '"name":"omc.compile"' \ 51 '"name":"device.timing.NOT_RUN"' '"name":"kernel:VECTOR_1D/vector.om:gbvec"'; do 52 grep -qF "$k" "$out/launch.trace.json" || fail "trace lacks $k" 53 done 54 grep -qF '"parentSpanId":"' "$out/launch.otlp.json" || fail 'otlp has no parent links' 55 "$work/omtrace" v "$out/launch.otr" > /dev/null 2>&1 || fail 'the recorded fragment does not validate' 56 grep -qF '"dropped":0,"refused":0,"open_spans":0}' "$out/launch.trace.json" || fail 'clean trace reports losses' 57 # a full recording that lost events must say so in both exports (and must export at all) 58 "$work/omtrace" f "$compiler" "$work/lossy" "$work/lossy.otr" "$n/trace/htrec.om" "$t/lossy.om" \ 59 > "$work/lossy.out" 2>&1 || fail "omtrace f on the lossy fixture exit $?: $(cat "$work/lossy.out")" 60 grep -qF '"dropped":2,"refused":1,"open_spans":1}' "$work/lossy.trace.json" || fail 'chrome export hides losses' 61 for k in '"aien.dropped","value":{"intValue":"2"}' '"aien.refused","value":{"intValue":"1"}' \ 62 '"aien.open_spans","value":{"intValue":"1"}'; do 63 grep -qF "$k" "$work/lossy.otlp.json" || fail "otlp export lacks $k" 64 done 65 echo "lossy: $(cat "$work/lossy.out") with dropped 2, refused 1, open_spans 1 in both exports" 66 67 # 3. compile diagnostics and traps are located in the unit that caused them 68 printf 'fn f a ulong to ulong\nif gt a 3\ntrap 3\nend\nret a\nend\n' > "$work/t1.om" 69 printf 'fn main to int\nr = f 9\nret 0\nend\n' > "$work/t2.om" 70 printf 'om2 diag\nfn main to int\nret int add zz 1\nend\n' > "$work/d2.om" 71 s=0; "$work/omtrace" r "$compiler" "$work/trap" - "$work/t1.om" "$work/t2.om" > /dev/null 2>&1 || s=$? 72 [ "$s" = 0 ] || fail "omtrace r on a trapping program exit $s" 73 grep -qF '"trap_name":"range","candidates":"'"$work"'/t1.om:3"' "$work/trap.trace.json" || fail 'trap not located' 74 s=0; "$work/omtrace" c "$compiler" "$work/diag" - "$work/d2.om" > /dev/null 2>&1 || s=$? 75 [ "$s" = 3 ] || fail "omtrace c on a failing unit exit $s, expected 3" 76 grep -qF '"status":3,"line":3,"col":13,"file":"'"$work"'/d2.om"' "$work/diag.trace.json" || fail 'diagnostic not located' 77 echo 'locate: trap and diagnostic located' 78 79 # 4. malformed fragments: each mutant must be rejected with its own reason 80 build badfrag "$t/badfrag.om" || fail 'badfrag does not compile' 81 "$work/badfrag" "$out/launch.otr" "$work/mut" || fail 'badfrag could not write mutants' 82 expect='20 21 22 23 24 25 26 27 28 29 30 31 27' 83 m=0 84 for e in $expect; do 85 s=0; "$work/omtrace" v "$work/mut.$m.otr" > /dev/null 2>&1 || s=$? 86 [ "$s" = "$e" ] || fail "mutant $m exit $s, expected $e" 87 m=$((m + 1)) 88 done 89 s=0; "$work/omtrace" v "$work/missing.otr" > /dev/null 2>&1 || s=$? 90 [ "$s" = 6 ] || fail "missing fragment exit $s, expected 6" 91 echo "reject: $m malformed fragments rejected with distinct reasons, missing file exit 6" 92 93 # 5. source mutations: each must turn a passing check into a failing one 94 mutate() { # mutate FILE OLDLINE NEWLINE OUT 95 awk -v old="$2" -v new="$3" '$0 == old { print new; hit++; next } { print } END { exit hit != 1 }' "$1" > "$4" || 96 fail "mutation anchor not found once in $1: $2" 97 } 98 # A mutant that no longer compiles proves nothing, so each must compile and then fail its check. 99 killed() { # killed NAME MUTATED-SOURCE FILE...: build, run; true when the run fails 100 name=$1; shift 101 build "$name" "$@" || fail "mutant $name does not compile" 102 ! "$work/$name" > /dev/null 2>&1 103 } 104 mutate "$n/trace/htrec.om" 'if ne get htfl i 0' 'if false' "$work/m1.src" 105 killed m1 "$work/m1.src" "$t/recorder-test.om" || fail 'mutant: second end accepted, test still passes' 106 mutate "$n/trace/htrec.om" 'ret or or eq b 58 eq b 47 eq b 45' 'ret true' "$work/m2.src" 107 killed m2 "$work/m2.src" "$t/recorder-test.om" || fail 'mutant: any name byte accepted, test still passes' 108 mutate "$n/trace/htrec.om" 'ret eq get htst 0 1' 'ret true' "$work/m3.src" 109 killed m3 "$work/m3.src" "$t/recorder-test.om" || fail 'mutant: recorder on by default, test still passes' 110 mutate "$root/tools/omtrace/omtrace.om" 'if lt t1 t0' 'if false' "$work/m4.src" 111 build m4 "$n/trace/htrec.om" "$work/m4.src" || fail 'mutant m4 does not compile' 112 s=0; "$work/m4" v "$work/mut.8.otr" > /dev/null 2>&1 || s=$? 113 [ "$s" != 28 ] || fail 'mutant: end-before-start check removed, still rejected as time' 114 echo 'mutations: 4 of 4 compile and are detected' 115 # 6. Native launch batches: actual packet bytes, one kick/wait, refusal and index attribution. 116 # The coordinator remains migration debt; policy, queue model and every new check are Omega. 117 batch_units="$t/batch-fake.om $n/blackwell/vector.om $n/blackwell/launch.om" 118 build batch $batch_units "$n/blackwell/batch.om" "$t/batch-device.om" "$t/batch-test.om" || fail 'batch does not compile' 119 "$work/batch" > "$out/batch.txt" || fail "batch: $(cat "$out/batch.txt")" 120 grep -qx 'BATCH_HOST_PASS checks=[0-9]* parity_cases=32 parity_bytes=[0-9]* batch_launches=287 kicks=1 waits=1 negatives=8' "$out/batch.txt" || fail 'batch output' 121 cat "$out/batch.txt" 122 mutate "$n/blackwell/batch.om" 'if gt dep idx' 'if false' "$work/bdep.src" 123 killed bdep $batch_units "$work/bdep.src" "$t/batch-device.om" "$t/batch-test.om" || fail 'batch: dependency mutant survived' 124 mutate "$n/blackwell/batch.om" 'if or eq count 0 gt count 512' 'if eq count 0' "$work/bcap.src" 125 killed bcap $batch_units "$work/bcap.src" "$t/batch-device.om" "$t/batch-test.om" || fail 'batch: capacity mutant survived' 126 mutate "$n/blackwell/batch.om" 'put gbst 4 i' 'put gbst 4 n' "$work/bindex.src" 127 killed bindex $batch_units "$work/bindex.src" "$t/batch-device.om" "$t/batch-test.om" || fail 'batch: index mutant survived' 128 mutate "$n/blackwell/batch.om" 'gbemit 4113' 'gbemit 0' "$work/border.src" 129 killed border $batch_units "$work/border.src" "$t/batch-device.om" "$t/batch-test.om" || fail 'batch: cache ordering mutant survived' 130 mutate "$n/blackwell/batch.om" 'if gt add n get gbst 2 `1048476`' 'if false' "$work/bbyte.src" 131 killed bbyte $batch_units "$work/bbyte.src" "$t/batch-device.om" "$t/batch-test.om" || fail 'batch: byte capacity mutant survived' 132 mutate "$n/blackwell/launch.om" 'm = nvalloc size ge i 5' 'm = nvalloc size true' "$work/bcache.src" 133 killed bcache "$t/batch-fake.om" "$n/blackwell/vector.om" "$work/bcache.src" "$n/blackwell/batch.om" "$t/batch-device.om" "$t/batch-test.om" || fail 'batch: GPU-cache attribute mutant survived' 134 echo 'batch mutations: 6 of 6 compile and are detected' 135 build batchwait "$n/nvrm/context.om" "$t/batch-wait-test.om" || fail 'native batch wait does not compile' 136 "$work/batchwait" > "$out/batch-wait.txt" || fail 'native batch wait failed' 137 grep -qx 'BATCH_NATIVE_WAIT_PASS completion timeout refusal' "$out/batch-wait.txt" || fail 'native batch wait output' 138 cat "$out/batch-wait.txt" 139 echo 'HOST TRACE CHECKS PASS'