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/nvrm/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 / nvrm / units.sh` 64 lines · 3863 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 # Regenerate both hosted instruction streams; portable wire units use om/units.sh. 4 set -eu 5 ROOT=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) 6 BRIDGE=${OMEGA_NVRM_BRIDGE:?set OMEGA_NVRM_BRIDGE to the pinned hosted/context bridge} 7 OMC=${OMEGA_NATIVE_OMC:?set OMEGA_NATIVE_OMC to the native generator compiler} 8 ARM=${OMEGA_NATIVE_OMC2:?set OMEGA_NATIVE_OMC2 to the AArch64 context compiler} 9 X86=${OMEGA_NATIVE_X86_OMC:?set OMEGA_NATIVE_X86_OMC to the hosted x86 compiler} 10 GEN_PIN=`734f0a39319fbfa930bcc62cb30dbf06d47d78e126372b74f5baf478e6126b61` 11 ARM_PIN=`d1a3047153e14676c4baf9248fa2b88bb1b68c37cfeb71d76f30f5230c7d2765` 12 X86_PIN=`cf4fcbbb4752c5dd0652b426c0f2d08f82e380e8fc6f5114acf51a4c077bb579` 13 IDENT=$ROOT/src/cudapp_om_nvrm_transport.ident 14 bridge_pin= native_pin= tool_pin= 15 set -f 16 for field in $(cat "$IDENT"); do 17 case "$field" in 18 bridge=*) bridge_pin=${field#bridge=} ;; 19 bridge_native=*) native_pin=${field#bridge_native=} ;; 20 bridge_tool=*) tool_pin=${field#bridge_tool=} ;; 21 esac 22 done 23 set +f 24 hash() { sha256sum < "$1" | cut -d' ' -f1; } 25 require_hash() { 26 [ -n "$2" ] && [ "$(hash "$1")" = "$2" ] || { 27 echo "NOT_RUN: native NVRM pin mismatch: $1" >&2; exit 3; 28 } 29 } 30 [ -n "$bridge_pin" ] && [ "$(git -C "$BRIDGE" rev-parse HEAD)" = "$bridge_pin" ] || { 31 echo "NOT_RUN: native NVRM bridge revision mismatch" >&2; exit 3; 32 } 33 require_hash "$BRIDGE/src/native.om" "$native_pin" 34 require_hash "$BRIDGE/tools/native" "$tool_pin" 35 require_hash "$OMC" "$GEN_PIN" 36 require_hash "$ARM" "$ARM_PIN" 37 require_hash "$X86" "$X86_PIN" 38 case $(uname -m) in 39 aarch64) ARM_CC=${OMEGA_NVRM_CC_AARCH64:-cc}; X86_CC=${OMEGA_NVRM_CC_X86:-x86_64-linux-gnu-gcc} ;; 40 x86_64) ARM_CC=${OMEGA_NVRM_CC_AARCH64:-aarch64-linux-gnu-gcc}; X86_CC=${OMEGA_NVRM_CC_X86:-cc} ;; 41 *) echo "NOT_RUN: native NVRM generation needs Linux AArch64/x86-64 cross compilers" >&2; exit 3 ;; 42 esac 43 T=$(mktemp -d) 44 trap 'rm -rf "$T"' EXIT 45 export OMEGA_NATIVE_OMC OMEGA_NATIVE_OMC2 OMEGA_NATIVE_X86_OMC 46 CC="$ARM_CC" "$BRIDGE/tools/native" --host --target aarch64linux "$T/arm" "$ROOT/native/nvrm/transport.om" "$ROOT/native/streams/submit.om" 47 CC="$X86_CC" "$BRIDGE/tools/native" --host --target x86linux "$T/x86" "$ROOT/native/nvrm/transport.om" "$ROOT/native/streams/submit.om" 48 { 49 printf '/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */\n/* Generated by native/nvrm/units.sh; do not edit. */\n#if defined(__aarch64__)\n' 50 cat "$T/arm/omega_native.c" 51 printf '\n#elif defined(__x86_64__)\n' 52 cat "$T/x86/omega_native.c" 53 printf '\n#else\n#error "NVRM hosted transport requires Linux AArch64 or x86-64"\n#endif\n' 54 } > "$T/cudapp_om_nvrm_transport.c" 55 { 56 printf '/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */\n/* Generated by native/nvrm/units.sh; do not edit. */\n#ifndef CUDAPP_NVRM_NATIVE_H\n#define CUDAPP_NVRM_NATIVE_H\n#if defined(__aarch64__)\n' 57 cat "$T/arm/omega_native.h" 58 printf '\n#elif defined(__x86_64__)\n' 59 cat "$T/x86/omega_native.h" 60 printf '\n#else\n#error "NVRM hosted transport requires Linux AArch64 or x86-64"\n#endif\n#endif\n' 61 } > "$T/cudapp_nvrm_native.h" 62 printf '%s\n' "omega-native-ident 1 unit=nvrm_transport path=native/nvrm/transport.om+native/streams/submit.om bridge=$bridge_pin bridge_native=$native_pin bridge_tool=$tool_pin omc_generator=$GEN_PIN omc_aarch64=$ARM_PIN omc_x86=$X86_PIN src=$(cat "$ROOT/native/nvrm/transport.om" "$ROOT/native/streams/submit.om" | sha256sum | cut -d" " -f1) c=$(hash "$T/cudapp_om_nvrm_transport.c") h=$(hash "$T/cudapp_nvrm_native.h")" > "$T/cudapp_om_nvrm_transport.ident" 63 cp "$T/cudapp_om_nvrm_transport.c" "$T/cudapp_nvrm_native.h" "$T/cudapp_om_nvrm_transport.ident" "$ROOT/src/" 64 printf 'NVRM NATIVE GENERATION PASS (AArch64+x86-64, pinned context compilers and bridge)\n'