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
| 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | # Existing portable roots, explicitly composed as OM2 for caller-stack native ABI. |
| 4 | set -eu |
| 5 | ROOT=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd) |
| 6 | MODE=${1:---install} |
| 7 | OUT=${2:-$ROOT/build/no_posix} |
| 8 | mkdir -p "$OUT/sources" "$OUT/native" |
| 9 | for pair in encoder/bw_enc_sm121 cubin/cubin_elf numeric/no_bf16 session/admit session/words session/park cmdlist/book streams/streams apiviews/no_avbf; do |
| 10 | name=${pair##*/} |
| 11 | { printf 'om2\n'; cat "$ROOT/om/$pair.om"; } > "$OUT/sources/$name.om" |
| 12 | done |
| 13 | # Core encoder/codegen roots; the C implementations are explicit oracles in both profiles. |
| 14 | for name in regalloc regalloc_ir regalloc_live cg_matmul cg_matmul_params cg_matmul_i32 cg_matmul_tensor cg_matmul_loop cg_matmul_frag cg_matmul_block cg_vecadd cg_bind cg_pack_len; do |
| 15 | { printf 'om2\n'; cat "$ROOT/om/codegen/$name.om"; } > "$OUT/sources/$name.om" |
| 16 | done |
| 17 | for name in cg_pack_h cg_sentin; do |
| 18 | cp "$ROOT/om/codegen/$name.om" "$OUT/sources/$name.om" |
| 19 | done |
| 20 | { printf 'om2\n'; cat "$ROOT/om/cache/digest.om" "$ROOT/om/blackwell/identity.om" "$ROOT/om/blackwell/id_native.om"; } > "$OUT/sources/bw_identity.om" |
| 21 | set -- "$OUT/sources/regalloc.om" "$OUT/sources/regalloc_ir.om" "$OUT/sources/regalloc_live.om" \ |
| 22 | "$OUT/sources/cg_matmul.om" "$OUT/sources/cg_matmul_params.om" "$OUT/sources/cg_matmul_i32.om" \ |
| 23 | "$OUT/sources/cg_matmul_tensor.om" "$OUT/sources/cg_matmul_loop.om" \ |
| 24 | "$OUT/sources/cg_matmul_frag.om" "$OUT/sources/cg_matmul_block.om" "$OUT/sources/cg_vecadd.om" \ |
| 25 | "$OUT/sources/cg_bind.om" "$OUT/sources/cg_pack_len.om" "$OUT/sources/cg_pack_h.om" "$OUT/sources/cg_sentin.om" \ |
| 26 | "$OUT/sources/bw_identity.om" |
| 27 | # ham/cubin-qmd-om: additive QMD roots; cg_bind and bw_identity come from the core block above. |
| 28 | { printf 'om2\n'; cat "$ROOT/om/qmd/bw_qmd.om"; } > "$OUT/sources/bw_qmd.om" |
| 29 | { printf 'om2\n'; cat "$ROOT/om/encoder/amp_runtime.om" "$ROOT/om/encoder/amp_qmd.om"; } > "$OUT/sources/amp_qmd.om" |
| 30 | if [ "$MODE" = --install ]; then |
| 31 | case "$(uname -m)" in |
| 32 | aarch64) target=aarch64linux ;; |
| 33 | x86_64) target=x86linux ;; |
| 34 | *) echo 'unsupported NO_POSIX target' >&2; exit 2 ;; |
| 35 | esac |
| 36 | cp "$ROOT/om/no-posix/gen/$target/"* "$OUT/native/" |
| 37 | exit 0 |
| 38 | fi |
| 39 | case "$MODE" in --generate|--check|--tools) ;; *) exit 2 ;; esac |
| 40 | : "${OMEGA_BRIDGE:?set OMEGA_BRIDGE to the locked converter}" |
| 41 | : "${OMEGA_OMC:?set OMEGA_OMC to the pinned seeded compiler}" |
| 42 | [ "$(sha256sum < "$OMEGA_OMC" | cut -c1-64)" = 2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f ] |
| 43 | [ "$(sha256sum < "$OMEGA_BRIDGE/tools/native" | cut -c1-64)" = 14b2b51ed062ebaa7ea99e83752cc075452465b9ddba4939eb171692358ecb6b ] |
| 44 | [ "$(sha256sum < "$OMEGA_BRIDGE/src/native.om" | cut -c1-64)" = e2077722aaeffb1121b70160e22357ea47f369e0039ab1ea06dc700f6f4e45d7 ] |
| 45 | # Verification oracles are immutable compiler blobs from their published revisions. |
| 46 | # An ordinary portable build consumes only the checked generated sources. |
| 47 | repo=$(CDPATH= cd -- "$(dirname "$OMEGA_OMC")/../.." && pwd) |
| 48 | mkdir -p "$OUT/tools" |
| 49 | git -C "$repo" show e17039d9ceeb30e0637ef4145e37afc5821c3773:seed/out/omc > "$OUT/tools/omc-gen" |
| 50 | git -C "$repo" show 474197e4fa0207e0e2fb3c0494594a975f5031fa:seed/out/omc > "$OUT/tools/omc-x86" |
| 51 | chmod +x "$OUT/tools/omc-gen" "$OUT/tools/omc-x86" |
| 52 | export OMEGA_NATIVE_OMC="$OUT/tools/omc-gen" |
| 53 | export OMEGA_NATIVE_X86_OMC="$OUT/tools/omc-x86" |
| 54 | [ "$MODE" != --tools ] || exit 0 |
| 55 | for target in aarch64linux x86linux; do |
| 56 | case "$target" in aarch64linux) triple=aarch64-linux-gnu ;; x86linux) triple=x86_64-linux-gnu ;; esac |
| 57 | if command -v "$triple-gcc" >/dev/null 2>&1; then native_cc="$triple-gcc" |
| 58 | elif command -v clang >/dev/null 2>&1; then native_cc="clang --target=$triple -ffreestanding" |
| 59 | else echo "NO_POSIX regeneration requires $triple-gcc or clang" >&2; exit 2; fi |
| 60 | # ham/cubin-qmd-om: native argv roots; install-time sources are the earlier block. |
| 61 | CC="$native_cc" OMEGA_NATIVE_OMC2="$OMEGA_OMC" sh "$OMEGA_BRIDGE/tools/native" --target "$target" --freestanding "$OUT/$target" \ |
| 62 | "$OUT/sources/bw_enc_sm121.om" "$OUT/sources/cubin_elf.om" "$OUT/sources/no_bf16.om" \ |
| 63 | "$OUT/sources/bw_qmd.om" "$OUT/sources/amp_qmd.om" \ |
| 64 | "$OUT/sources/admit.om" "$OUT/sources/words.om" "$OUT/sources/park.om" "$OUT/sources/book.om" "$OUT/sources/streams.om" "$OUT/sources/no_avbf.om" "$@" |
| 65 | dest="$ROOT/om/no-posix/gen/$target" |
| 66 | if [ "$MODE" = --generate ]; then mkdir -p "$dest"; fi |
| 67 | for file in omega_native.c omega_native.h omega_api_decl.h omega_api_defs.c; do |
| 68 | if [ "$MODE" = --generate ]; then cp "$OUT/$target/$file" "$dest/$file" |
| 69 | else cmp "$OUT/$target/$file" "$dest/$file"; fi |
| 70 | done |
| 71 | done |
| 72 | echo 'PASS NO_POSIX checked native sources regenerate byte for byte (both ISAs)' |