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
CUDApp / tests / codegen_base / run.sh
| 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | set -eu |
| 4 | ROOT=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) |
| 5 | cd "$ROOT" |
| 6 | : "${CC:=cc}" |
| 7 | : "${CODEGEN_BASE_OUT:=$ROOT/build/codegen-base-om}" |
| 8 | OUT=$CODEGEN_BASE_OUT |
| 9 | mkdir -p "$OUT" |
| 10 | # These are generated build profiles, never historical evidence. |
| 11 | rm -f "$OUT"/*.gcda |
| 12 | if [ -n "${OMEGA_OMC:-}" ]; then sh om/units.sh --check |
| 13 | else echo "NOT_RUN om/units.sh --check (requires the pinned AArch64 omc; the C comparison below still runs)"; fi |
| 14 | python3 - "$OUT" <<'PY' |
| 15 | import pathlib, re, sys |
| 16 | out = pathlib.Path(sys.argv[1]) |
| 17 | s = pathlib.Path('src/omega_blackwell_codegen.c').read_text() |
| 18 | names = sorted(set(re.findall(r'^(?:int|void|size_t|uint32_t|uint16_t) (omega_\w+)\(', s, re.M))) |
| 19 | base = ''.join('#define '+n+' legacy_'+n+'\n' for n in names) |
| 20 | (out/'oracle_base.h').write_text(base) |
| 21 | (out/'oracle_sass.h').write_text(''.join('#define '+n+' sass_'+n+'\n' for n in names)) |
| 22 | s = pathlib.Path('src/omega_gpu_om_ir.c').read_text() |
| 23 | names = sorted(set(re.findall(r'^(?:int|const char \*)\s*(omega_\w+)\(', s, re.M))) |
| 24 | (out/'oracle_ir.h').write_text(base+''.join('#define '+n+' legacy_'+n+'\n' for n in names)) |
| 25 | PY |
| 26 | FLAGS="-std=gnu11 -O2 -Wall -Wextra -Werror -ffp-contract=off -ffunction-sections -fdata-sections -Isrc" |
| 27 | COV="-O0 --coverage" |
| 28 | $CC $FLAGS $COV -DCUDAPP_MIGRATION_PENDING_C_CODEGEN_BASE \ |
| 29 | -include "$OUT/oracle_base.h" -c src/omega_blackwell_codegen.c -o "$OUT/oracle_base.o" |
| 30 | $CC $FLAGS $COV -DCUDAPP_MIGRATION_PENDING_C_CODEGEN_BASE -include "$OUT/oracle_ir.h" \ |
| 31 | -c src/omega_gpu_om_ir.c -o "$OUT/oracle_ir.o" |
| 32 | $CC $FLAGS -DCUDAPP_MIGRATION_PENDING_C_CODEGEN_BASE -DCUDAPP_MIGRATION_PENDING_C_ENCODER \ |
| 33 | -include "$OUT/oracle_sass.h" -c src/omega_blackwell_codegen.c -o "$OUT/oracle_sass.o" |
| 34 | OBJECTS="$OUT/oracle_base.o $OUT/oracle_ir.o $OUT/oracle_sass.o" |
| 35 | for src in src/omega_blackwell_codegen.c src/omega_gpu_om_ir.c src/omega_blackwell_matmul.c src/omega_cubin.c src/sha256.c \ |
| 36 | src/cudapp_om_*.c src/cudapp_freest_*.c; do |
| 37 | name=$(basename "$src" .c) |
| 38 | $CC $FLAGS -c "$src" -o "$OUT/$name.o" |
| 39 | OBJECTS="$OBJECTS $OUT/$name.o" |
| 40 | done |
| 41 | $CC $FLAGS tests/codegen_base/differential.c $OBJECTS --coverage -Wl,--gc-sections -o "$OUT/differential" |
| 42 | "$OUT/differential" |
| 43 | $CC $FLAGS -DCODEGEN_BASE_RED tests/codegen_base/differential.c $OBJECTS --coverage -Wl,--gc-sections -o "$OUT/red" |
| 44 | if "$OUT/red" > "$OUT/red.log" 2>&1; then echo "FAIL: one-bit red control survived"; exit 1; fi |
| 45 | echo "PASS: one flipped SASS bit rejected by byte comparison" |
| 46 | gcov -b -c -o "$OUT/oracle_ir.gcno" src/omega_gpu_om_ir.c > "$OUT/gcov-ir.log" |
| 47 | gcov -b -c -o "$OUT/oracle_base.gcno" src/omega_blackwell_codegen.c > "$OUT/gcov-base.log" |
| 48 | mv omega_gpu_om_ir.c.gcov "$OUT/" |
| 49 | mv omega_blackwell_codegen.c.gcov "$OUT/" |
| 50 | for header in omega_bw_bind.h.gcov omega_path_check.h.gcov; do |
| 51 | if [ -f "$header" ]; then mv "$header" "$OUT/"; fi |
| 52 | done |
| 53 | if [ "${1:-}" = --mutants ]; then |
| 54 | export CODEGEN_BASE_OBJECTS="$OBJECTS" |
| 55 | python3 tests/codegen_base/mutants.py |
| 56 | fi |
| 57 | echo "CODEGEN BASE HOST ACCEPTANCE PASS" |