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 / om_qmd_mutants.sh

54 lines · 2037 bytes Raw Blame History
1#!/bin/sh
2# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3# Recompile seven semantic mutants of om/qmd/bw_qmd.om. Each must fail the sweep.
4# Host only. Needs OMEGA_OMC (pinned e5b32567) and OMEGA_BRIDGE.
5set -eu
6ROOT=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
7OMC=${OMEGA_OMC:-$HOME/work/cudastack/omega-mv/seed/out/omc}
8BRIDGE=${OMEGA_BRIDGE:-$HOME/work/cudastack/omega-bridge}
9SRC=$ROOT/om/qmd/bw_qmd.om
10OUT=$ROOT/build/om-qmd/mutants
11mkdir -p "$OUT"
12killed=0
13run_one() {
14 name=$1
15 from=$2
16 to=$3
17 cp "$SRC" "$OUT/$name.om"
18 # The from-string must occur once. grep -c counts lines.
19 n=$(grep -c -F "$from" "$OUT/$name.om")
20 if [ "$n" != 1 ]; then
21 echo "FAIL $name site count $n"
22 exit 1
23 fi
24 # Replace the one site. python keeps the rest byte-stable.
25 python3 - "$OUT/$name.om" "$from" "$to" <<'PY'
26import pathlib, sys
27path, old, new = sys.argv[1:]
28text = pathlib.Path(path).read_text()
29pathlib.Path(path).write_text(text.replace(old, new, 1))
30PY
31 OMEGA_SEEDED_OMC="$OMC" sh "$BRIDGE/tools/bridge-seeded" c "$OUT/$name.om" > "$OUT/$name.c"
32 gcc -std=gnu11 -O2 -Wall -Wextra -Werror -I"$ROOT/src" -o "$OUT/$name" \
33 "$ROOT/tests/om_qmd_sweep_test.c" "$ROOT/src/omega_blackwell_qmd.c" "$OUT/$name.c"
34 set +e
35 # The caller runs this script under the bwrap/taskset wrapper; a nested bwrap
36 # can fail to create namespaces, and that failure would read as a kill.
37 "$OUT/$name" >"$OUT/$name.out" 2>"$OUT/$name.err"
38 rc=$?
39 set -e
40 if [ "$rc" = 0 ]; then
41 echo "SURVIVED $name"
42 exit 1
43 fi
44 echo "KILLED $name rc=$rc"
45 killed=$((killed + 1))
46}
47run_one m_qmd0_w4 'put q 4 8388610' 'put q 4 8388611'
48run_one m_qmd1_w4 'put q 4 20905984' 'put q 4 20905985'
49run_one m_qmd1_w14 'put q 14 793772964' 'put q 14 793772965'
50run_one m_qmd1_offset 'put q 14 793772964' 'put q 13 793772964'
51run_one m_cbank_w0 'put q 0 641859584' 'put q 0 641859585'
52run_one m_cbank_w223 'put q 223 16776640' 'put q 223 16776641'
53run_one m_shared_cap 'if gt sm 32768' 'if gt sm 16384'
54echo "PASS $killed mutants killed"