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/om-encoder.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 / om-encoder.mk` 289 lines · 23525 bytes Raw Blame History 1 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 # CUDApp#79: the sm_121 instruction encoder in seeded Omega (om/encoder/bw_enc_sm121.om), linked through the 3 # portable generated C units $(CUDAPP_BINDING_SRCS) that om/units.sh generates. The C encoder in 4 # src/omega_blackwell_codegen.c is migration-pending: explicit default-OFF oracle builds only. 5 # make test-om-encoder (in `make test`, no Omega tools needed) 6 # 1. the golden-word fixture verifiers (nvcc/nvdisasm oracles) through the .om encoder; 7 # 2. a build with CUDAPP_MIGRATION_PENDING_ENCODER_DIFF encodes every codegen fixture both ways and must log 8 # only SAME lines; 3. its red check: the same build with one flipped output bit must abort. 9 # make test-om-encoder-corpus every kernel of the sm121dis corpus (tools/sm121dis/corpus.sh) built three ways: 10 # .om (OUT_DIR), C oracle ($(OUT_DIR)-enc-c), diff ($(OUT_DIR)-enc-diff); the .om and C kernel sets must be 11 # identical file for file, and the diff build must log no DIFFER line. 12 # make test-om-units the committed binding regenerates byte for byte from the pinned omc + bridge 13 # make test-om-encoder-mutants three mutant .om encoders, each compiled by the pinned omc, must go red 14 # (after its prerequisites test-om-encoder-ldg, test-om-encoder-ldg-spec and test-om-encoder-ldg-c, so the 15 # CI om-units job, which already has the pinned omc, omega-bridge and nvdisasm 13.0.85, runs the LDG gates) 16 # make test-om-encoder-ldg CUDApp#373: om/encoder/ldg_offset_test.om, composed after the encoder and compiled by 17 # the pinned omc, checks the exact LDG.E words for byte offsets 0, +0x40, -0x100000, +0x7fffff, -0x800000 and 18 # the refusal of +0x800000, -0x800001, 0x7fffffff, 0x80000000; ORACLE NVIDIA nvdisasm 13.0.85 (offline, 19 # read-only, never shipped) must decode the accepted words as those offsets. Red checks: the pre-fix op-11 20 # line (offset dropped), a field bound widened by one, and the oracle text without its -0x800000 line. 21 # make test-om-encoder-atomg op 64 ATOMG.E.MIN.64.STRONG.SYS (Omega NG trap word): om/encoder/atomg_min_test.om, 22 # composed after the encoder and compiled by the pinned omc, checks the exact words of three rows (one with RZ 23 # as destination); the nvdisasm 13.0.85 ORACLE must decode them as those instructions. Red checks: the signed 24 # type (.S64), RZ dropped for an absent destination, and the oracle text without its R14 line. 25 # make test-om-encoder-guard DRA-483: om/encoder/guard_pred_test.om, the guard predicate (@P0 / @!P0) of every 26 # emitting op 0..79 through the seeded encoder, LDCU / LDCU.64 refused, the omega-mv #1044 bool/trap rows; ORACLE 27 # nvdisasm 13.0.85 must print each guard; om/encoder/guard_spec_test.om: sp_enc equals enc1 on the guards. 28 # Red checks: the guard ignored, forced to 7, @!P0 as @P0, the LDCU refusal removed (enc1 and sp_enc), oracle 29 # lines missing. 30 # The last five accept OMEGA_OMC, units and mutants also OMEGA_BRIDGE; their defaults retain the 31 # OMEGA_MV and OMEGA_BRIDGE_DIR checkout convention. Missing pins refuse. 32 OMEGA_MV ?= ../omega-mv 33 OMEGA_BRIDGE_DIR ?= ../omega-bridge 34 OMEGA_OMC ?= $(OMEGA_MV)/seed/out/omc 35 OMEGA_BRIDGE ?= $(OMEGA_BRIDGE_DIR) 36 OM_ENC_DIR = $(OUT_DIR)/om-encoder 37 OM_ENC_TEST_DEPS = tests/test_omega_codegen_freestanding.c src/omega_blackwell_codegen.h src/omega_blackwell_matmul.h 38 OM_ENC_SRCS = src/omega_blackwell_codegen.c src/omega_gpu_om_ir.c src/omega_blackwell_matmul.c src/sha256.c 39 OM_ENC_BUILD = gcc -std=gnu11 -O2 -Wall -Wextra -Werror -pthread -Isrc 40 41 .PHONY: test-om-encoder test-om-encoder-corpus test-om-units test-om-encoder-mutants 42 $(OM_ENC_DIR)/codegen_om: $(OM_ENC_TEST_DEPS) $(OM_ENC_SRCS) $(CUDAPP_BINDING_SRCS) src/cudapp_native.h 43 @mkdir -p $(OM_ENC_DIR) 44 $(OM_ENC_BUILD) -o $@ tests/test_omega_codegen_freestanding.c $(OM_ENC_SRCS) $(CUDAPP_BINDING_SRCS) 45 $(OM_ENC_DIR)/codegen_diff: $(OM_ENC_TEST_DEPS) $(OM_ENC_SRCS) $(CUDAPP_BINDING_SRCS) src/cudapp_native.h 46 @mkdir -p $(OM_ENC_DIR) 47 $(OM_ENC_BUILD) -DCUDAPP_MIGRATION_PENDING_ENCODER_DIFF -o $@ tests/test_omega_codegen_freestanding.c \ 48 $(OM_ENC_SRCS) $(CUDAPP_BINDING_SRCS) 49 $(OM_ENC_DIR)/codegen_diff_red: $(OM_ENC_TEST_DEPS) $(OM_ENC_SRCS) $(CUDAPP_BINDING_SRCS) src/cudapp_native.h 50 @mkdir -p $(OM_ENC_DIR) 51 $(OM_ENC_BUILD) -DCUDAPP_MIGRATION_PENDING_ENCODER_DIFF -DCUDAPP_ENCODER_DIFF_SELFTEST -o $@ \ 52 tests/test_omega_codegen_freestanding.c $(OM_ENC_SRCS) $(CUDAPP_BINDING_SRCS) 53 54 test-om-encoder: $(OM_ENC_DIR)/codegen_om $(OM_ENC_DIR)/codegen_diff $(OM_ENC_DIR)/codegen_diff_red 55 $(OM_ENC_DIR)/codegen_om --golden 56 rm -f $(OM_ENC_DIR)/diff.log 57 CUDAPP_ENCODER_DIFF_LOG=$(OM_ENC_DIR)/diff.log $(OM_ENC_DIR)/codegen_diff --golden 58 CUDAPP_ENCODER_DIFF_LOG=$(OM_ENC_DIR)/diff.log $(OM_ENC_DIR)/codegen_diff --dump > $(OM_ENC_DIR)/dump_diff.txt 59 @same=$$(grep -c ' SAME$$' $(OM_ENC_DIR)/diff.log); other=$$(grep -vc ' SAME$$' $(OM_ENC_DIR)/diff.log); \ 60 if [ "$$same" -eq 0 ] || [ "$$other" -ne 0 ]; then echo "FAIL encoder diff: $$same SAME, $$other other lines"; exit 1; fi; \ 61 echo "encoder diff: .om and C byte-identical on $$(grep -c '^insn ' $(OM_ENC_DIR)/diff.log) golden instructions and $$(grep -c '^program ' $(OM_ENC_DIR)/diff.log) fixture programs" 62 @if CUDAPP_ENCODER_DIFF_LOG=$(OM_ENC_DIR)/diff_red.log $(OM_ENC_DIR)/codegen_diff_red --dump > /dev/null 2>&1; then \ 63 echo "RED CHECK BROKEN: a flipped bit passed the encoder diff"; exit 1; \ 64 else echo "red check: one flipped bit aborts the encoder diff, as it must"; fi 65 66 test-om-encoder-corpus: 67 $(MAKE) OUT_DIR=$(OUT_DIR) CUDAPP_ENCODER=om sm121dis-corpus-bins 68 $(MAKE) OUT_DIR=$(OUT_DIR)-enc-c CUDAPP_ENCODER=c sm121dis-corpus-bins 69 $(MAKE) OUT_DIR=$(OUT_DIR)-enc-diff CUDAPP_ENCODER=diff sm121dis-corpus-bins 70 rm -rf $(OM_ENC_DIR)/k-om $(OM_ENC_DIR)/k-c $(OM_ENC_DIR)/k-diff $(OM_ENC_DIR)/corpus-diff.log 71 @mkdir -p $(OM_ENC_DIR) 72 sh tools/sm121dis/corpus.sh $(OUT_DIR) $(OM_ENC_DIR)/k-om 73 sh tools/sm121dis/corpus.sh $(OUT_DIR)-enc-c $(OM_ENC_DIR)/k-c 74 CUDAPP_ENCODER_DIFF_LOG=$(abspath $(OM_ENC_DIR))/corpus-diff.log sh tools/sm121dis/corpus.sh $(OUT_DIR)-enc-diff $(OM_ENC_DIR)/k-diff 75 diff -r $(OM_ENC_DIR)/k-om $(OM_ENC_DIR)/k-c 76 diff -r $(OM_ENC_DIR)/k-om $(OM_ENC_DIR)/k-diff 77 @if grep -v ' SAME$$' $(OM_ENC_DIR)/corpus-diff.log; then echo "FAIL corpus encoder diff"; exit 1; fi 78 @echo "encoder corpus: $$(ls $(OM_ENC_DIR)/k-om/*.bin | wc -l) distinct kernels identical .om vs C; diff build $$(grep -c '^program ' $(OM_ENC_DIR)/corpus-diff.log) program encodes and $$(grep -c '^insn ' $(OM_ENC_DIR)/corpus-diff.log) single-instruction encodes, all SAME" 79 80 # The samples are read back by Omega's own decoder ($(OUT_DIR)/sm121dis, mk/sm121dis.mk, read after this file). The 81 # -nvdisasm-oracle variant reads them with NVIDIA's offline nvdisasm instead; it is not in `make test`. 82 .PHONY: test-om-spec-encoder test-om-spec-encoder-nvdisasm-oracle 83 ifeq ($(CUDAPP_OMC_HOST),1) 84 # On a non-AArch64 host the native AArch64 function-byte probe cannot execute; the script exits 3 (NOT_RUN) for 85 # it unless told the row is accepted as NOT_RUN, which this target does there and the log says so. 86 test-om-spec-encoder: $(OUT_DIR)/sm121dis 87 OMEGA_BRIDGE="$(OMEGA_BRIDGE)" SM121DIS="$(OUT_DIR)/sm121dis" $(if $(CUDAPP_HOST_IS_AARCH64),,BW_SPEC_NATIVE_PROBE_NOT_RUN_OK=1) sh tools/test_bw_spec_encoder.sh 88 test-om-spec-encoder-nvdisasm-oracle: 89 OMEGA_BRIDGE="$(OMEGA_BRIDGE)" SPEC_ENCODER_ORACLE=nvdisasm NVDISASM="$(NVDISASM)" $(if $(CUDAPP_HOST_IS_AARCH64),,BW_SPEC_NATIVE_PROBE_NOT_RUN_OK=1) sh tools/test_bw_spec_encoder.sh 90 else 91 test-om-spec-encoder test-om-spec-encoder-nvdisasm-oracle: 92 @echo "$@: NOT_RUN (requires the pinned AArch64 omc; set OMEGA_OMC to a pin that executes on this host; not part of the portable host suite)" 93 @exit 2 94 endif 95 96 test-om-units: 97 OMEGA_OMC="$(OMEGA_OMC)" OMEGA_BRIDGE="$(OMEGA_BRIDGE)" sh om/units.sh --check 98 99 # Each mutant is one edit of the .om source, compiled by the pinned omc into its own binding; the hosted 100 # fixture test must fail golden words or differ from the unmutated native Omega dump. 101 # Independent C-oracle parity is required separately by test-om-encoder-primary. 102 OM_ENC_MUTANTS = 's/^ret or base shl rb o 1 16$$/ret or base shl rb o 1 17/' \ 103 's/^p = 262144$$/p = 0/' \ 104 's/^const NOPC ulong `1032192`$$/const NOPC ulong `1032193`/' 105 test-om-encoder-mutants: build/test_codegen_freestanding test-om-encoder-ldg test-om-encoder-ldg-spec test-om-encoder-ldg-c 106 @[ -x "$(OMEGA_OMC)" ] && [ -f "$(OMEGA_BRIDGE)/src/toc.om" ] && [ -f "$(OMEGA_BRIDGE)/src/freest.om" ] || { echo "NOT_RUN: set pinned OMEGA_OMC and OMEGA_BRIDGE"; exit 3; } 107 @mkdir -p $(OM_ENC_DIR) 108 ./build/test_codegen_freestanding --dump > $(OM_ENC_DIR)/native-dump.txt 109 @n=0; for m in $(OM_ENC_MUTANTS); do n=$$((n+1)); d=$(OM_ENC_DIR)/mutant$$n; rm -rf $$d; mkdir -p $$d; \ 110 sed "$$m" om/encoder/bw_enc_sm121.om > $$d/bw_enc_sm121.om; \ 111 if cmp -s $$d/bw_enc_sm121.om om/encoder/bw_enc_sm121.om; then echo "MUTANT $$n BROKEN: '$$m' changed nothing"; exit 1; fi; \ 112 OMEGA_UNITS=$$(pwd)/$$d/bw_enc_sm121.om OMEGA_UNITS_DEST=$$d OMEGA_OMC="$(OMEGA_OMC)" \ 113 OMEGA_BRIDGE="$(OMEGA_BRIDGE)" sh om/units.sh > /dev/null || exit 1; \ 114 $(OM_ENC_BUILD) -o $$d/codegen tests/test_omega_codegen_freestanding.c $(OM_ENC_SRCS) \ 115 $(filter-out src/cudapp_om_bw_enc_sm121.c,$(CUDAPP_BINDING_SRCS)) $$d/cudapp_om_bw_enc_sm121.c || exit 1; \ 116 g=0; $$d/codegen --golden > $$d/golden.log 2>&1 || g=1; \ 117 c=0; $$d/codegen --dump > $$d/dump.txt 2>&1; cmp -s $$d/dump.txt $(OM_ENC_DIR)/native-dump.txt || c=1; \ 118 if [ $$g = 0 ] && [ $$c = 0 ]; then echo "MUTANT $$n SURVIVED: '$$m'"; exit 1; fi; \ 119 echo "mutant $$n red ('$$m'): golden words $$( [ $$g = 1 ] && echo FAIL || echo pass ), dump vs native Omega $$( [ $$c = 1 ] && echo DIFFERS || echo same )"; \ 120 done 121 122 .PHONY: test-om-encoder-ldg-c 123 $(OM_ENC_DIR)/ldg-c: gpu-engine-freestanding $(GPU_NO_POSIX_OBJS) tests/test_omega_codegen_freestanding.c src/omega_blackwell_codegen.c 124 @mkdir -p $(OM_ENC_DIR) 125 $(OM_ENC_BUILD) -DOMEGA_GPU_NO_POSIX -DCUDAPP_MIGRATION_PENDING_C_REGALLOC -DCUDAPP_MIGRATION_PENDING_C_CODEGEN_MATMUL \ 126 -DCUDAPP_MIGRATION_PENDING_C_ENCODER -DCUDAPP_MIGRATION_PENDING_C_BIND -DCUDAPP_MIGRATION_PENDING_C_PACK -DCUDAPP_MIGRATION_PENDING_C_CORE \ 127 -I$(GPU_NO_POSIX_DIR) -o $@ tests/test_omega_codegen_freestanding.c src/omega_blackwell_codegen.c src/omega_blackwell_matmul.c \ 128 src/sha256.c src/cudapp_freest_f16.c src/cudapp_freest_bw_scalar.c src/cudapp_freest_fixture_verify.c $(GPU_NO_POSIX_OBJS) 129 test-om-encoder-ldg-c: $(OM_ENC_DIR)/ldg-c 130 cat om/encoder/bw_enc_sm121.om om/encoder/ldg_mini.om > $(OM_ENC_DIR)/ldg-mini.om 131 $(OMEGA_OMC) < $(OM_ENC_DIR)/ldg-mini.om > $(OM_ENC_DIR)/ldg-mini 132 chmod +x $(OM_ENC_DIR)/ldg-mini 133 $(OM_ENC_DIR)/ldg-mini > $(OM_ENC_DIR)/ldg-mini.tape 134 $(OM_ENC_DIR)/ldg-mini expected > $(OM_ENC_DIR)/ldg-mini.om.bin 135 $(OM_ENC_DIR)/ldg-c --encoder-tape < $(OM_ENC_DIR)/ldg-mini.tape > $(OM_ENC_DIR)/ldg-mini.c.bin 136 cmp $(OM_ENC_DIR)/ldg-mini.om.bin $(OM_ENC_DIR)/ldg-mini.c.bin 137 sed '$(OM_ENC_LDG_PREFIX_SED)' om/encoder/bw_enc_sm121.om > $(OM_ENC_DIR)/ldg-before.om 138 @if cmp -s $(OM_ENC_DIR)/ldg-before.om om/encoder/bw_enc_sm121.om; then echo 'FAIL pre-fix LDG reversal changed nothing'; exit 1; fi 139 cat om/encoder/ldg_mini.om >> $(OM_ENC_DIR)/ldg-before.om 140 $(OMEGA_OMC) < $(OM_ENC_DIR)/ldg-before.om > $(OM_ENC_DIR)/ldg-before 141 chmod +x $(OM_ENC_DIR)/ldg-before 142 $(OM_ENC_DIR)/ldg-before expected > $(OM_ENC_DIR)/ldg-mini.before.bin 143 @if cmp -s $(OM_ENC_DIR)/ldg-mini.before.bin $(OM_ENC_DIR)/ldg-mini.c.bin; then echo 'FAIL pre-fix LDG witness unexpectedly agrees'; exit 1; fi 144 @echo 'PASS one-instruction LDG C parity; pre-fix seeded encoder differs; public Mesa field selects C as correct' 145 OM_ENC_GUARD = $(OM_ENC_DIR)/guard-pred 146 # DRA-483 (C1b): om/encoder/guard_pred_test.om, composed after the encoder and compiled by the pinned omc. Every 147 # emitting op 0..79 encoded @P0 and @!P0 must carry guard 0 / 8 in w0 bits 12..15 and equal the unpredicated words 148 # otherwise. DSETP (op 72) is encoded with no GPR destination. LDCU / LDCU.64 (uniform datapath, guard bits name 149 # UP0..UPT) must refuse both forms; the omega-mv #1044 bool and trap rows through the program entry must get 150 # guards 7, 0, 8, 8, 8. ORACLE NVIDIA nvdisasm 13.0.85 (offline, read-only, never shipped) must print @P0 / @!P0 151 # on the 156 P-guarded words, @UP0 / @!UP0 on the 4 LDCU probe words and the five #1044 guards. Then 152 # om/encoder/guard_spec_test.om: the spec encoder sp_enc (bc_encode's path) must equal enc1 on every op 0..59 153 # unpredicated, @P0 and @!P0. sp_enc does not emit ops 60..79; enc1 does, and this gate checks those on enc1. 154 # Red checks: each triple is the file edited, the failure count the gate must print (exit 1), then one edit. 155 # enc 152: the guard left as each op encodes it (the pre-fix behaviour except the LDCU refusal). 156 # The #280 wrapper owns both EXIT guard forms; removing it loses one more form than main's partial EXIT guard. 157 # Ops 65..79 encode guard 7 in the opcode word, so they fail this edit too. 158 # enc 160: the guard forced to 7 (always) again. enc 81: @!P0 encoded as @P0. enc 4: LDCU / LDCU.64 accept a P 159 # guard. spec 106: sp_enc without the guard. spec 4: sp_enc accepts a P guard on LDCU / LDCU.64. Oracle red: no 160 # @!UP0 lines exits 4. 161 OM_ENC_GUARD_RED = enc 152 's/^put w 0 or sub x and x 61440 shl pred o 12$$/put w 0 x/' \ 162 enc 160 's/^put w 0 or sub x and x 61440 shl pred o 12$$/put w 0 or sub x and x 61440 shl ulong 7 12/' \ 163 enc 81 's/^put w 0 or sub x and x 61440 shl pred o 12$$/put w 0 or sub x and x 61440 shl and pred o 7 12/' \ 164 enc 4 's/^if isuld op$$/if eq op 99/' \ 165 spec 106 's/^put w 0 or sub gx and gx 61440 shl sp_val R_PRED 0 o 12$$/put w 0 gx/' \ 166 spec 4 's/^if or eq get o 0 6 eq get o 0 7$$/if eq get o 0 99/' 167 .PHONY: test-om-encoder-guard 168 test-om-encoder-guard: om/encoder/bw_enc_sm121.om om/encoder/bw_spec_sm121.om om/encoder/guard_pred_test.om \ 169 om/encoder/guard_spec_test.om 170 @[ -x "$(OMEGA_OMC)" ] && [ "$$(sha256sum < $(OMEGA_OMC) | cut -c1-64)" = `2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f` ] || { echo "NOT_RUN: set OMEGA_OMC to the pinned seeded compiler"; exit 3; } 171 @case "$$($(NVDISASM) --version 2>/dev/null)" in *V13.0.85*) ;; *) echo "NOT_RUN: nvdisasm version must be 13.0.85"; exit 3;; esac 172 @mkdir -p $(OM_ENC_DIR) 173 cat om/encoder/bw_enc_sm121.om om/encoder/guard_pred_test.om > $(OM_ENC_GUARD).om 174 $(OMEGA_OMC) < $(OM_ENC_GUARD).om > $(OM_ENC_GUARD) 175 chmod +x $(OM_ENC_GUARD) 176 $(OM_ENC_GUARD) 177 $(OM_ENC_GUARD) bin > $(OM_ENC_GUARD).bin 178 $(NVDISASM) -b SM121 -hex $(OM_ENC_GUARD).bin > $(OM_ENC_GUARD).nv 179 $(OM_ENC_GUARD) check oracle < $(OM_ENC_GUARD).nv 180 cat om/encoder/bw_enc_sm121.om om/encoder/bw_spec_sm121.om om/encoder/guard_spec_test.om > $(OM_ENC_GUARD)-spec.om 181 $(OMEGA_OMC) < $(OM_ENC_GUARD)-spec.om > $(OM_ENC_GUARD)-spec 182 chmod +x $(OM_ENC_GUARD)-spec 183 $(OM_ENC_GUARD)-spec 184 @set -- $(OM_ENC_GUARD_RED); n=0; while [ $$# -gt 0 ]; do f=$$1; want=$$2; m=$$3; shift 3; n=$$((n+1)); d=$(OM_ENC_GUARD)-red$$n; \ 185 if [ $$f = enc ]; then src=om/encoder/bw_enc_sm121.om; else src=om/encoder/bw_spec_sm121.om; fi; \ 186 sed "$$m" $$src > $$d.om; \ 187 if cmp -s $$d.om $$src; then echo "RED CHECK $$n BROKEN: '$$m' changed nothing"; exit 1; fi; \ 188 if [ $$f = enc ]; then cat $$d.om om/encoder/guard_pred_test.om; \ 189 else cat om/encoder/bw_enc_sm121.om $$d.om om/encoder/guard_spec_test.om; fi | $(OMEGA_OMC) > $$d || exit 1; \ 190 chmod +x $$d; rc=0; $$d > $$d.txt || rc=$$?; got=$$(tail -n 1 $$d.txt); \ 191 if [ $$f = enc ]; then exp="guard predicate failures: $$want"; else exp="spec guard mismatches: $$want"; fi; \ 192 if [ $$rc != 1 ] || [ "$$got" != "$$exp" ]; then echo "RED CHECK $$n BROKEN: '$$m' exited $$rc, '$$got', not 1 with '$$exp'"; exit 1; fi; \ 193 echo "red check $$n ($$f): '$$m' exits 1 with $$want failures, as it must"; done 194 @rc=0; grep -v -- '@!UP0' $(OM_ENC_GUARD).nv | $(OM_ENC_GUARD) check oracle > /dev/null || rc=$$?; \ 195 if [ $$rc != 4 ]; then echo "RED CHECK BROKEN: oracle text without @!UP0 exited $$rc, not 4"; exit 1; fi; \ 196 echo "red check: oracle text without the @!UP0 lines exits 4, as it must" 197 @echo "PASS guard predicates: 78 ops x @P0/@!P0 exact guard, LDCU/LDCU.64 refused, #1044 bool/trap rows, nvdisasm 13.0.85 prints all 165 guards, sp_enc = enc1 on 180 forms. GB10 DEVICE NOT_RUN" 198 199 # Sampling, normalization and verification live in seeded Omega; the C test only routes the tape. 200 # The per-form and per-edge acceptance counts must equal the committed receipt: a sampler or encoder change that 201 # moves an acceptance needs a new receipt directory (earlier receipts stay unedited). 202 OM_ENC_PRIMARY_RECEIPT = evidence/encoder-primary-integ-280-`20261110` 203 .PHONY: test-om-encoder-primary 204 test-om-encoder-primary: test-no-posix-native build/test_codegen_hosted 205 @mkdir -p $(OM_ENC_DIR) 206 { printf 'om2\n'; cat om/encoder/bw_enc_sm121.om om/encoder/primary_parity.om; } | $(OMEGA_OMC) > $(OM_ENC_DIR)/primary-parity 207 chmod +x $(OM_ENC_DIR)/primary-parity 208 $(OM_ENC_DIR)/primary-parity t > $(OM_ENC_DIR)/primary-tape.bin 209 build/no_posix/check/codegen-oracle --encoder-tape < $(OM_ENC_DIR)/primary-tape.bin > $(OM_ENC_DIR)/primary-c.bin 210 build/test_codegen_freestanding --encoder-tape < $(OM_ENC_DIR)/primary-tape.bin > $(OM_ENC_DIR)/primary-native.bin 211 build/test_codegen_hosted --encoder-tape < $(OM_ENC_DIR)/primary-tape.bin > $(OM_ENC_DIR)/primary-hosted.bin 212 $(OM_ENC_DIR)/primary-parity c < $(OM_ENC_DIR)/primary-c.bin 2> $(OM_ENC_DIR)/primary-counts.txt 213 cmp $(OM_ENC_DIR)/primary-c.bin $(OM_ENC_DIR)/primary-native.bin 214 cmp $(OM_ENC_DIR)/primary-c.bin $(OM_ENC_DIR)/primary-hosted.bin 215 @rc=0; $(OM_ENC_DIR)/primary-parity r < $(OM_ENC_DIR)/primary-c.bin > /dev/null 2> $(OM_ENC_DIR)/primary-red.txt || rc=$$?; test $$rc = 1 216 cmp $(OM_ENC_DIR)/primary-counts.txt $(OM_ENC_PRIMARY_RECEIPT)/parity-counts.txt 217 @echo 'PASS encoder primary: 1024 samples per operand form, eight forms per opcode 0..79, 44 refusal-edge samples per opcode 0..81, C oracle = native = hosted = seeded conductor, counts = $(OM_ENC_PRIMARY_RECEIPT); flipped-byte control refused' 218 NVDISASM ?= /usr/local/cuda/bin/nvdisasm 219 OM_ENC_LDG = $(OM_ENC_DIR)/ldg-offset 220 # The pre-fix op-11 line (base `cb3395aa`) differs from the fixed line only by the dropped offset term, so 221 # test-om-encoder-ldg-c and red check 11 rebuild it from the current source: neither needs Git history 222 # (shallow CI checkout). Red checks: each pair is the exit the gate must give, then one edit of the encoder. 223 # 11: the pre-fix op-11 line drops the offset (row 1, +0x40). 20: a field bound widened by one accepts 224 # +0x800000 (refused row 0). 225 OM_ENC_LDG_PREFIX_SED = s/^put4 w wda o 31105 or rb o 5 shl and imm `16777215` 8 `203299072` ctl o 991744$$/put4 w wda o 31105 rb o 5 `203299072` ctl o 991744/ 226 OM_ENC_LDG_RED = 11 '$(OM_ENC_LDG_PREFIX_SED)' \ 227 20 's/^ret or lt imm `8388608` ge imm `4286578688`$$/ret or lt imm `8388609` ge imm `4286578687`/' 228 .PHONY: test-om-encoder-ldg 229 test-om-encoder-ldg: om/encoder/bw_enc_sm121.om om/encoder/ldg_offset_test.om 230 @[ -x "$(OMEGA_OMC)" ] && [ "$$(sha256sum < $(OMEGA_OMC) | cut -c1-64)" = `2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f` ] || { echo "NOT_RUN: set OMEGA_OMC to the pinned seeded compiler"; exit 3; } 231 @case "$$($(NVDISASM) --version 2>/dev/null)" in *V13.0.85*) ;; *) echo "NOT_RUN: nvdisasm version must be 13.0.85"; exit 3;; esac 232 @mkdir -p $(OM_ENC_DIR) 233 cat om/encoder/bw_enc_sm121.om om/encoder/ldg_offset_test.om > $(OM_ENC_LDG).om 234 $(OMEGA_OMC) < $(OM_ENC_LDG).om > $(OM_ENC_LDG) 235 chmod +x $(OM_ENC_LDG) 236 $(OM_ENC_LDG) 237 $(OM_ENC_LDG) bin > $(OM_ENC_LDG).bin 238 $(NVDISASM) -b SM121 -hex $(OM_ENC_LDG).bin > $(OM_ENC_LDG).nv 239 $(OM_ENC_LDG) check oracle < $(OM_ENC_LDG).nv 240 @set -- $(OM_ENC_LDG_RED); n=0; while [ $$# -gt 0 ]; do want=$$1; m=$$2; shift 2; n=$$((n+1)); d=$(OM_ENC_LDG)-red$$n; \ 241 sed "$$m" om/encoder/bw_enc_sm121.om > $$d.om; \ 242 if cmp -s $$d.om om/encoder/bw_enc_sm121.om; then echo "RED CHECK $$n BROKEN: '$$m' changed nothing"; exit 1; fi; \ 243 cat $$d.om om/encoder/ldg_offset_test.om | $(OMEGA_OMC) > $$d || exit 1; \ 244 chmod +x $$d; rc=0; $$d || rc=$$?; \ 245 if [ $$rc != $$want ]; then echo "RED CHECK $$n BROKEN: '$$m' exited $$rc, not $$want"; exit 1; fi; \ 246 echo "red check $$n: '$$m' exits $$rc, as it must"; done 247 @rc=0; grep -v -- '-0x800000' $(OM_ENC_LDG).nv | $(OM_ENC_LDG) check oracle || rc=$$?; \ 248 if [ $$rc != 4 ]; then echo "RED CHECK BROKEN: oracle text without -0x800000 exited $$rc, not 4"; exit 1; fi; \ 249 echo "red check: oracle text without the -0x800000 line exits 4, as it must" 250 @echo "PASS LDG.E offset: 5 exact words, 4 refusals, nvdisasm 13.0.85 decodes all 5. GB10 DEVICE NOT_RUN" 251 252 .PHONY: test-om-encoder-ldg-spec 253 test-om-encoder-ldg-spec: 254 @mkdir -p $(OM_ENC_DIR) 255 cat om/encoder/bw_enc_sm121.om om/encoder/bw_spec_sm121.om om/encoder/ldg_spec_test.om > $(OM_ENC_DIR)/ldg-spec.om 256 $(OMEGA_OMC) < $(OM_ENC_DIR)/ldg-spec.om > $(OM_ENC_DIR)/ldg-spec 257 chmod +x $(OM_ENC_DIR)/ldg-spec 258 $(OM_ENC_DIR)/ldg-spec 259 @rc=0; $(OM_ENC_DIR)/ldg-spec red || rc=$$?; test $$rc = 1 260 @echo 'PASS LDG spec: nine signed-offset/boundary cases equal primitive encoder; omitted-field control refused' 261 262 OM_ENC_ATOMG = $(OM_ENC_DIR)/atomg-min 263 # Red checks as for test-om-encoder-ldg. 10: type 2 -> 3 encodes the signed .S64 min (row 0). 11: the destination 264 # field ignores its presence flag, so an absent destination is not RZ (row 1). 265 OM_ENC_ATOMG_RED = 10 's/^put4 w a or rb o 3 `2147483648` or `144659712` rb o 5 ctl o `3284480`$$/put4 w a or rb o 3 `2147483648` or `144660224` rb o 5 ctl o `3284480`/' \ 266 11 's/^a = or or 31144 shl rz o 1 15 16 shl rb o 2 24$$/a = or or 31144 shl rb o 1 16 shl rb o 2 24/' 267 .PHONY: test-om-encoder-atomg 268 test-om-encoder-atomg: om/encoder/bw_enc_sm121.om om/encoder/atomg_min_test.om 269 @[ -x "$(OMEGA_OMC)" ] && [ "$$(sha256sum < $(OMEGA_OMC) | cut -c1-64)" = `2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f` ] || { echo "NOT_RUN: set OMEGA_OMC to the pinned seeded compiler"; exit 3; } 270 @case "$$($(NVDISASM) --version 2>/dev/null)" in *V13.0.85*) ;; *) echo "NOT_RUN: nvdisasm version must be 13.0.85"; exit 3;; esac 271 @mkdir -p $(OM_ENC_DIR) 272 cat om/encoder/bw_enc_sm121.om om/encoder/atomg_min_test.om > $(OM_ENC_ATOMG).om 273 $(OMEGA_OMC) < $(OM_ENC_ATOMG).om > $(OM_ENC_ATOMG) 274 chmod +x $(OM_ENC_ATOMG) 275 $(OM_ENC_ATOMG) 276 $(OM_ENC_ATOMG) bin > $(OM_ENC_ATOMG).bin 277 $(NVDISASM) -b SM121 -hex $(OM_ENC_ATOMG).bin > $(OM_ENC_ATOMG).nv 278 $(OM_ENC_ATOMG) check oracle < $(OM_ENC_ATOMG).nv 279 @set -- $(OM_ENC_ATOMG_RED); n=0; while [ $$# -gt 0 ]; do want=$$1; m=$$2; shift 2; n=$$((n+1)); d=$(OM_ENC_ATOMG)-red$$n; \ 280 sed "$$m" om/encoder/bw_enc_sm121.om > $$d.om; \ 281 if cmp -s $$d.om om/encoder/bw_enc_sm121.om; then echo "RED CHECK $$n BROKEN: '$$m' changed nothing"; exit 1; fi; \ 282 cat $$d.om om/encoder/atomg_min_test.om | $(OMEGA_OMC) > $$d || exit 1; \ 283 chmod +x $$d; rc=0; $$d || rc=$$?; \ 284 if [ $$rc != $$want ]; then echo "RED CHECK $$n BROKEN: '$$m' exited $$rc, not $$want"; exit 1; fi; \ 285 echo "red check $$n: '$$m' exits $$rc, as it must"; done 286 @rc=0; grep -v -- 'R14' $(OM_ENC_ATOMG).nv | $(OM_ENC_ATOMG) check oracle || rc=$$?; \ 287 if [ $$rc != 4 ]; then echo "RED CHECK BROKEN: oracle text without the R14 line exited $$rc, not 4"; exit 1; fi; \ 288 echo "red check: oracle text without the R14 line exits 4, as it must" 289 @echo "PASS ATOMG.E.MIN.64.STRONG.SYS: 3 exact rows, nvdisasm 13.0.85 decodes all 3. GB10 DEVICE NOT_RUN"