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/device-trace/run-runner-controls.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 / device-trace / run-runner-controls.sh` 99 lines · 3782 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 # Shell orchestration only: fake compiler programs and deliberately synthetic decode rows. 4 # This does not compile Omega, decode GPU bytes, open a GPU or establish native execution. 5 set -eu 6 root=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) 7 work=$(mktemp -d "${TMPDIR:-/tmp}/cudapp-runner-controls.XXXXXX") 8 trap 'rm -rf -- "$work"' EXIT HUP INT TERM 9 mkdir "$work/bin" 10 export RUNNER_CONTROL_LOG="$work/calls" 11 12 cat > "$work/bin/omc" <<'EOF' 13 #!/bin/sh 14 set -eu 15 src=$(cat) 16 case "$src" in 17 *'global Aregs ulong'*) unit=address ;; 18 *'fn gprepare to void'*) unit=guard ;; 19 *'fn ballflags to bool'*) 20 unit=body 21 case "$src" in *'fn gbvec to void'*) : ;; *) exit 32 ;; esac ;; 22 *'global Fails ulong'*) unit=emitter ;; 23 *) unit=dump ;; 24 esac 25 printf 'compile %s\n' "$unit" >> "$RUNNER_CONTROL_LOG" 26 if [ "${CONTROL_STDERR:-}" = "$unit" ]; then echo 'synthetic compiler diagnostic' >&2; fi 27 # Emit executable bytes even when the compiler later fails. They must not run. 28 printf '#!/bin/sh\nprintf "run %s\\n" >> "$RUNNER_CONTROL_LOG"\n' "$unit" 29 printf '[ "${CONTROL_FAIL:-}" != "%s" ] || exit 23\n' "$unit" 30 if [ "$unit" = dump ]; then 31 printf 'dd if=/dev/zero bs=640 count=1 2>/dev/null\n' 32 elif [ "$unit" = emitter ]; then 33 printf 'printf "1 0\\n"\n' 34 fi 35 if [ "${CONTROL_COMPILE_FAIL:-}" = "$unit" ]; then exit 24; fi 36 EOF 37 cat > "$work/bin/nvdisasm" <<'EOF' 38 #!/bin/sh 39 set -eu 40 echo decode >> "$RUNNER_CONTROL_LOG" 41 [ "${CONTROL_DECODE_FAIL:-0}" = 0 ] || exit 25 42 # Only the runner's handwritten addressed expectations are meaningful here. 43 # Repeated ffff rows below are intentionally not a real instruction stream. 44 printf '%s\n' '/*0010*/ @P0 BRA 0x140 ;' '/*0070*/ MOV R6, 0x40 ;' \ 45 '/*0080*/ IMAD.WIDE.U32 R8, R6, 0x1, R4 ;' '/*01b0*/ MOV R6, 0x80 ;' \ 46 '/*01c0*/ IMAD.WIDE.U32 R8, R6, 0x1, R4 ;' 47 for pair in 'BRA 1' 'ISETP.GE.AND 2' 'LDC.64 6' 'LDCU.64 2' 'MOV 6' 'S2R 2' 'STG.E 16'; do 48 set -- $pair 49 n=$2 50 while [ "$n" -gt 0 ]; do printf '/*ffff*/ %s ;\n' "$1"; n=$((n - 1)); done 51 done 52 EOF 53 chmod +x "$work/bin/omc" "$work/bin/nvdisasm" 54 55 run_case() { 56 : > "$RUNNER_CONTROL_LOG" 57 rc=0 58 OMEGA_COMPILER="$work/bin/omc" PATH="$work/bin:$PATH" \ 59 sh "$root/tests/device-trace/run-emitter-checks.sh" > "$work/out" 2> "$work/err" || rc=$? 60 } 61 fail() { echo "runner control FAIL: $*" >&2; cat "$work/out" "$work/err" >&2; exit 1; } 62 63 run_case 64 [ "$rc" = 0 ] || fail 'positive shell orchestration' 65 for unit in emitter address guard body dump; do 66 grep -qx "compile $unit" "$RUNNER_CONTROL_LOG" || fail "missing compile $unit" 67 grep -qx "run $unit" "$RUNNER_CONTROL_LOG" || fail "missing run $unit" 68 done 69 grep -qx decode "$RUNNER_CONTROL_LOG" || fail 'missing decode' 70 71 for unit in emitter address guard body; do 72 export CONTROL_FAIL="$unit" 73 run_case 74 [ "$rc" = 23 ] || fail "$unit failure was not propagated" 75 if grep -qx decode "$RUNNER_CONTROL_LOG"; then fail "decode ran after $unit failed"; fi 76 done 77 unset CONTROL_FAIL 78 79 for unit in emitter address guard body dump; do 80 export CONTROL_COMPILE_FAIL="$unit" 81 run_case 82 [ "$rc" != 0 ] || fail "$unit compiler failure was accepted" 83 if grep -qx "run $unit" "$RUNNER_CONTROL_LOG"; then fail "$unit ran rejected compiler output"; fi 84 done 85 unset CONTROL_COMPILE_FAIL 86 87 for unit in emitter address guard body dump; do 88 export CONTROL_STDERR="$unit" 89 run_case 90 [ "$rc" != 0 ] || fail "$unit compiler diagnostic was accepted" 91 if grep -qx "run $unit" "$RUNNER_CONTROL_LOG"; then fail "$unit ran with compiler diagnostics"; fi 92 done 93 unset CONTROL_STDERR 94 95 export CONTROL_DECODE_FAIL=1 96 run_case 97 [ "$rc" = 25 ] || fail 'decoder failure was not propagated' 98 unset CONTROL_DECODE_FAIL 99 echo 'RUNNER ORCHESTRATION CONTROLS PASS (synthetic tools; no native or GPU execution)'