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 / regalloc_om / sim_ge.sh

41 lines · 2119 bytes Raw Blame History
1#!/bin/sh
2# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3# Run inside the device-free bwrap namespace, like every host/simulator gate.
4set -eu
5ROOT=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd)
6cd "$ROOT"
7: "${CC:=cc}"
8: "${SIM_GE_OUT:=$ROOT/build/regalloc-om/signed-ge}"
9mkdir -p "$SIM_GE_OUT/mutant"
10FLAGS="-std=gnu11 -O2 -Wall -Wextra -Werror -Wno-unused-function -ffp-contract=off -ffunction-sections -fdata-sections -Isrc -I$ROOT/build/regalloc-om/include"
11ORACLE="-DCUDAPP_MIGRATION_PENDING_C_REGALLOC -DCUDAPP_MIGRATION_PENDING_C_CODEGEN_MATMUL -DCUDAPP_MIGRATION_PENDING_C_ENCODER -DCUDAPP_MIGRATION_PENDING_C_BIND"
12SOURCES="tests/regalloc_om/sim.c src/omega_blackwell_codegen.c src/omega_blackwell_matmul.c src/omega_blackwell_encoder.c src/sha256.c src/cudapp_om_bw_enc_sm121.c src/cudapp_freest_f16.c"
13$CC $FLAGS $ORACLE -Itests $SOURCES -Wl,--gc-sections -lm -o "$SIM_GE_OUT/baseline"
14"$SIM_GE_OUT/baseline" >"$SIM_GE_OUT/baseline.log" 2>&1
15cat "$SIM_GE_OUT/baseline.log"
16python3 - "$SIM_GE_OUT/mutant/bw_warp_sim_tc.h" <<'PY'
17import pathlib,sys
18source=pathlib.Path('tests/bw_warp_sim_tc.h').read_text()
19old='case BW_IR_ISETP_GE: l->p0 = (int32_t)a >= (in->src2_vreg >= 0 ? (int32_t)b : (int32_t)in->imm); break;'
20new='case BW_IR_ISETP_GE: l->p0 = a >= (in->src2_vreg >= 0 ? b : in->imm); break;'
21if source.count(old) != 1:
22 raise SystemExit('FAIL unsigned mutant site not unique')
23pathlib.Path(sys.argv[1]).write_text(source.replace(old,new))
24PY
25$CC $FLAGS $ORACLE -I"$SIM_GE_OUT/mutant" -Itests $SOURCES -Wl,--gc-sections -lm -o "$SIM_GE_OUT/unsigned-mutant"
26set +e
27"$SIM_GE_OUT/unsigned-mutant" >"$SIM_GE_OUT/unsigned-mutant.log" 2>&1
28rc=$?
29set -e
30if [ "$rc" -ne 1 ]; then
31 cat "$SIM_GE_OUT/unsigned-mutant.log"
32 echo "FAIL unsigned GE mutant exercise=$rc expected=1"
33 exit 1
34fi
35if ! grep -q '^FAIL signed GE ' "$SIM_GE_OUT/unsigned-mutant.log"; then
36 cat "$SIM_GE_OUT/unsigned-mutant.log"
37 echo 'FAIL unsigned GE mutant failed for an unrelated reason'
38 exit 1
39fi
40cat "$SIM_GE_OUT/unsigned-mutant.log"
41echo 'PASS unsigned GE semantic mutant KILLED compile=0 exercise=1'