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

92 lines · 3055 bytes Raw Blame History
1#!/bin/sh
2# Ten killed mutants. Each site is unique in its unit. A mutant that still
3# prints PASS fails the gate. The .om edit is restored before the binary
4# runs. Regeneration goes to a temp DEST so src/ stays clean.
5# Compile is unwrapped; the mutant binary runs under bwrap.
6set -eu
7OUT=${1:?out}
8OMC=${2:?omc}
9BRIDGE=${3:?bridge}
10ROOT=${4:?root}
11BWRAP="bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10"
12CC=${CC:-cc}
13AV="bf16 e4m3 ewarg fp8am fp8en fp8q fp8sc gdnch gdnsc gdnsl rope scan widen gdnex gdnpt gdnut fp8x fp8xb"
14restore=""
15
16cleanup() {
17 if [ -n "$restore" ] && [ -f "$restore.bak" ]; then
18 mv "$restore.bak" "$restore"
19 fi
20}
21trap cleanup EXIT
22
23run_one() {
24 name=$1
25 file=$2
26 old=$3
27 new=$4
28 src="$ROOT/om/apiviews/$file"
29 if ! grep -F -q "$old" "$src"; then
30 echo "FAIL mutant $name: site missing"
31 exit 1
32 fi
33 n=$(grep -F -c "$old" "$src")
34 if [ "$n" != 1 ]; then
35 echo "FAIL mutant $name: site found $n times"
36 exit 1
37 fi
38 cp "$src" "$src.bak"
39 restore=$src
40 sed -i "s|$old|$new|" "$src"
41 dest=$(mktemp -d)
42 if ! OMEGA_OMC="$OMC" OMEGA_BRIDGE="$BRIDGE" \
43 OMEGA_UNITS_DEST="$dest" sh "$ROOT/om/units.sh" >/tmp/apiviews-mutant-$name.log 2>&1; then
44 echo "FAIL mutant $name: regen rc $?"
45 cat /tmp/apiviews-mutant-$name.log
46 rm -rf "$dest"
47 exit 1
48 fi
49 mv "$src.bak" "$src"
50 restore=""
51 srcs=""
52 for u in $AV; do
53 if [ "$u" = "${file%.om}" ]; then
54 srcs="$srcs $dest/cudapp_om_av_$u.c"
55 else
56 srcs="$srcs $ROOT/src/cudapp_om_av_$u.c"
57 fi
58 done
59 bin=$OUT/mutant-$name
60 if ! $CC -std=c11 -Wall -Wno-unused-function -I"$ROOT/src" -ffp-contract=off -O0 \
61 -DCUDAPP_MIGRATION_PENDING_APIVIEWS_DIFF \
62 -o "$bin" "$ROOT/tests/apiviews_host_test.c" $srcs "$ROOT/src/omega_gpu_hostmath.c" "$ROOT/src/cudapp_om_core_hostmath.c" -lm; then
63 echo "KILLED mutant $name: compile refused"
64 rm -rf "$dest"
65 return 0
66 fi
67 set +e
68 $BWRAP "$bin" >"$dest/out" 2>"$dest/err"
69 rc=$?
70 set -e
71 if [ "$rc" -eq 0 ] && grep -q '^PASS apiviews host' "$dest/out"; then
72 echo "FAIL mutant $name: still PASS"
73 cat "$dest/out" "$dest/err"
74 rm -rf "$dest"
75 exit 1
76 fi
77 echo "KILLED mutant $name rc $rc"
78 rm -rf "$dest"
79}
80
81mkdir -p "$OUT"
82run_one e4m3 e4m3.om 'if gt code 126' 'if gt code 64'
83run_one scan scan.om 'if and eq a 0.0f32 eq b 0.0f32' 'if and eq a 1.0f32 eq b 0.0f32'
84run_one fp8q fp8q.om 'if gt n 128' 'if gt n 64'
85run_one ewarg ewarg.om 'if gt p0 2048' 'if gt p0 8'
86run_one gdnch gdnch.om 'ret add mul hk 128 s' 'ret add mul hk 128 add s 1'
87run_one gdnex gdnex.om 'put ng i neg f32 av_exp1 f64 get a i' 'put ng i f32 av_exp1 f64 get a i'
88run_one gdnpt gdnpt.om 'put dst add base 3 0.0f32' 'put dst add base 3 1.0f32'
89run_one gdnut gdnut.om 'if eq rem hh div vh 16 0' 'if eq rem hh div vh 16 1'
90run_one fp8x fp8x.om 'fold = bitcast f32 uint 1602224128' 'fold = bitcast f32 uint 1065353216'
91run_one fp8xb fp8xb.om 'fold = bitcast f32 uint 1602224128' 'fold = bitcast f32 uint 1065353216'
92echo "PASS 10 mutants killed"