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 / tests / tools-om / lib.sh

38 lines · 1972 bytes Raw Blame History
1# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2# Shared helpers for tests/tools-om/*.sh. Source after setting ROOT and tmp; the caller runs
3# under bwrap/taskset (see tests/tools-om/README.md). Every helper fails the script on a broken
4# expectation; nothing is skipped silently.
5OMC=${OMEGA_OMC:-$HOME/work/cudastack/omega-mv/seed/out/omc}
6BRIDGE=${OMEGA_BRIDGE:-$HOME/work/cudastack/omega-bridge}
7OMC_PIN=2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f
8CC=${CC:-cc}
9TOM_CFLAGS="-std=gnu11 -Wall -Wextra -Werror -D_GNU_SOURCE -O2 -ffp-contract=off -Isrc"
10
11tom_pin() {
12 [ "$(sha256sum < "$OMC" | cut -c1-64)" = "$OMC_PIN" ] || { echo "NOT_RUN: omc is not the pinned e5b32567 build"; exit 3; }
13}
14
15# tom_mutant NAME SRC SITE REPLACEMENT: copy SRC with the one line SITE replaced, compile it through the
16# pinned bridge to $tmp/NAME.c. SITE must occur exactly once, as a whole line.
17tom_mutant() {
18 name=$1 src=$2 site=$3 repl=$4
19 n=$(grep -c -x -F -- "$site" "$src" || true)
20 [ "$n" = 1 ] || { echo "FAIL mutant $name: site found $n times"; exit 1; }
21 awk -v s="$site" -v r="$repl" '$0 == s { print r; next } { print }' "$src" > "$tmp/$name.om"
22 OMEGA_SEEDED_OMC="$OMC" sh "$BRIDGE/tools/bridge-seeded" c "$tmp/$name.om" > "$tmp/$name.c"
23}
24
25# tom_flip ORACLE CANDIDATE: CANDIDATE matched ORACLE byte for byte. Write CANDIDATE.flip with the last
26# decimal digit of the last record changed and require the same cmp to reject it against ORACLE.
27tom_flip() {
28 cmp -s "$1" "$2" || { echo "FAIL negative control: $2 did not match $1 before the flip"; exit 1; }
29 python3 - "$2" "$2.flip" <<'PY'
30import sys
31b = bytearray(open(sys.argv[1], "rb").read())
32i = max(i for i, c in enumerate(b) if 48 <= c <= 57)
33b[i] = 48 + (b[i] - 48 + 1) % 10
34open(sys.argv[2], "wb").write(b)
35PY
36 if cmp -s "$1" "$2.flip"; then echo "FAIL negative control: flipped record not caught"; exit 1; fi
37 echo "negative control: flipped record caught ($(basename "$2"))"
38}