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
CUDApp / tools / extract / map.sh
| 1 | #!/usr/bin/env bash |
| 2 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | # map.sh: file-level map of the GPU stack between Omega (aien-dev/omega-mv) and CUDA++. |
| 4 | # |
| 5 | # tools/extract/map.sh OMEGA_DIR OMEGA_REF [CUDAPP_REF] [PHYSICS_DIR PHYSICS_REF] |
| 6 | # |
| 7 | # Prints TSV on stdout: omega_path cudapp_path status omega_blob cudapp_blob |
| 8 | # status: same | differs | cudapp-only | omega-only |
| 9 | # Paths are 1:1 (filemap.tsv is the identity map). The set compared is the GPU part: |
| 10 | # every path in filemap.tsv, shared.txt and extra-paths.txt (directories expanded), |
| 11 | # every src/omega_gpu_* / src/omega_blackwell_* / src/omega_bw_* / src/omega_sm121_* file on either side, |
| 12 | # every tests/, mk/, examples/ and docs/runtime/ file CUDA++ holds or Omega holds under |
| 13 | # a CUDA++ name pattern (tests/gpu_*, tests/bw_*, mk/omega-gpu-*, mk/runtime-*, mk/sm121dis.mk, |
| 14 | # tools/sm121dis/, evidence/C3-* .. evidence/C6-*). |
| 15 | # With PHYSICS_DIR/PHYSICS_REF the driver-client paths (physics-paths.txt) are compared |
| 16 | # against that physics checkout instead of Omega; their omega_path column reads physics:PATH. |
| 17 | # Blobs are git object ids, so `same` means byte-identical. Opens nothing but git. |
| 18 | set -euo pipefail |
| 19 | export LC_ALL=C |
| 20 | |
| 21 | omega=${1:?omega dir}; oref=${2:?omega ref}; cref=${3:-HEAD} |
| 22 | physics=${4:-}; pref=${5:-} |
| 23 | here=$(cd "$(dirname "$0")" && pwd) |
| 24 | top=$(git -C "$here" rev-parse --show-toplevel) |
| 25 | otip=$(git -C "$omega" rev-parse --verify "$oref^{commit}") |
| 26 | ctip=$(git -C "$top" rev-parse --verify "$cref^{commit}") |
| 27 | |
| 28 | lst() { grep -v '^#' "$1" | grep . || true; } |
| 29 | tree() { git -C "$1" ls-tree -r "$2" | awk -F'\t' '{split($1,a," "); print $2 "\t" a[3]}'; } |
| 30 | |
| 31 | scratch=$(mktemp -d); trap 'rm -rf "$scratch"' EXIT |
| 32 | tree "$omega" "$otip" | sort > "$scratch/o" |
| 33 | tree "$top" "$ctip" | sort > "$scratch/c" |
| 34 | : > "$scratch/p" |
| 35 | if [[ -n $physics ]]; then |
| 36 | ptip=$(git -C "$physics" rev-parse --verify "$pref^{commit}") |
| 37 | tree "$physics" "$ptip" | sort > "$scratch/p" |
| 38 | fi |
| 39 | lst "$here/physics-paths.txt" > "$scratch/phys-roots" |
| 40 | |
| 41 | { |
| 42 | cut -f1 "$here/filemap.tsv" |
| 43 | lst "$here/shared.txt" |
| 44 | lst "$here/extra-paths.txt" |
| 45 | cat "$scratch/phys-roots" |
| 46 | cut -f1 "$scratch/o" "$scratch/c" | grep -E '^src/omega_(gpu|blackwell|bw|sm121)_|^tests/(gpu|bw)_|^mk/(omega-gpu|runtime)-|^mk/sm121dis\.mk$|^tools/sm121dis/|^evidence/C[3-6]-' |
| 47 | cut -f1 "$scratch/c" | grep -E '^(src|tests|mk|examples|docs/runtime|nvrm|m16|native)/|^Makefile$' |
| 48 | } | sort -u > "$scratch/roots" |
| 49 | |
| 50 | # Expand directory roots against both trees, keep files only. |
| 51 | cut -f1 "$scratch/o" "$scratch/c" "$scratch/p" | sort -u > "$scratch/all" |
| 52 | awk 'NR==FNR{r[$0]=1; next} {p=$0; if (p in r) {print; next} n=split(p,s,"/"); d=""; for(i=1;i<n;i++){d=d (i>1?"/":"") s[i]; if (d in r) {print; next}}}' \ |
| 53 | "$scratch/roots" "$scratch/all" | sort -u > "$scratch/paths" |
| 54 | |
| 55 | # A path is a driver-client path when it equals or sits under a physics-paths.txt root. |
| 56 | isphys() { awk -v p="$1" 'BEGIN{r=1} {if (p==$0 || index(p, $0 "/")==1) {r=0; exit}} END{exit r}' "$scratch/phys-roots"; } |
| 57 | |
| 58 | printf 'omega_path\tcudapp_path\tstatus\tomega_blob\tcudapp_blob\n' |
| 59 | join -t$'\t' -a1 -e- -o 0,2.2 "$scratch/paths" "$scratch/o" > "$scratch/jo" |
| 60 | join -t$'\t' -a1 -e- -o 0,2.2 "$scratch/paths" "$scratch/c" > "$scratch/jc" |
| 61 | join -t$'\t' -a1 -e- -o 0,2.2 "$scratch/paths" "$scratch/p" > "$scratch/jp" |
| 62 | paste "$scratch/jo" "$scratch/jc" "$scratch/jp" | while IFS=$'\t' read -r path ob _ cb _ pb; do |
| 63 | src=$path |
| 64 | if [[ -n $physics ]] && isphys "$path"; then ob=$pb; src="physics:$path"; fi |
| 65 | if [[ $ob == - && $cb == - ]]; then continue |
| 66 | elif [[ $ob == - ]]; then st=cudapp-only |
| 67 | elif [[ $cb == - ]]; then st=omega-only |
| 68 | elif [[ $ob == "$cb" ]]; then st=same |
| 69 | else st=differs; fi |
| 70 | printf '%s\t%s\t%s\t%s\t%s\n' "$src" "$path" "$st" "$ob" "$cb" |
| 71 | done |