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/tools/prof/selftest.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 / tools / prof / selftest.sh` 129 lines · 4334 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 # Host and simulator gate for tools/prof. No GPU is opened. The caller chooses CPU placement 4 # (taskset/nice): fixed cores 10-14 here failed on a 4-CPU hosted runner (taskset: Invalid argument). 5 set -eu 6 ROOT=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) 7 PROF="$ROOT/tools/prof" 8 : "${OMEGA_OMC:=$HOME/work/cudastack/omega-mv/seed/out/omc}" 9 expected=`2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f` 10 if [ ! -x "$OMEGA_OMC" ]; then 11 echo "NOT_RUN: pinned omc is not executable at $OMEGA_OMC" 12 exit 2 13 fi 14 actual=$(sha256sum < "$OMEGA_OMC" | cut -c1-64) 15 if [ "$actual" != "$expected" ]; then 16 echo "NOT_RUN: profiler compiler pin mismatch" 17 exit 2 18 fi 19 T=$(mktemp -d) 20 trap 'rm -rf "$T"' EXIT HUP INT TERM 21 22 "$OMEGA_OMC" < "$PROF/prof.om" > "$T/prof" 2>"$T/omc.err" 23 chmod +x "$T/prof" 24 25 "$T/prof" words `4294967408` 0 > "$T/words.txt" 26 printf '%s\n' `537206870` 0 0 112 1 0 > "$T/words.exp" 27 diff -u "$T/words.exp" "$T/words.txt" 28 cc -std=c11 -Wall -Wextra -Werror -o "$T/oracle" "$PROF/stamp_oracle.c" 29 "$T/oracle" `4294967408` 0 > "$T/oracle.txt" 30 diff -u "$T/words.txt" "$T/oracle.txt" 31 "$T/prof" words 100 1 > "$T/w1.txt" 32 "$T/oracle" 100 1 > "$T/o1.txt" 33 diff -u "$T/w1.txt" "$T/o1.txt" 34 35 "$T/prof" fix "$T/fix.bin" 36 cc -std=c11 -Wall -Wextra -Werror -o "$T/wfix" "$PROF/write_fix.c" 37 "$T/wfix" "$T/cfix.bin" 38 cmp "$T/fix.bin" "$T/cfix.bin" 39 40 "$T/prof" sim "$T/sim.txt" 41 diff -u "$PROF/golden.txt" "$T/sim.txt" 42 "$T/prof" report "$T/fix.bin" "$T/rep.txt" 43 diff -u "$PROF/golden.txt" "$T/rep.txt" 44 45 grep -F 'k 0 time_ns `1000000000` bytes `195100000000` flops `115140000000` ai_milli 590 bound_probe mem' "$T/sim.txt" >/dev/null 46 grep -F 'ai_milli `590158892` bound_probe compute' "$T/sim.txt" >/dev/null 47 grep -F 'ai_milli 590158 bound_probe ridge' "$T/sim.txt" >/dev/null 48 grep -F 'probe_mem_milli 1000 probe_flop_milli 1 sec5_mem_237_milli 823 sec5_mem_207_milli 942 sec5_flop_milli 0' "$T/sim.txt" >/dev/null 49 grep -F 'sec5_flop_milli 484' "$T/sim.txt" >/dev/null 50 grep -F 'probe_mem_milli 500 probe_flop_milli 500 sec5_mem_237_milli 411 sec5_mem_207_milli 471 sec5_flop_milli 242' "$T/sim.txt" >/dev/null 51 grep -F 'ridge_probe_milli 590158' "$T/sim.txt" >/dev/null 52 53 set +e 54 "$T/prof" >/dev/null 2>&1 55 usage=$? 56 set -e 57 [ "$usage" -eq 2 ] 58 59 python3 - "$T" << 'PY' 60 import pathlib, sys 61 t = pathlib.Path(sys.argv[1]) 62 b = bytearray((t / "fix.bin").read_bytes()) 63 swap = bytearray(b) 64 swap[112:120], swap[128:136] = swap[128:136], swap[112:120] 65 (t / "swap.bin").write_bytes(swap) 66 zero = bytearray(b) 67 zero[128:136] = zero[112:120] 68 (t / "zero.bin").write_bytes(zero) 69 bad = bytearray(b) 70 bad[0] = 0 71 (t / "bad.bin").write_bytes(bad) 72 (t / "short.bin").write_bytes(bytes(b[:32])) 73 PY 74 75 set +e 76 "$T/prof" report "$T/swap.bin" "$T/swap.txt" >/dev/null 2>&1 77 swap=$? 78 "$T/prof" report "$T/zero.bin" "$T/zero.txt" >/dev/null 2>&1 79 zero=$? 80 "$T/prof" report "$T/bad.bin" "$T/bad.txt" >/dev/null 2>&1 81 bad=$? 82 "$T/prof" report "$T/short.bin" "$T/short.txt" >/dev/null 2>&1 83 short=$? 84 set -e 85 [ "$swap" -eq 3 ] 86 [ "$zero" -eq 3 ] 87 [ "$bad" -eq 4 ] 88 [ "$short" -eq 4 ] 89 90 sed 's/bad = lt t1 t0/bad = lt t1 t1/' "$PROF/prof.om" > "$T/order.om" 91 grep -F 'bad = lt t1 t1' "$T/order.om" >/dev/null 92 if grep -F 'bad = lt t1 t0' "$T/order.om" >/dev/null; then 93 echo "order mutant sed did not apply" 94 exit 1 95 fi 96 "$OMEGA_OMC" < "$T/order.om" > "$T/order" 2>"$T/order.err" 97 chmod +x "$T/order" 98 set +e 99 "$T/order" report "$T/swap.bin" "$T/order.txt" >/dev/null 2>&1 100 ord=$? 101 set -e 102 [ "$ord" -ne 3 ] 103 104 sed 's/const flop_at ulong 16/const flop_at ulong 8/' "$PROF/prof.om" > "$T/flop.om" 105 grep -F 'const flop_at ulong 8' "$T/flop.om" >/dev/null 106 if grep -F 'const flop_at ulong 16' "$T/flop.om" >/dev/null; then 107 echo "flop mutant sed did not apply" 108 exit 1 109 fi 110 "$OMEGA_OMC" < "$T/flop.om" > "$T/flop" 2>"$T/flop.err" 111 chmod +x "$T/flop" 112 "$T/flop" report "$T/fix.bin" "$T/flop.txt" 113 if diff -q "$PROF/golden.txt" "$T/flop.txt" >/dev/null; then 114 echo "flop mutant was not caught" 115 exit 1 116 fi 117 118 set +e 119 sh "$PROF/chip.sh" > "$T/chip.txt" 120 chip=$? 121 set -e 122 [ "$chip" -eq 2 ] 123 grep -F 'NOT_RUN' "$T/chip.txt" >/dev/null 124 if grep -F '/dev/nvidia' "$PROF/chip.sh" >/dev/null; then 125 echo "chip.sh names a GPU device node" 126 exit 1 127 fi 128 129 echo "PROFILER HOST SIM PASS words oracle fixture sim report mutants swap=$swap order=$ord chip=$chip"