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/runtime_portability_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 / tools / runtime_portability_controls.sh` 68 lines · 4423 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 # Negative and positive controls for tools/runtime_portability_check.sh (omega-mv#596, slice R3). 4 # usage: runtime_portability_controls.sh 5 # Each control builds a scratch copy of the GPU source files, breaks one thing, and requires the 6 # checker to FAIL with the expected message (or, for the positive control, to still PASS). 7 # A check that cannot fail proves nothing. Exit 0 only when every control behaves as required. 8 scratch=$1; table=$2; mk=$3 9 here=$(cd "$(dirname "$0")" && pwd) 10 chk="$here/runtime_portability_check.sh" 11 [ -n "$scratch" ] && [ -f "$table" ] && [ -f "$mk" ] || { echo "usage: $0 "; exit 2; } 12 ok=0 13 14 fresh() { # fresh : scratch root with a copy of the GPU files and the table 15 r="$scratch/$1"; rm -rf "$r"; mkdir -p "$r/src" 16 cp src/omega_gpu_* src/omega_blackwell_* src/omega_bw_* src/omega_ampere_* "$r/src/" 17 cp "$table" "$r/table.tsv" 18 } 19 expect_fail() { # expect_fail 20 out=$("$chk" "$scratch/$1" "$scratch/$1/table.tsv" "$mk" 2>&1); rc=$? 21 if [ $rc -eq 1 ] && printf '%s\n' "$out" | grep -q "$2"; then 22 echo "CONTROL $1: FAIL as required ($3)"; printf '%s\n' "$out" | grep "$2" | head -2 | sed 's/^/ /' 23 else 24 echo "CONTROL $1: WRONG, the checker exit was $rc and did not report '$2' ($3)"; printf '%s\n' "$out" | head -5 | sed 's/^/ /'; ok=1 25 fi 26 } 27 expect_pass() { 28 out=$("$chk" "$scratch/$1" "$scratch/$1/table.tsv" "$mk" 2>&1); rc=$? 29 if [ $rc -eq 0 ]; then echo "CONTROL $1: PASS as required ($2)" 30 else echo "CONTROL $1: WRONG, the checker failed ($2)"; printf '%s\n' "$out" | head -5 | sed 's/^/ /'; ok=1; fi 31 } 32 setclass() { # setclass 33 awk -F'\t' -v f="$2" -v c="$3" 'BEGIN{OFS="\t"} $1==f{$2=c} {print}' "$scratch/$1/table.tsv" > "$scratch/$1/t.new" && mv "$scratch/$1/t.new" "$scratch/$1/table.tsv" 34 } 35 36 fresh unchanged; expect_pass unchanged "scratch copy of the real tree and table" 37 38 fresh new-file-no-row 39 printf 'int omega_gpu_zz_dummy(void) { return 0; }\n' > "$scratch/new-file-no-row/src/omega_gpu_zz_dummy.c" 40 expect_fail new-file-no-row "no row in the table for src/omega_gpu_zz_dummy.c" "a new omega_gpu_ file with no row" 41 42 fresh row-missing-file 43 printf 'src/omega_gpu_zz_ghost.c\tPORTABLE\tghost\tNO_HOSTED_INCLUDE\n' >> "$scratch/row-missing-file/table.tsv" 44 expect_fail row-missing-file "row names a missing file: src/omega_gpu_zz_ghost.c" "a row for a file that does not exist" 45 46 fresh portable-includes-nvrm 47 printf '#include "nvrm.h"\n' | cat - "$scratch/portable-includes-nvrm/src/omega_gpu_wait.c" > "$scratch/p.c" && mv "$scratch/p.c" "$scratch/portable-includes-nvrm/src/omega_gpu_wait.c" 48 expect_fail portable-includes-nvrm "omega_gpu_wait.c: PORTABLE but includes a Linux/NVRM header: nvrm.h" "a PORTABLE file that includes nvrm.h" 49 50 fresh portable-row-on-linux-file 51 setclass portable-row-on-linux-file src/omega_gpu_platform_linux.c PORTABLE 52 expect_fail portable-row-on-linux-file "omega_gpu_platform_linux.c: PORTABLE but includes a Linux/NVRM header" "the real Linux backend relabelled PORTABLE" 53 54 fresh portable-row-on-chip-file 55 setclass portable-row-on-chip-file src/omega_blackwell_qmd.h PORTABLE 56 setclass portable-row-on-chip-file src/omega_gpu_attention_api.c PORTABLE 57 expect_fail portable-row-on-chip-file "omega_gpu_attention_api.c: PORTABLE but includes a Blackwell chip header" "a file that includes Blackwell headers relabelled PORTABLE" 58 59 fresh guarded-include 60 { printf '#ifndef OMEGA_GPU_NO_POSIX\n#include "nvrm.h"\n#include \n#endif\n'; cat "$scratch/guarded-include/src/omega_gpu_engine.c"; } > "$scratch/g.c" && mv "$scratch/g.c" "$scratch/guarded-include/src/omega_gpu_engine.c" 61 expect_pass guarded-include "an nvrm.h include inside #ifndef OMEGA_GPU_NO_POSIX is the hosted-only build and must not count" 62 63 fresh freestanding-claim-broken 64 printf '#include \n' | cat - "$scratch/freestanding-claim-broken/src/omega_gpu_fmt.c" > "$scratch/g.c" && mv "$scratch/g.c" "$scratch/freestanding-claim-broken/src/omega_gpu_fmt.c" 65 expect_fail freestanding-claim-broken "omega_gpu_fmt.c: is in GPU_FS_SRCS but the include scan finds stdlib.h" "a freestanding-closure file that gained stdlib.h" 66 67 [ $ok -eq 0 ] && echo "ALL CONTROLS BEHAVED AS REQUIRED" || echo "A CONTROL DID NOT BEHAVE: the check is not trustworthy" 68 exit $ok