Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/mk/sm121dis.mk # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / mk / sm121dis.mk` 160 lines · 12162 bytes Raw Blame History 1 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 # C6 of docs/OMEGA.md: Omega's own sm_121 disassembler (om/disasm/sm121_dis.om through the generated binding 3 # src/cudapp_om_sm121_dis.c, glue in src/omega_sm121_disasm.c; tools/sm121dis/). CUDA++ C6, DRA-475. 4 # make test-sm121dis collect every kernel the library builds (no GPU), compare our text with nvdisasm's, word by word; 5 # then the red check: a decoder built with one deliberate fault must FAIL the same comparison; 6 # then the differential: the .om decoder and the migration-pending C decoder on every word of 7 # the corpus (abort on any difference), with its red check; then the flipped-bit control. 8 # make test-sm121dis-om-mutants three one-line mutants of the .om decoder, each regenerated by the pinned omc and 9 # bridge (om/units.sh), must each change the text of the corpus (needs OMEGA_OMC, OMEGA_BRIDGE). 10 # Picked up by the `-include mk/*.mk` line of the Makefile. The test binaries are named as files, not through the 11 # GPU_*_TEST variables: this file is read before the Makefile defines them. 12 SM121DIS = $(OUT_DIR)/sm121dis 13 SM121DIS_RED = $(OUT_DIR)/sm121dis_red 14 SM121DIS_DIFF = $(OUT_DIR)/sm121dis_diff 15 SM121DIS_DIFF_RED = $(OUT_DIR)/sm121dis_diff_red 16 SM121DIS_K = $(OUT_DIR)/sm121dis-kernels 17 SM121DIS_DEPS = tools/sm121dis/sm121dis.c src/omega_sm121_disasm.c src/omega_sm121_disasm.h src/cudapp_om_sm121_dis.c \ 18 src/cudapp_native.h src/omega_dis_words.h src/cudapp_om_words.c 19 # the command line reads each word through the seeded word unit (om/disasm/words.om, src/omega_dis_words.h) 20 SM121DIS_SRCS = tools/sm121dis/sm121dis.c src/omega_sm121_disasm.c src/cudapp_om_sm121_dis.c src/cudapp_om_words.c 21 SM121DIS_CC = $(CC) -std=gnu11 -Wall -Wextra -Werror -O2 -Isrc 22 23 $(SM121DIS): $(SM121DIS_DEPS) 24 @mkdir -p $(OUT_DIR) 25 $(SM121DIS_CC) $(CUDAPP_DISASM_DEFS) -o $@ $(SM121DIS_SRCS) 26 # the red decoder: the C oracle with one planted fault (first source register off by one bit) 27 $(SM121DIS_RED): $(SM121DIS_DEPS) 28 @mkdir -p $(OUT_DIR) 29 $(SM121DIS_CC) -DCUDAPP_MIGRATION_PENDING_C_DISASM -DSM121DIS_MUTANT=1 -o $@ tools/sm121dis/sm121dis.c src/omega_sm121_disasm.c src/cudapp_om_words.c 30 $(SM121DIS_DIFF): $(SM121DIS_DEPS) 31 @mkdir -p $(OUT_DIR) 32 $(SM121DIS_CC) -DCUDAPP_MIGRATION_PENDING_DISASM_DIFF -o $@ $(SM121DIS_SRCS) 33 $(SM121DIS_DIFF_RED): $(SM121DIS_DEPS) 34 @mkdir -p $(OUT_DIR) 35 $(SM121DIS_CC) -DCUDAPP_MIGRATION_PENDING_DISASM_DIFF -DCUDAPP_DISASM_DIFF_SELFTEST -o $@ $(SM121DIS_SRCS) 36 37 sm121dis-corpus-bins: $(addprefix $(OUT_DIR)/,gpu_matmul_api_test gpu_elementwise_test gpu_reconv_test gpu_attention_test \ 38 gpu_moe_window_test gpu_fp8_api_test gpu_decode_attn_test gpu_router_test gpu_bf16_gemv_test gpu_fp8gemm_test \ 39 gpu_tc_probe_test gpu_tc_peak_test gpu_pf_mem_test gpu_qmma_probe_test gpu_cmdlist_test gpu_decode_graph_test gpu_tcgemm_test \ 40 gpu_prefill_attn_test gpu_pfgemm_test gpu_qgemm_test gpu_pfhost_test gpu_gpr_boundary_test \ 41 gpu_scan_test gpu_gemm_test gpu_streams_test gpu_isolation_test bw_hazard_test gpu_mathlibs_test) 42 43 .PHONY: test-sm121dis sm121dis-corpus-bins test-sm121dis-corpus-controls test-sm121dis-check-controls 44 test-sm121dis-corpus-controls: 45 sh tools/sm121dis/corpus_selftest.sh 46 47 test-sm121dis-check-controls: 48 sh tools/sm121dis/check_selftest.sh 49 50 test-sm121dis: $(SM121DIS) $(SM121DIS_RED) $(SM121DIS_DIFF) $(SM121DIS_DIFF_RED) sm121dis-corpus-bins test-sm121dis-corpus-controls test-sm121dis-check-controls 51 rm -rf $(SM121DIS_K) && sh tools/sm121dis/corpus.sh $(OUT_DIR) $(SM121DIS_K) 52 sh tools/sm121dis/check.sh $(SM121DIS) $(SM121DIS_K) $(OUT_DIR)/sm121dis-work 53 @if sh tools/sm121dis/check.sh $(SM121DIS_RED) $(SM121DIS_K) $(OUT_DIR)/sm121dis-red > $(OUT_DIR)/sm121dis-red.log 2>&1; then \ 54 echo "RED CHECK BROKEN: the faulty decoder passed"; exit 1; \ 55 elif ! grep -q '^VERDICT FAIL' $(OUT_DIR)/sm121dis-red.log; then \ 56 echo "RED CHECK BROKEN: the faulty decoder's run did not reach a verdict"; tail -3 $(OUT_DIR)/sm121dis-red.log; exit 1; \ 57 else echo "red check: the faulty decoder FAILS the comparison, as it must ($$(grep -c '^\[FAIL\]' $(OUT_DIR)/sm121dis-red.log) kernels)"; fi 58 @n=0; for f in $(SM121DIS_K)/*.bin; do n=$$((n+1)); rc=0; $(SM121DIS_DIFF) --pairs $$f > /dev/null 2> $(OUT_DIR)/sm121dis-diff.err || rc=$$?; \ 59 if [ $$rc != 0 ]; then echo "FAIL .om vs C decoder differential on $$f (exit $$rc)"; head -3 $(OUT_DIR)/sm121dis-diff.err; exit 1; fi; done; \ 60 echo "decoder differential: .om and migration-pending C decoders agree on every word of $$n kernels" 61 @rc=0; (ulimit -c 0; $(SM121DIS_DIFF_RED) --pairs $$(ls $(SM121DIS_K)/*.bin | head -1) > /dev/null 2> $(OUT_DIR)/sm121dis-diff-red.err) || rc=$$?; \ 62 if [ $$rc -le 128 ] || ! grep -q '^DISASM DIFFER' $(OUT_DIR)/sm121dis-diff-red.err; then \ 63 echo "RED CHECK BROKEN: the differential did not abort on a flipped bit (exit $$rc)"; exit 1; fi; \ 64 echo "red check: one flipped bit aborts the decoder differential, as it must (exit $$rc)" 65 sh tools/sm121dis/negctl.sh $(SM121DIS) $(SM121DIS_K) $(OUT_DIR)/sm121dis-work 66 67 .PHONY: test-sm121dis-om-mutants 68 test-sm121dis-om-mutants: 69 @ls $(SM121DIS_K)/*.bin > /dev/null 2>&1 || { echo "NOT_RUN: no corpus in $(SM121DIS_K) (make test-sm121dis first)"; exit 2; } 70 OMEGA_OMC="$(OMEGA_OMC)" OMEGA_BRIDGE="$(OMEGA_BRIDGE)" sh tools/sm121dis/om_mutants.sh $(OUT_DIR)/sm121dis-om-mutants $(SM121DIS_K) 71 72 # The device-trace emitter's words (tests/device-trace/run-emitter-checks.sh) decoded by our disassembler against the 73 # hand-written expectations, never nvdisasm here (NVDISASM is cleared); then the red check: the faulty decoder must FAIL. 74 .PHONY: test-device-trace-emitter 75 test-device-trace-emitter: $(SM121DIS) $(SM121DIS_RED) 76 @test "$$(sha256sum < $(OMEGA_OMC) | cut -c1-64)" = `2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f` || { echo "NOT_RUN: wrong seeded compiler $(OMEGA_OMC)"; exit 3; } 77 NVDISASM= OMEGA_COMPILER="$(OMEGA_OMC)" SM121DIS=$(SM121DIS) sh tests/device-trace/run-emitter-checks.sh 78 @rc=0; NVDISASM= OMEGA_COMPILER="$(OMEGA_OMC)" SM121DIS=$(SM121DIS_RED) sh tests/device-trace/run-emitter-checks.sh \ 79 > $(OUT_DIR)/device-trace-red.log 2>&1 || rc=$$?; \ 80 if [ $$rc != 1 ] || ! grep -q '^offset 0x.*: want' $(OUT_DIR)/device-trace-red.log; then \ 81 echo "RED CHECK BROKEN: the faulty decoder did not fail the expectations (exit $$rc)"; tail -3 $(OUT_DIR)/device-trace-red.log; exit 1; fi; \ 82 echo "red check: the faulty decoder FAILS the device-trace expectations, as it must ($$(grep -c '^offset 0x' $(OUT_DIR)/device-trace-red.log) lines)" 83 84 # The provenance checks (tools/divsqrt_nvdisasm_check.sh, tools/ldst_nvdisasm_check.sh, test-numeric-reduce-nvdisasm) 85 # call build/sm121dis by that name, whatever OUT_DIR is. 86 ifneq ($(OUT_DIR),build) 87 build/sm121dis: $(SM121DIS_DEPS) 88 @mkdir -p build 89 $(SM121DIS_CC) $(CUDAPP_DISASM_DEFS) -o $@ $(SM121DIS_SRCS) 90 endif 91 92 # ZERO-NVDISASM (bar C6, second half: nothing calls nvdisasm). tools/sm121dis/zero_nvdisasm.sh runs every listing and 93 # provenance check with a decoy nvdisasm first on PATH, the CUDA directories removed from PATH, and strace on execve; 94 # then its own red check plants two calls to nvdisasm and must see the gate FAIL. 95 .PHONY: test-zero-nvdisasm 96 test-zero-nvdisasm: $(SM121DIS) build/sm121dis $(addprefix $(OUT_DIR)/,gpu_attention_test gpu_elementwise_test gpu_fp8_api_test gpu_reconv_test bw_hazard_test) 97 PHYSICS_DIR="$(PHYSICS_DIR)" sh tools/sm121dis/zero_nvdisasm.sh $(OUT_DIR) 98 @if PHYSICS_DIR="$(PHYSICS_DIR)" sh tools/sm121dis/zero_nvdisasm.sh $(OUT_DIR) --red > $(OUT_DIR)/zero-nvdisasm-red.log 2>&1; then \ 99 echo "RED CHECK BROKEN: the planted nvdisasm calls passed the gate"; exit 1; \ 100 else echo "red check: the planted nvdisasm calls FAIL the gate, as they must ($$(grep -c 'FAIL$$' $(OUT_DIR)/zero-nvdisasm-red.log) lines)"; fi 101 102 # Issue #171: the semantic fixture and expectation live in Omega. NVIDIA's 103 # pinned offline decoder is read-only; neither output nor the mutant enters a kernel. 104 NVDISASM ?= /usr/local/cuda/bin/nvdisasm 105 SM121_MMIO = $(OUT_DIR)/sm121-mmio 106 $(SM121_MMIO): om/encoder/bw_enc_sm121.om om/encoder/mmio_test.om 107 @mkdir -p $(OUT_DIR) 108 @test "$$(sha256sum < $(OMEGA_MV)/seed/out/omc | cut -c1-64)" = `2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f` || { echo "NOT_RUN: wrong seeded compiler"; exit 3; } 109 cat $^ > $@.om 110 $(OMEGA_MV)/seed/out/omc < $@.om > $@ 111 chmod +x $@ 112 113 .PHONY: test-sm121-mmio 114 test-sm121-mmio: $(SM121_MMIO) 115 @$(NVDISASM) --version > $(SM121_MMIO).version 116 @case "$$(cat $(SM121_MMIO).version)" in *V13.0.85*) ;; *) echo "NOT_RUN: nvdisasm version must be 13.0.85"; exit 3;; esac 117 @sha256sum $(NVDISASM) 118 $(SM121_MMIO) > $(SM121_MMIO).bin 119 $(NVDISASM) -b SM121 -hex $(SM121_MMIO).bin > $(SM121_MMIO).nv 120 $(SM121_MMIO) check oracle < $(SM121_MMIO).nv 121 $(SM121_MMIO) wrong-cache-policy > $(SM121_MMIO)-ef.bin 122 $(NVDISASM) -b SM121 -hex $(SM121_MMIO)-ef.bin > $(SM121_MMIO)-ef.nv 123 @if $(SM121_MMIO) check oracle < $(SM121_MMIO)-ef.nv; then \ 124 echo "FAIL: EF satisfied the MMIO.GPU contract"; exit 1; \ 125 else rc=$$?; test "$$rc" = 4 || exit "$$rc"; \ 126 echo "PASS: exact MMIO.GPU op and operands; wrong-EF negative refused. GB10 DEVICE NOT_RUN"; fi 127 128 # BlackwellIR ops 64..79 after the #280 numbering move (evidence/INTEG-280-`20261110`/numbering.txt): 129 # om/disasm/opmove_test.om, composed after the seeded encoder and this decoder and compiled by the pinned omc, encodes 130 # one row of each op; Omega's own decoder must know every word and print the op's mnemonic, and the nvdisasm 13.0.85 131 # ORACLE (offline, read-only, never shipped) must print the decoder's text for each word. Red checks: the rows 132 # numbered as before the move (stale numbering, exit 41), the decoder without its DADD row (exit 15), the oracle text 133 # without its DADD line (exit 4). 134 SM121DIS_OPMOVE = $(OUT_DIR)/sm121dis-opmove 135 SM121DIS_OPMOVE_RED = 's/^if eq op 553$$/if eq op 4096/' 136 .PHONY: test-sm121dis-opmove 137 test-sm121dis-opmove: om/encoder/bw_enc_sm121.om om/disasm/sm121_dis.om om/disasm/opmove_test.om 138 @[ -x "$(OMEGA_OMC)" ] && [ "$$(sha256sum < $(OMEGA_OMC) | cut -c1-64)" = `2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f` ] || { echo "NOT_RUN: set OMEGA_OMC to the pinned seeded compiler"; exit 3; } 139 @case "$$($(NVDISASM) --version 2>/dev/null)" in *V13.0.85*) ;; *) echo "NOT_RUN: nvdisasm version must be 13.0.85"; exit 3;; esac 140 @mkdir -p $(OUT_DIR) 141 cat om/encoder/bw_enc_sm121.om om/disasm/sm121_dis.om om/disasm/opmove_test.om > $(SM121DIS_OPMOVE).om 142 $(OMEGA_OMC) < $(SM121DIS_OPMOVE).om > $(SM121DIS_OPMOVE) 143 chmod +x $(SM121DIS_OPMOVE) 144 $(SM121DIS_OPMOVE) 145 $(SM121DIS_OPMOVE) bin > $(SM121DIS_OPMOVE).bin 146 $(NVDISASM) -b SM121 -hex $(SM121DIS_OPMOVE).bin > $(SM121DIS_OPMOVE).nv 147 $(SM121DIS_OPMOVE) check oracle < $(SM121DIS_OPMOVE).nv 148 @rc=0; $(SM121DIS_OPMOVE) stale numbering control || rc=$$?; \ 149 if [ $$rc != 41 ]; then echo "RED CHECK BROKEN: the stale numbering exited $$rc, not 41"; exit 1; fi; \ 150 echo "red check: the stale numbering (I2FP_U32 encoded as op 64) exits 41, as it must" 151 @sed $(SM121DIS_OPMOVE_RED) om/disasm/sm121_dis.om > $(SM121DIS_OPMOVE)-red.dis.om; \ 152 if cmp -s $(SM121DIS_OPMOVE)-red.dis.om om/disasm/sm121_dis.om; then echo "RED CHECK BROKEN: the DADD row edit changed nothing"; exit 1; fi; \ 153 cat om/encoder/bw_enc_sm121.om $(SM121DIS_OPMOVE)-red.dis.om om/disasm/opmove_test.om | $(OMEGA_OMC) > $(SM121DIS_OPMOVE)-red || exit 1; \ 154 chmod +x $(SM121DIS_OPMOVE)-red; rc=0; $(SM121DIS_OPMOVE)-red || rc=$$?; \ 155 if [ $$rc != 15 ]; then echo "RED CHECK BROKEN: the decoder without its DADD row exited $$rc, not 15"; exit 1; fi; \ 156 echo "red check: the decoder without its DADD row exits 15, as it must" 157 @rc=0; grep -v -- 'DADD' $(SM121DIS_OPMOVE).nv | $(SM121DIS_OPMOVE) check oracle || rc=$$?; \ 158 if [ $$rc != 4 ]; then echo "RED CHECK BROKEN: oracle text without the DADD line exited $$rc, not 4"; exit 1; fi; \ 159 echo "red check: oracle text without the DADD line exits 4, as it must" 160 @echo "PASS BlackwellIR ops 64..79: 16 rows encoded, Omega's decoder knows all 16, nvdisasm 13.0.85 prints the same text. GB10 DEVICE NOT_RUN"