interplane.Get Omega
Read in your language

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

branch main Branches Tags History

CUDApp / tools / c5 / build.sh

31 lines · 2008 bytes Raw Blame History
1#!/bin/sh
2# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3# C5 sharing (docs/OMEGA.md row C5): build what tools/c5/chip.sh runs.
4# build/gpu_isolation_test the imported test, unchanged (make target)
5# build/gpu_isolation_test_mutant the same source with one change made here, never committed: the chip work kernel
6# is codegen mutant 1 (out = 2x + tag + 1), so the chip values check must go red
7# build/c5_matrix tools/c5/c5_matrix.om compiled by the pinned seeded omc (tools/c5/omc.pin)
8# OMC=path skips the fetch of the pinned omc; its sha256 is checked either way.
9set -eu
10cd "$(dirname "$0")/../.."
11make build/gpu_isolation_test
12src=tests/gpu_isolation_test.c
13mut=build/gpu_isolation_test_mutant.c
14sed 's/if (codegen(hang, 0, &k->prog) != 0) return -1;/if (codegen(hang, 1, \&k->prog) != 0) return -1;/' "$src" > "$mut"
15[ "$(diff "$src" "$mut" | grep -c '^>')" -eq 1 ] || { echo "FAIL: the mutant edit did not apply exactly once" >&2; exit 1; }
16# the mutant compiles with the Makefile's own CC and CFLAGS, through a one-rule makefile on stdin
17printf '%s\n\t%s\n' 'build/gpu_isolation_test_mutant: build/gpu_isolation_test_mutant.c build/libomega_gpu.a' \
18 '$(CC) $(CFLAGS) -ffp-contract=off -Itests -o $@ $< build/libomega_gpu.a -lpthread -lm' |
19 make -f Makefile -f - build/gpu_isolation_test_mutant
20read -r repo sha path want < tools/c5/omc.pin
21if [ -z "${OMC:-}" ]; then
22 OMC=build/omc-pinned
23 curl -fsSL "https://raw.githubusercontent.com/$repo/$sha/$path" -o "$OMC"
24fi
25got=$(sha256sum "$OMC" | cut -d' ' -f1)
26[ "$got" = "$want" ] || { echo "FAIL: omc sha256 $got, pin $want" >&2; exit 1; }
27chmod +x "$OMC"
28"$OMC" < tools/c5/c5_matrix.om > build/c5_matrix 2> build/c5_matrix.err || { cat build/c5_matrix.err >&2; exit 1; }
29[ ! -s build/c5_matrix.err ] || { cat build/c5_matrix.err >&2; exit 1; }
30chmod +x build/c5_matrix
31sha256sum build/gpu_isolation_test build/gpu_isolation_test_mutant build/c5_matrix "$OMC"