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

85 lines · 3652 bytes Raw Blame History
1#!/bin/sh
2# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3# own30b_prof acceptance: self-tests of both builds, differential against the C oracle
4# (-DCUDAPP_MIGRATION_PENDING_C_TOOLS_OWN30B), a flipped-record negative control and eight recompiled
5# mutants of om/tools/own30b_prof.om. TOOLS_OM_COVERAGE=DIR also writes gcov branch data of the oracle.
6# Run under: bwrap --dev-bind / / --dev /dev --proc /proc -- taskset -c 10-14 nice -n 10
7set -eu
8ROOT=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd)
9cd "$ROOT"
10tmp=$(mktemp -d)
11trap 'rm -rf "$tmp"' EXIT
12. tests/tools-om/lib.sh
13tom_pin
14OM=om/tools/own30b_prof.om
15DRV=tests/tools-om/own30b_diff.c
16OFF=-DCUDAPP_MIGRATION_PENDING_C_TOOLS_OWN30B
17# seed tokens mutations-per-mille: heavy mutation, light mutation, clean past the 4096-token table, mixed past it.
18CONFIGS="1:40:400 2:300:3 3:4200:0 4:4300:1 5:600:30 6:2:1000"
19
20$CC $TOM_CFLAGS -DOWN30B_PROFILE_TEST $OFF -o "$tmp/test_c" tools/own30b_decode_profile.c
21$CC $TOM_CFLAGS -DOWN30B_PROFILE_TEST -o "$tmp/test_om" tools/own30b_decode_profile.c src/cudapp_om_own30b_prof.c
22"$tmp/test_c" | sed 's/^/oracle: /'
23"$tmp/test_om" | sed 's/^/omega: /'
24$CC $TOM_CFLAGS $OFF -o "$tmp/diff_c" $DRV
25$CC $TOM_CFLAGS -o "$tmp/diff_om" $DRV src/cudapp_om_own30b_prof.c
26
27run_all() { # BIN PREFIX
28 for cfg in $CONFIGS; do
29 IFS=: read -r s t m <<EOF
30$cfg
31EOF
32 "$1" "$s" "$t" "$m" > "$2.$s.out" 2> "$2.$s.err"
33 done
34}
35run_all "$tmp/diff_c" "$tmp/c"
36run_all "$tmp/diff_om" "$tmp/om"
37for cfg in $CONFIGS; do
38 s=${cfg%%:*}
39 cmp "$tmp/c.$s.out" "$tmp/om.$s.out"
40 cmp "$tmp/c.$s.err" "$tmp/om.$s.err"
41 echo "differential seed $s: identical ($(tail -n 1 "$tmp/c.$s.out"), $(head -n 1 "$tmp/c.$s.err" | sed 's/.*\(tokens=.*\)/\1/'), $(wc -l < "$tmp/c.$s.out") classifications)"
42done
43tom_flip "$tmp/c.3.err" "$tmp/om.3.err"
44
45killed=0
46mut() { # NAME SITE REPLACEMENT
47 tom_mutant "$1" $OM "$2" "$3"
48 $CC $TOM_CFLAGS -o "$tmp/$1.bin" $DRV "$tmp/$1.c"
49 run_all "$tmp/$1.bin" "$tmp/$1" || true
50 for cfg in $CONFIGS; do
51 s=${cfg%%:*}
52 if ! cmp -s "$tmp/c.$s.out" "$tmp/$1.$s.out" || ! cmp -s "$tmp/c.$s.err" "$tmp/$1.$s.err"; then
53 echo "mutant $1: killed (seed $s)"; killed=$((killed + 1)); return 0
54 fi
55 done
56 echo "FAIL mutant $1 survived"; exit 1
57}
58mut expect 'if lt pos 288' 'if lt pos 287'
59mut complete 'if eq get st 45 289' 'if eq get st 45 288'
60mut dropped 'put st 1 add get st 1 1' 'put st 1 add get st 1 2'
61mut gu_shape 'if eq n 1536' 'if eq n 1537'
62mut gap 'put st r add get st r sub beg get st 4' 'put st r add get st r sub get st 4 beg'
63mut attn 'put st 5 mul 2048 add get a 5 1' 'put st 5 mul 2048 add get a 5 2'
64mut digits 'x = div x 10' 'x = div x 11'
65mut rearm 'put st 2 1' 'put st 2 0'
66echo "own30b_prof mutants: $killed killed"
67
68if [ -n "${TOOLS_OM_COVERAGE:-}" ]; then
69 mkdir -p "$TOOLS_OM_COVERAGE"
70 cov=$tmp/cov
71 mkdir -p "$cov"
72 cp tools/own30b_decode_profile.c $DRV "$cov/"
73 sed -i 's#"../../tools/own30b_decode_profile.c"#"own30b_decode_profile.c"#' "$cov/own30b_diff.c"
74 (cd "$cov" && $CC -std=gnu11 -D_GNU_SOURCE -O0 --coverage -I"$ROOT/src" $OFF -c -o own30b_diff.o own30b_diff.c && $CC --coverage -o diff_cov own30b_diff.o)
75 for cfg in $CONFIGS; do
76 IFS=: read -r s t m <<EOF
77$cfg
78EOF
79 "$cov/diff_cov" "$s" "$t" "$m" > /dev/null 2>&1
80 done
81 (cd "$cov" && gcov -b -c own30b_diff.c > "$TOOLS_OM_COVERAGE/own30b.gcov.txt" 2>&1)
82 cp "$cov/own30b_decode_profile.c.gcov" "$TOOLS_OM_COVERAGE/own30b_decode_profile.c.gcov"
83 echo "coverage: $TOOLS_OM_COVERAGE/own30b.gcov.txt"
84fi
85echo "tools-om own30b_prof: PASS (differential $(echo $CONFIGS | wc -w) seeds, negative control, $killed mutants killed)"