blob: 867182c69f14ce386ad457c51c2ad36561e06a00 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause
#
# p2/build.sh - build the P2 "arbitrary CUDA kernels" acceptance programs.
#
# Target is sm_75 (Turing TU104) to match the project's GPU. The CUDA
# runtime is linked statically (--cudart=static) so the guest needs only the
# driver's libcuda.so, exactly like ab.sh/victory_mail.
#
# Usage: ./build.sh [program ...] (default: all programs)
set -e
HERE="$(cd "$(dirname "$0")" && pwd)"
NVCC="${NVCC:-nvcc}"
FLAGS="${P2_NVCC_FLAGS:--O2 -arch=sm_75 --cudart=static}"
command -v "$NVCC" >/dev/null || { echo "nvcc not found"; exit 1; }
mkdir -p "$HERE/bin"
build_one() {
local src="$HERE/src/$1.cu"
local bin="$HERE/bin/$1"
[ -f "$src" ] || { echo "[build] missing source: $src" >&2; return 1; }
echo "[build] $1"
# shellcheck disable=SC2086
"$NVCC" $FLAGS -I"$HERE/src" -o "$bin" "$src"
}
if [ "$#" -gt 0 ]; then
for p in "$@"; do build_one "$p"; done
else
for src in "$HERE"/src/p2_*.cu; do
build_one "$(basename "$src" .cu)"
done
fi
echo "[build] OK: $(ls "$HERE"/bin/p2_* 2>/dev/null | wc -l) program(s) in $HERE/bin"
|