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 / carry.sh
| 1 | #!/usr/bin/env bash |
| 2 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | # carry.sh: bring the GPU half of an Omega branch over to CUDA++, with its whole history |
| 4 | # (merges and their conflict resolutions included). |
| 5 | # |
| 6 | # tools/extract/carry.sh OMEGA_DIR OMEGA_REF NEW_BRANCH [EXTRA_PATHSPEC...] |
| 7 | # |
| 8 | # How: the branch is cut exactly like the original extraction (git fast-export limited to the |
| 9 | # CUDA++ paths, the same exclusions, into a scratch repository). The cut is deterministic, so |
| 10 | # every commit the branch shares with the Omega history CUDA++ was cut from comes out with the |
| 11 | # same id as here; the new commits sit on top. NEW_BRANCH = current HEAD merged with that cut, |
| 12 | # a normal three-way merge (it only has to reconcile what CUDA++ changed since, e.g. SPDX lines). |
| 13 | # |
| 14 | # Paths: every path in filemap.tsv, plus every src/omega_gpu_* and src/omega_blackwell_* file |
| 15 | # the branch adds (new GPU files), minus the Omega bridges in stay.txt, plus EXTRA_PATHSPEC. |
| 16 | # The Omega half of the same branch stays in Omega: rebase it on Omega's opencuda/consume and |
| 17 | # point cudapp.lock at NEW_BRANCH's tip. |
| 18 | set -euo pipefail |
| 19 | export LC_ALL=C |
| 20 | |
| 21 | omega=${1:?omega dir}; ref=${2:?omega ref}; new=${3:?new branch}; shift 3 |
| 22 | here=$(cd "$(dirname "$0")" && pwd) |
| 23 | top=$(git -C "$here" rev-parse --show-toplevel) |
| 24 | tip=$(git -C "$omega" rev-parse "$ref") |
| 25 | scratch=$(mktemp -d); trap 'rm -rf "$scratch"' EXIT |
| 26 | |
| 27 | mapfile -t paths < <(cut -f1 "$here/filemap.tsv") |
| 28 | mapfile -t added < <(git -C "$omega" ls-tree -r --name-only "$tip" -- src | grep -E '^src/omega_(gpu|blackwell)_' | |
| 29 | grep -vxF -f <(grep -v '^#' "$here/stay.txt" | grep .) | grep -vxF -f <(printf '%s\n' "${paths[@]}") || true) |
| 30 | paths+=("${added[@]}" "$@") |
| 31 | while IFS= read -r x; do [[ -n $x && $x != \#* ]] && paths+=(":(exclude)$x"); done < "$here/omega-exclude.txt" |
| 32 | ((${#added[@]})) && echo "new GPU files on $ref: ${added[*]}" |
| 33 | |
| 34 | git -C "$omega" update-ref refs/heads/cudapp-carry "$tip" |
| 35 | git init -q --bare "$scratch/cut.git" |
| 36 | git -C "$omega" fast-export --signed-tags=strip --tag-of-filtered-object=drop --reencode=yes \ |
| 37 | refs/heads/cudapp-carry -- -- "${paths[@]}" | git -C "$scratch/cut.git" fast-import --quiet |
| 38 | git -C "$omega" update-ref -d refs/heads/cudapp-carry |
| 39 | git -C "$top" fetch -q "$scratch/cut.git" "refs/heads/cudapp-carry:refs/carry/$new" |
| 40 | shared=$(git -C "$top" merge-base HEAD "refs/carry/$new" || true) |
| 41 | [[ -n $shared ]] || { echo "carry: the cut shares no commit with HEAD (was the branch cut with other paths?)" >&2; exit 1; } |
| 42 | echo "carry $ref ($(git -C "$omega" rev-parse --short "$tip")): $(git -C "$top" rev-list --count "$shared..refs/carry/$new") new commit(s) on top of $(git -C "$top" rev-parse --short "$shared")" |
| 43 | |
| 44 | git -C "$top" checkout -q -b "$new" |
| 45 | if ! git -C "$top" merge -q --no-ff --no-edit "refs/carry/$new" \ |
| 46 | -m "Carry Omega $ref ($tip) into CUDA++ (tools/extract/carry.sh)"; then |
| 47 | echo "CARRY CONFLICT on $new: resolve, then git commit (or git merge --abort)" >&2 |
| 48 | exit 1 |
| 49 | fi |
| 50 | echo "carried onto $new = $(git -C "$top" rev-parse --short HEAD)" |