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/native/aiengpu/units.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 / native / aiengpu / units.sh` 85 lines · 5209 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 # Regenerate the hosted aien-gpu effects unit (native/aiengpu/effects.om) through the bridge's context mode. 4 # 5 # native/aiengpu/units.sh pinned: bridge revision and hashes from src/cudapp_aiengpu_effects.ident, 6 # output into src/ (the committed generated C) 7 # native/aiengpu/units.sh --adopt take the bridge checkout's revision as the new pin (the checkout must be 8 # clean): output into src/ with that revision and its hashes in the .ident 9 # native/aiengpu/units.sh --candidate D [F] any bridge checkout, revision and hashes recorded as candidate: output 10 # into D only, never src/; F replaces effects.om (mutants, reproducibility) 11 # AArch64 only: the device-word compiler (omega-mv#1047, omc sha256 `b8f8f137`...) carries the aien-gpu 'A' devctl 12 # allowlist for aarch64linux; there is no x86 aien-gpu target. 13 set -eu 14 ROOT=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) 15 BRIDGE=${OMEGA_AIENGPU_BRIDGE:?set OMEGA_AIENGPU_BRIDGE to the hosted/context bridge with the aien-gpu mapping profile} 16 OMC=${OMEGA_NATIVE_OMC:?set OMEGA_NATIVE_OMC to the native generator compiler} 17 ARM=${OMEGA_NATIVE_OMC2:?set OMEGA_NATIVE_OMC2 to the AArch64 context compiler with the aien-gpu devctl words} 18 GEN_PIN=`734f0a39319fbfa930bcc62cb30dbf06d47d78e126372b74f5baf478e6126b61` 19 ARM_PIN=`b8f8f1371bc0303f8da02db8b754e085d5dd852620c8d8d676c5769c233d9195` 20 SRC=native/aiengpu/effects.om 21 SRCFILE=$ROOT/$SRC 22 hash() { sha256sum < "$1" | cut -d' ' -f1; } 23 require_hash() { 24 [ -n "$2" ] && [ "$(hash "$1")" = "$2" ] || { echo "NOT_RUN: aien-gpu effects pin mismatch: $1" >&2; exit 3; } 25 } 26 DEST=$ROOT/src 27 if [ "${1:-}" = "--candidate" ]; then 28 DEST=${2:?--candidate needs an output directory} 29 if [ -n "${3:-}" ]; then SRCFILE=$(CDPATH= cd -- "$(dirname "$3")" && pwd)/$(basename "$3"); SRC=$3; fi 30 mkdir -p "$DEST" 31 case $(CDPATH= cd -- "$DEST" && pwd) in 32 "$ROOT/src" | "$ROOT"/src/*) echo "units.sh: a candidate never writes into src/" >&2; exit 2 ;; 33 esac 34 bridge_pin=candidate-$(git -C "$BRIDGE" rev-parse HEAD 2>/dev/null || echo unrevisioned) 35 native_pin=$(hash "$BRIDGE/src/native.om") 36 tool_pin=$(hash "$BRIDGE/tools/native") 37 elif [ "${1:-}" = "--adopt" ]; then 38 [ -z "$(git -C "$BRIDGE" status --porcelain)" ] || { echo "units.sh: --adopt needs a clean bridge checkout" >&2; exit 2; } 39 bridge_pin=$(git -C "$BRIDGE" rev-parse HEAD) 40 native_pin=$(hash "$BRIDGE/src/native.om") 41 tool_pin=$(hash "$BRIDGE/tools/native") 42 else 43 IDENT=$ROOT/src/cudapp_aiengpu_effects.ident 44 [ -f "$IDENT" ] || { echo "NOT_RUN: no pinned aien-gpu bridge yet ($IDENT); use --candidate" >&2; exit 3; } 45 bridge_pin= native_pin= tool_pin= 46 set -f 47 for field in $(cat "$IDENT"); do 48 case "$field" in 49 bridge=*) bridge_pin=${field#bridge=} ;; 50 bridge_native=*) native_pin=${field#bridge_native=} ;; 51 bridge_tool=*) tool_pin=${field#bridge_tool=} ;; 52 esac 53 done 54 set +f 55 [ -n "$bridge_pin" ] && [ "$(git -C "$BRIDGE" rev-parse HEAD)" = "$bridge_pin" ] || { 56 echo "NOT_RUN: aien-gpu effects bridge revision mismatch" >&2; exit 3; 57 } 58 require_hash "$BRIDGE/src/native.om" "$native_pin" 59 require_hash "$BRIDGE/tools/native" "$tool_pin" 60 fi 61 require_hash "$OMC" "$GEN_PIN" 62 require_hash "$ARM" "$ARM_PIN" 63 case $(uname -m) in 64 aarch64) ARM_CC=${OMEGA_AIENGPU_CC_AARCH64:-cc} ;; 65 x86_64) ARM_CC=${OMEGA_AIENGPU_CC_AARCH64:-aarch64-linux-gnu-gcc} ;; 66 *) echo "NOT_RUN: aien-gpu effects generation needs Linux AArch64 or an AArch64 cross compiler" >&2; exit 3 ;; 67 esac 68 T=$(mktemp -d) 69 trap 'rm -rf "$T"' EXIT 70 export OMEGA_NATIVE_OMC OMEGA_NATIVE_OMC2 71 CC="$ARM_CC" "$BRIDGE/tools/native" --host --target aarch64linux "$T/arm" "$SRCFILE" 72 { 73 printf '/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */\n/* Generated by native/aiengpu/units.sh; do not edit. */\n#if defined(__aarch64__)\n' 74 cat "$T/arm/omega_native.c" 75 printf '\n#else\n#error "the aien-gpu effects are generated for Linux AArch64 only"\n#endif\n' 76 } > "$T/cudapp_aiengpu_effects.c" 77 { 78 printf '/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */\n/* Generated by native/aiengpu/units.sh; do not edit. */\n#ifndef CUDAPP_AIENGPU_NATIVE_H\n#define CUDAPP_AIENGPU_NATIVE_H\n#if defined(__aarch64__)\n' 79 cat "$T/arm/omega_native.h" 80 printf '\n#else\n#error "the aien-gpu effects are generated for Linux AArch64 only"\n#endif\n#endif\n' 81 } > "$T/cudapp_aiengpu_native.h" 82 printf '%s\n' "omega-native-ident 1 unit=aiengpu_effects path=$SRC bridge=$bridge_pin bridge_native=$native_pin bridge_tool=$tool_pin omc_generator=$GEN_PIN omc_aarch64=$ARM_PIN src=$(hash "$SRCFILE") c=$(hash "$T/cudapp_aiengpu_effects.c") h=$(hash "$T/cudapp_aiengpu_native.h")" > "$T/cudapp_aiengpu_effects.ident" 83 mkdir -p "$DEST" 84 cp "$T/cudapp_aiengpu_effects.c" "$T/cudapp_aiengpu_native.h" "$T/cudapp_aiengpu_effects.ident" "$DEST/" 85 printf 'AIEN-GPU EFFECTS GENERATION PASS (%s, AArch64, omc %.8s, bridge %s)\n' "$DEST" "$ARM_PIN" "$bridge_pin"