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 / om / native-freest.sh
| 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | # Regenerate src/cudapp_freest_pathcopy.c from om/components/pathcopy.om. |
| 4 | # The committed .c is the artifact. This script is the regeneration path, not a build step. |
| 5 | # AArch64 and x86-64 halves are selected by the compiler; only one is compiled. |
| 6 | set -eu |
| 7 | ROOT=$(cd "$(dirname "$0")/.." && pwd) |
| 8 | OMC_PIN=734f0a39319fbfa930bcc62cb30dbf06d47d78e126372b74f5baf478e6126b61 |
| 9 | OMC2_PIN=2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f |
| 10 | X86_PIN=be8c51301307555254fc59e351d281aae1aa096d91521777e33a41c8b446448a |
| 11 | NATIVE_PIN=14b2b51ed062ebaa7ea99e83752cc075452465b9ddba4939eb171692358ecb6b |
| 12 | UNIT=${PATHCOPY_UNIT:-$ROOT/om/components/pathcopy.om} |
| 13 | DEST=${PATHCOPY_DEST:-$ROOT/src/cudapp_freest_pathcopy.c} |
| 14 | BRIDGE=${OMEGA_BRIDGE:?set OMEGA_BRIDGE to the stage-5 omega-bridge checkout} |
| 15 | OMC=${OMEGA_NATIVE_OMC:?set OMEGA_NATIVE_OMC to the #72 generator omc} |
| 16 | OMC2=${OMEGA_NATIVE_OMC2:?set OMEGA_NATIVE_OMC2 to the OM-2 compiler e5b32567} |
| 17 | X86=${OMEGA_NATIVE_X86_OMC:?set OMEGA_NATIVE_X86_OMC to the x86 OM-2 compiler} |
| 18 | [ "$(sha256sum < "$OMC" | cut -c1-64)" = "$OMC_PIN" ] || { echo "NOT_RUN: generator omc is not the #72 pin"; exit 3; } |
| 19 | [ "$(sha256sum < "$OMC2" | cut -c1-64)" = "$OMC2_PIN" ] || { echo "NOT_RUN: OM-2 omc is not e5b32567"; exit 3; } |
| 20 | [ "$(sha256sum < "$X86" | cut -c1-64)" = "$X86_PIN" ] || { echo "NOT_RUN: x86 omc is not the #72 pin"; exit 3; } |
| 21 | [ "$(sha256sum < "$BRIDGE/tools/native" | cut -c1-64)" = "$NATIVE_PIN" ] || { echo "NOT_RUN: tools/native is not the stage-5 frontend"; exit 3; } |
| 22 | T=$(mktemp -d) |
| 23 | trap 'rm -rf "$T"' EXIT |
| 24 | mkdir -p "$T/a64" "$T/x86" |
| 25 | export OMEGA_NATIVE_OMC="$OMC" OMEGA_NATIVE_OMC2="$OMC2" OMEGA_NATIVE_X86_OMC="$X86" |
| 26 | if [ "${PATHCOPY_ARCH:-both}" = both ] || [ "${PATHCOPY_ARCH:-both}" = a64 ]; then |
| 27 | CC=aarch64-linux-gnu-gcc sh "$BRIDGE/tools/native" --freestanding --target aarch64linux "$T/a64" "$UNIT" |
| 28 | fi |
| 29 | if [ "${PATHCOPY_ARCH:-both}" = both ] || [ "${PATHCOPY_ARCH:-both}" = x86 ]; then |
| 30 | CC=x86_64-linux-gnu-gcc sh "$BRIDGE/tools/native" --freestanding --target x86linux "$T/x86" "$UNIT" |
| 31 | fi |
| 32 | |
| 33 | { |
| 34 | printf '%s\n' '/* Generated by om/native-freest.sh from om/components/pathcopy.om.' |
| 35 | printf '%s\n' ' * omega-bridge tools/native --freestanding (stage-5 converter). Do not edit.' |
| 36 | printf '%s\n' ' * AArch64 and x86-64 only. The unused half is not compiled. */' |
| 37 | printf '%s\n' '#if defined(__aarch64__)' |
| 38 | if [ -f "$T/a64/omega_native.c" ]; then cat "$T/a64/omega_native.c"; else printf '%s\n' '#error pathcopy aarch64 half was not generated'; fi |
| 39 | printf '%s\n' '#elif defined(__x86_64__)' |
| 40 | if [ -f "$T/x86/omega_native.c" ]; then cat "$T/x86/omega_native.c"; else printf '%s\n' '#error pathcopy x86-64 half was not generated'; fi |
| 41 | printf '%s\n' '#else' |
| 42 | printf '%s\n' '#error pathcopy freestanding binding is aarch64 or x86-64 only' |
| 43 | printf '%s\n' '#endif' |
| 44 | } > "$DEST" |
| 45 | echo "WROTE $DEST" |