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 / platform-linux / gen_effects.sh
| 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | # Regenerates om/platform-linux/gen/*.c from the platform .om units. |
| 4 | # Output is not src/cudapp_om_*.c: that glob is one link, and each generated |
| 5 | # runtime defines omega_native_context_create. Callers compile these with |
| 6 | # -D renames (mk/platform-linux.mk). Needs the retire-compiler pair and |
| 7 | # BridgeX86 tools/native. The pinned CUDApp omc rejects cpufence and mapget. |
| 8 | set -eu |
| 9 | ROOT=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) |
| 10 | BRIDGE=${CUDAPP_EFFECTS_BRIDGE:-/home/drakestapleton/work/cudastack/lanes/BridgeX86} |
| 11 | X86_OMC=${OMEGA_NATIVE_X86_OMC:-/home/drakestapleton/work/cudastack/lanes/omega-mv-x86/seed/out/omc} |
| 12 | X86_CC=${OMEGA_NATIVE_X86_CC:-x86_64-linux-gnu-gcc} |
| 13 | OMC2=${OMEGA_NATIVE_OMC2:-/home/drakestapleton/work/cudastack/lanes/omega-mv-bh-retire/seed/out/omc} |
| 14 | OMC=${OMEGA_NATIVE_OMC:-/home/drakestapleton/work/cudastack/lanes/omega-mv-c6/seed/out/omc} |
| 15 | GEN="$ROOT/om/platform-linux/gen" |
| 16 | mkdir -p "$GEN" |
| 17 | export OMEGA_NATIVE_OMC2="$OMC2" OMEGA_NATIVE_OMC="$OMC" OMEGA_NATIVE_X86_OMC="$X86_OMC" |
| 18 | one() { |
| 19 | name=$1 |
| 20 | src=$2 |
| 21 | T=$(mktemp -d) |
| 22 | "$BRIDGE/tools/native" --host --target aarch64linux "$T/arm" "$src" |
| 23 | CC="$X86_CC" "$BRIDGE/tools/native" --host --target x86linux "$T/x86" "$src" |
| 24 | { |
| 25 | printf '/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */\n/* Generated by om/platform-linux/gen_effects.sh; do not edit. */\n#if defined(__aarch64__)\n' |
| 26 | cat "$T/arm/omega_native.c" |
| 27 | printf '\n#elif defined(__x86_64__)\n' |
| 28 | cat "$T/x86/omega_native.c" |
| 29 | printf '\n#else\n#error "platform omega units require Linux AArch64 or x86-64"\n#endif\n' |
| 30 | } > "$GEN/$name.c" |
| 31 | { |
| 32 | printf '/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */\n/* Generated by om/platform-linux/gen_effects.sh; do not edit. */\n#ifndef CUDAPP_PLAT_%s_H\n#define CUDAPP_PLAT_%s_H\n#include <stdint.h>\n#if defined(__aarch64__)\n' "$name" "$name" |
| 33 | cat "$T/arm/omega_native.h" |
| 34 | printf '\n#elif defined(__x86_64__)\n' |
| 35 | cat "$T/x86/omega_native.h" |
| 36 | printf '\n#else\n#error "platform omega units require Linux AArch64 or x86-64"\n#endif\n#endif\n' |
| 37 | } > "$GEN/$name.h" |
| 38 | rm -rf "$T" |
| 39 | } |
| 40 | one plat_effects "$ROOT/om/platform-linux/plat_effects.om" |
| 41 | one plat_wait "$ROOT/om/platform-linux/plat_wait.om" |
| 42 | # The carried test-platform-linux-wait mutant: the 2^31 deadline bound replaced by 0. |
| 43 | # Committed like the units above, so the gate compiles it without these compilers. |
| 44 | MT=$(mktemp -d) |
| 45 | grep -q 2147483648 "$ROOT/om/platform-linux/plat_wait.om" |
| 46 | sed 's/2147483648/0/' "$ROOT/om/platform-linux/plat_wait.om" > "$MT/plat_wait_mutant.om" |
| 47 | ! grep -q 2147483648 "$MT/plat_wait_mutant.om" |
| 48 | one plat_wait_mutant "$MT/plat_wait_mutant.om" |
| 49 | rm -rf "$MT" |
| 50 | rename() { |
| 51 | src=$1 |
| 52 | dst=$2 |
| 53 | p=$3 |
| 54 | # Symbols immediately following an escaped newline have no regex word boundary. |
| 55 | sed -e "s/ombr_enter/${p}_ombr_enter/g" \ |
| 56 | -e "s/ombr_trap/${p}_ombr_trap/g" \ |
| 57 | -e "s/ombr_no_entry/${p}_ombr_no_entry/g" \ |
| 58 | -e "s/\\bomega_native_context_create\\b/${p}_context_create/g" \ |
| 59 | -e "s/\\bomega_native_context_destroy\\b/${p}_context_destroy/g" \ |
| 60 | "$src" > "$dst" |
| 61 | } |
| 62 | mkdir -p "$GEN/link" |
| 63 | rename "$GEN/plat_effects.c" "$GEN/link/plat_fx_effects.c" plat_fx |
| 64 | rename "$GEN/plat_wait.c" "$GEN/link/plat_fx_wait.c" plat_wt |
| 65 | echo "PASS platform effects generation" |