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
| 1 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | # C6 (CUDApp#10): the sm_121 disassembler in seeded Omega (om/disasm/sm121_dis.om), linked through its generated |
| 3 | # binding src/cudapp_om_sm121_dis.c (om/units.sh). The C decoder in src/omega_sm121_disasm.c is migration-pending: |
| 4 | # CUDAPP_DISASM=c builds it alone, CUDAPP_DISASM=diff runs both on every word and aborts on a difference. |
| 5 | # make test-om-disasm (in `make test`; no Omega tool, no NVIDIA tool) tests/sm121_dis_diff_test.c: |
| 6 | # 1. eleven golden words print their text, and each with one flipped bit (the corrupted word) does not; |
| 7 | # 2. .om vs C on every row of the C table with random operands, random words and IMAD immediates; |
| 8 | # 3. red checks: one planted byte in one .om text must FAIL step 2; corrupted words held to the golden text |
| 9 | # must FAIL step 1. |
| 10 | # make test-om-disasm-mutants (pinned OMEGA_OMC and OMEGA_BRIDGE) four mutant .om decoders, each compiled by the |
| 11 | # pinned omc into its own binding, must each fail the differential. |
| 12 | # make test-sm121dis (mk/sm121dis.mk) is the nvdisasm oracle and the .om vs C comparison over the kernel corpus. |
| 13 | # #280 merge with main's C6 decoder (2026-11-10): the float-immediate sweep (test-om-disasm-fimm) is retired with the |
| 14 | # decoder it probed; main's decoder has no float printer (%f is used by no row and refuses). |
| 15 | CARRIED_HOST_TESTS += test-om-disasm |
| 16 | OM_DIS_DIR = $(OUT_DIR)/om-disasm |
| 17 | OM_DIS_BUILD = gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc src/cudapp_om_words.c |
| 18 | OM_DIS_DEPS = tests/sm121_dis_diff_test.c src/omega_sm121_disasm.c src/omega_sm121_disasm.h src/cudapp_native.h src/omega_dis_words.h src/cudapp_om_words.c |
| 19 | OM_DIS_PIN_CHECK = [ -x "$(OMEGA_OMC)" ] && [ -f "$(OMEGA_BRIDGE)/src/toc.om" ] && [ -f "$(OMEGA_BRIDGE)/src/freest.om" ] || \ |
| 20 | { echo "NOT_RUN: set pinned OMEGA_OMC and OMEGA_BRIDGE"; exit 3; } |
| 21 | OM_DIS_UNITS = sm121_dis=$$(pwd)/$$d/sm121_dis.om |
| 22 | |
| 23 | .PHONY: test-om-disasm test-om-disasm-mutants |
| 24 | $(OM_DIS_DIR)/diff: $(OM_DIS_DEPS) src/cudapp_om_sm121_dis.c |
| 25 | @mkdir -p $(OM_DIS_DIR) |
| 26 | $(OM_DIS_BUILD) -o $@ tests/sm121_dis_diff_test.c src/cudapp_om_sm121_dis.c |
| 27 | |
| 28 | test-om-disasm: $(OM_DIS_DIR)/diff |
| 29 | $(OM_DIS_DIR)/diff |
| 30 | @if $(OM_DIS_DIR)/diff --plant > $(OM_DIS_DIR)/plant.log 2>&1; then \ |
| 31 | echo "RED CHECK BROKEN: a planted .om text difference passed"; exit 1; \ |
| 32 | elif ! grep -q '^FAIL .* words, 1 differ' $(OM_DIS_DIR)/plant.log; then \ |
| 33 | echo "RED CHECK BROKEN: the planted run did not report one difference"; tail -3 $(OM_DIS_DIR)/plant.log; exit 1; \ |
| 34 | else echo "red check: the planted .om text difference FAILS, as it must"; fi |
| 35 | @if $(OM_DIS_DIR)/diff --corrupt > $(OM_DIS_DIR)/corrupt.log 2>&1; then \ |
| 36 | echo "RED CHECK BROKEN: corrupted words passed as golden"; exit 1; \ |
| 37 | elif ! grep -q '^FAIL corrupted words read as golden: 11 of 11 differ' $(OM_DIS_DIR)/corrupt.log; then \ |
| 38 | echo "RED CHECK BROKEN: not every corrupted word failed"; tail -3 $(OM_DIS_DIR)/corrupt.log; exit 1; \ |
| 39 | else echo "red check: every corrupted word FAILS the golden text, as it must (11 of 11)"; fi |
| 40 | |
| 41 | # Each mutant is one edit of the .om source; each target line occurs exactly once in sm121_dis.om. |
| 42 | # 1 field a/A read one bit higher; 2 a power-of-two IMAD immediate of 2^31 (Rc = RZ) printed as IMAD.SHL instead |
| 43 | # of plain IMAD; 3 the never-true guard @!PT dropped like @PT; 4 the HADD2.F32 row's fixed opcode off by one, so |
| 44 | # the #280 half-widening form is no longer known. |
| 45 | OM_DIS_MUTANTS = 's/^ret pk 0 24 8$$/ret pk 0 25 8/' \ |
| 46 | 's/^if or eq n 16 eq n 31$$/if eq n 16/' \ |
| 47 | 's/^if or ne g 7 ne gn 0$$/if ne g 7/' \ |
| 48 | 's/^put t 0 2305843013491913264$$/put t 0 2305843013491913265/' |
| 49 | test-om-disasm-mutants: $(OM_DIS_DEPS) om/disasm/sm121_dis.om |
| 50 | @$(OM_DIS_PIN_CHECK) |
| 51 | @n=0; for m in $(OM_DIS_MUTANTS); do n=$$((n+1)); d=$(OM_DIS_DIR)/mutant$$n; rm -rf $$d; mkdir -p $$d; \ |
| 52 | sed "$$m" om/disasm/sm121_dis.om > $$d/sm121_dis.om; \ |
| 53 | if cmp -s $$d/sm121_dis.om om/disasm/sm121_dis.om; then echo "MUTANT $$n BROKEN: '$$m' changed nothing"; exit 1; fi; \ |
| 54 | OMEGA_UNITS="$(OM_DIS_UNITS)" OMEGA_UNITS_DEST=$$d OMEGA_OMC="$(OMEGA_OMC)" OMEGA_BRIDGE="$(OMEGA_BRIDGE)" \ |
| 55 | sh om/units.sh > /dev/null || exit 1; \ |
| 56 | $(OM_DIS_BUILD) -o $$d/diff tests/sm121_dis_diff_test.c $$d/cudapp_om_sm121_dis.c || exit 1; \ |
| 57 | w=0; $$d/diff > $$d/diff.log 2>&1 || w=1; \ |
| 58 | if [ $$w = 0 ]; then echo "MUTANT $$n SURVIVED: '$$m'"; exit 1; fi; \ |
| 59 | echo "mutant $$n red ('$$m'): words FAIL"; \ |
| 60 | done |
| 61 | @echo "OM_DISASM_MUTANTS PASS (4/4 killed)" |