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 / compat / cuda / build.sh
| 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | # Rebuild the v3 Omega-default fixture identity; v1/v2 profiles remain frozen. |
| 4 | # Usage: compat/cuda/build.sh OUTDIR |
| 5 | # Host only. Nothing here opens /dev/nvidia*, loads libcuda, or runs the executables. |
| 6 | # The link uses a link-only stub libcuda.so.1 generated from the object's own undefined cu* symbols |
| 7 | # (every symbol defined as 0, no code); it is a link-time placeholder, never a runtime library. |
| 8 | # cuda.h is read from the local CUDA install (CUDA_INC) and is never committed (PROVENANCE.md 3.3). |
| 9 | set -eu |
| 10 | here=$(cd "$(dirname "$0")" && pwd) |
| 11 | out=${1:?usage: build.sh OUTDIR} |
| 12 | CUDA_INC=${CUDA_INC:-/usr/local/cuda/include} |
| 13 | mkdir -p "$out" |
| 14 | out=$(cd "$out" && pwd) |
| 15 | cp "$here/fixture/vadd_u32.ptx" "$out/vadd_u32.ptx" |
| 16 | build_one() { |
| 17 | isa=$1 |
| 18 | cc=$2 |
| 19 | d="$out/$isa" |
| 20 | rm -rf "$d" |
| 21 | mkdir -p "$d" |
| 22 | # Keep the source path so its private Omega ABI header resolves identically. |
| 23 | ( |
| 24 | cd "$d" |
| 25 | "$cc" -std=c11 -O2 -fno-ident -ffile-prefix-map="$d"=. -I"$CUDA_INC" -c "$here/fixture/vadd_drv.c" -o vadd_drv.o |
| 26 | "$cc" -std=c11 -O2 -ffp-contract=off -fno-ident -c "$here/../../src/cudapp_om_standalone_oracles.c" -o standalone_oracles.o |
| 27 | defs=$(nm -u vadd_drv.o | awk '$2 ~ /^cu/ {printf " -Wl,--defsym,%s=0", $2}') |
| 28 | printf '' | "$cc" -x c -c - -o empty.o |
| 29 | # shellcheck disable=SC2086 |
| 30 | "$cc" -shared -nostdlib -o libcuda.so.1 -Wl,-soname,libcuda.so.1 empty.o $defs |
| 31 | "$cc" -o vadd_drv vadd_drv.o standalone_oracles.o -L. -l:libcuda.so.1 |
| 32 | rm -f empty.o |
| 33 | ) |
| 34 | echo "built $isa $(sha256sum "$d/vadd_drv" | cut -d' ' -f1)" |
| 35 | } |
| 36 | build_one aarch64 "${CC_AARCH64:-gcc}" |
| 37 | build_one x86_64 "${CC_X86_64:-x86_64-linux-gnu-gcc}" |
| 38 | echo "built ptx $(sha256sum "$out/vadd_u32.ptx" | cut -d' ' -f1)" |