omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / mk / omega-gpu-engine.mk
| 1 | # Omega GPU Engine (docs/numeric/OMEGA_GPU_ENGINE.md). Picked up by |
| 2 | # `-include mk/*.mk`. Host only: opens no device; needs no physics headers except the two A3b1 targets, not |
| 3 | # part of `all` or `test`. |
| 4 | # test-gpu-engine-compile header + core compile, enum names, refusals, no-op backend (A2/A3a) |
| 5 | # test-gpu-engine the engine core against a fake backend (every state and failure) |
| 6 | # test-gpu-engine-backend-compile syntax-checks src/omega_blackwell_engine.c (A3b1): -c only, no link, no device |
| 7 | # test-gpu-engine-prod-build production build of build/omegatool at the physics pin: links only, opens no device |
| 8 | # test-gpu-engine-mutants removes each protection from src/omega_gpu_engine.c in a scratch |
| 9 | # copy; the host test must fail each one (exit nonzero on a survivor) |
| 10 | # test-gpu-engine-sim (A3b2) the REAL engine core + Blackwell backend + vector wrapper against a simulated driver |
| 11 | # (tests/fake_m16_native.c); host only, no device, no physics C sources |
| 12 | # test-gpu-engine-backend-mutants (A3b2) one mutant per protection in the backend and the vector wrapper |
| 13 | # test-gpu-engine-gb10-compile (A3b2) compile-only check of tests/test_omega_gpu_engine_gb10.c (Phase B chip test, never run here) |
| 14 | # gpu-engine-freestanding (native v1 P07 cut A) the portable GPU files built -ffreestanding with |
| 15 | # OMEGA_GPU_NO_POSIX: no Linux header, no errno, no clock, no libc beyond mem*/str* |
| 16 | # test-codegen-freestanding (cut A.2) codegen hosted vs freestanding byte-identical, bounded code buffers, |
| 17 | # and test-sha256-freestanding-parity (hosted vs freestanding SHA-256 binding) |
| 18 | # test-gpu-engine-freestanding the engine contract test and the platform contract test linked against |
| 19 | # those freestanding objects (host runner, opens no device) |
| 20 | .PHONY: test-gpu-engine-compile test-gpu-engine test-gpu-engine-mutants test-gpu-engine-backend-compile test-gpu-engine-prod-build test-gpu-engine-sim test-gpu-engine-backend-mutants test-gpu-engine-gb10-compile gpu-engine-freestanding test-gpu-engine-freestanding |
| 21 | build/test_omega_gpu_engine_compile: tests/test_omega_gpu_engine_compile.c src/omega_gpu_engine.c src/omega_gpu_engine.h |
| 22 | @mkdir -p build |
| 23 | gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -DOMEGA_NUMERIC_CPU_ONLY -o $@ tests/test_omega_gpu_engine_compile.c src/omega_gpu_engine.c |
| 24 | test-gpu-engine-compile: build/test_omega_gpu_engine_compile |
| 25 | ./build/test_omega_gpu_engine_compile |
| 26 | |
| 27 | build/test_omega_gpu_engine: tests/test_omega_gpu_engine.c src/omega_gpu_engine.c src/omega_gpu_engine.h |
| 28 | @mkdir -p build |
| 29 | gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -DOMEGA_NUMERIC_CPU_ONLY -o $@ tests/test_omega_gpu_engine.c src/omega_gpu_engine.c |
| 30 | test-gpu-engine: build/test_omega_gpu_engine |
| 31 | ./build/test_omega_gpu_engine |
| 32 | |
| 33 | test-gpu-engine-mutants: |
| 34 | sh tools/gpu_engine_mutations.sh |
| 35 | |
| 36 | # A3b1: the Blackwell backend includes physics headers (m16_native.h, nvrm.h), so it |
| 37 | # uses the same physics -I paths as the top-level Makefile CFLAGS (Makefile lines 9-14). |
| 38 | GPU_ENGINE_PHYS_INC = -I$(PHYSICS_DIR)/m16 -I$(PHYSICS_DIR)/nvrm \ |
| 39 | -I$(PHYSICS_DIR)/third_party/nvidia-open-580.173.02/src/common/sdk/nvidia/inc \ |
| 40 | -I$(PHYSICS_DIR)/third_party/nvidia-open-580.173.02/kernel-open/common/inc \ |
| 41 | -I$(PHYSICS_DIR)/third_party/nvidia-open-580.173.02/kernel-open/nvidia-uvm \ |
| 42 | -I$(PHYSICS_DIR)/third_party/nvidia-open-580.173.02/src/nvidia/arch/nvalloc/unix/include |
| 43 | |
| 44 | build/omega_blackwell_engine_syntax.o: src/omega_blackwell_engine.c src/omega_blackwell_engine.h src/omega_gpu_engine.h |
| 45 | @mkdir -p build |
| 46 | gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -Isrc $(GPU_ENGINE_PHYS_INC) -c -o $@ src/omega_blackwell_engine.c |
| 47 | test-gpu-engine-backend-compile: build/omega_blackwell_engine_syntax.o |
| 48 | |
| 49 | # Links only, opens no device. Uses the real m16_native and nvrm sources at the physics pin. |
| 50 | test-gpu-engine-prod-build: |
| 51 | $(MAKE) build/omegatool |
| 52 | |
| 53 | # A3b2: simulated-driver host test. Links the sources of the Makefile RX_COMPOSE_GPU_SRCS list (plus the |
| 54 | # three core files the vector builder needs) with tests/fake_m16_native.c in place of the physics |
| 55 | # m16_native.c and nvrm.c. Opens no device. |
| 56 | GPU_ENGINE_SIM_SRCS = src/omega_blackwell_submit.c src/omega_blackwell_engine.c src/omega_gpu_engine.c \ |
| 57 | src/omega_blackwell_matmul.c src/omega_blackwell_codegen.c src/omega_blackwell_encoder.c \ |
| 58 | src/omega_blackwell_qmd.c src/omega_blackwell_realize.c src/omega_vector.c src/omega_validate.c \ |
| 59 | src/omega_core.c src/omega_canonical.c src/omega_om_units.c |
| 60 | |
| 61 | build/test_omega_blackwell_engine: tests/test_omega_blackwell_engine.c tests/fake_m16_native.c tests/fake_m16_native.h \ |
| 62 | $(GPU_ENGINE_SIM_SRCS) src/omega_gpu_engine.h src/omega_blackwell_engine.h |
| 63 | @mkdir -p build |
| 64 | gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -pthread -ffunction-sections -fdata-sections \ |
| 65 | -Isrc -Itests $(GPU_ENGINE_PHYS_INC) -o $@ tests/test_omega_blackwell_engine.c tests/fake_m16_native.c \ |
| 66 | $(GPU_ENGINE_SIM_SRCS) -Wl,--gc-sections -lm |
| 67 | test-gpu-engine-sim: build/test_omega_blackwell_engine |
| 68 | ./build/test_omega_blackwell_engine |
| 69 | |
| 70 | # One mutant per backend and vector-wrapper protection; the sim test must fail each one. |
| 71 | test-gpu-engine-backend-mutants: |
| 72 | PHYSICS_DIR="$(PHYSICS_DIR)" sh tools/gpu_engine_backend_mutations.sh |
| 73 | |
| 74 | # Phase B chip test, compile only here. Never run in Phase A. |
| 75 | build/test_omega_gpu_engine_gb10.o: tests/test_omega_gpu_engine_gb10.c src/omega_gpu_engine.h src/omega_blackwell_engine.h src/omega_blackwell_submit.h |
| 76 | @mkdir -p build |
| 77 | gcc -std=gnu11 -O2 -Wall -Wextra -Werror -ffp-contract=off -fno-fast-math -pthread -Isrc $(GPU_ENGINE_PHYS_INC) -c -o $@ tests/test_omega_gpu_engine_gb10.c |
| 78 | test-gpu-engine-gb10-compile: build/test_omega_gpu_engine_gb10.o |
| 79 | |
| 80 | # Measurement (sc#277): driver allocations and frees made by the REAL session + matmul + attention |
| 81 | # APIs while serving a Qwen3-4B-shaped sequence, against the simulated driver. Host only, no device. |
| 82 | # Prints MEASURE lines; asserts only bookkeeping. Links no physics C sources, only its headers. |
| 83 | GPU_SERVE_ALLOC_SRCS = src/omega_gpu_session.c src/omega_gpu_platform.c src/omega_gpu_platform_linux.c src/omega_gpu_fmt.c src/omega_gpu_matmul_api.c src/omega_gpu_attention_api.c src/omega_gpu_serving.c \ |
| 84 | src/omega_gpu_wait.c src/omega_blackwell_codegen.c src/omega_blackwell_encoder.c src/omega_blackwell_qmd.c \ |
| 85 | src/omega_blackwell_matmul.c src/omega_om_units.c |
| 86 | build/gpu_serving_alloc_count_test: tests/gpu_serving_alloc_count_test.c tests/fake_m16_native.c tests/fake_m16_native.h $(GPU_SERVE_ALLOC_SRCS) |
| 87 | @mkdir -p build |
| 88 | gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -pthread -ffp-contract=off -Isrc -Itests $(GPU_ENGINE_PHYS_INC) \ |
| 89 | -o $@ tests/gpu_serving_alloc_count_test.c tests/fake_m16_native.c $(GPU_SERVE_ALLOC_SRCS) -lm |
| 90 | .PHONY: test-gpu-serving-alloc |
| 91 | test-gpu-serving-alloc: build/gpu_serving_alloc_count_test |
| 92 | ./build/gpu_serving_alloc_count_test plain |
| 93 | ./build/gpu_serving_alloc_count_test reserve |
| 94 | ./build/gpu_serving_alloc_count_test bounds |
| 95 | ./build/gpu_serving_alloc_count_test bounds-block |
| 96 | ./build/gpu_serving_alloc_count_test rollback |
| 97 | ./build/gpu_serving_alloc_count_test sweep |
| 98 | ./build/gpu_serving_alloc_count_test pin |
| 99 | ./build/gpu_serving_alloc_count_test seal-bare |
| 100 | ./build/gpu_serving_alloc_count_test update |
| 101 | @if ./build/gpu_serving_alloc_count_test sweep-skip >build/gpu_serving_alloc_count_sweep_skip.log 2>&1; then echo "RED RUN PASSED: zero allocations over the row sweep do not need prepare + seal"; exit 1; fi |
| 102 | @if [ "$$(grep -c "^FAIL" build/gpu_serving_alloc_count_sweep_skip.log)" -lt 1 ]; then echo "sweep-skip exited nonzero without a FAIL check (crash, not the red assertion)"; exit 1; fi |
| 103 | @grep -E "^MEASURE sweep" build/gpu_serving_alloc_count_sweep_skip.log | sed "s/^/sweep-skip (control): /" |
| 104 | @if ./build/gpu_serving_alloc_count_test reserve-skip >build/gpu_serving_alloc_count_skip.log 2>&1; then echo "RED RUN PASSED: the zero-allocation assertion does not need the reservation call"; exit 1; fi |
| 105 | @if [ "$$(grep -c "^FAIL" build/gpu_serving_alloc_count_skip.log)" -lt 1 ]; then echo "reserve-skip exited nonzero without a FAIL check (crash, not the red assertion)"; exit 1; fi |
| 106 | @echo "reserve-skip (no reservation call): fails as required ($$(grep -c "^FAIL" build/gpu_serving_alloc_count_skip.log) failing checks)" |
| 107 | |
| 108 | # native v1 P07 cut A (aienos#286 cut A, aien-architecture#190): the freestanding link target. |
| 109 | # Each file below is compiled with no hosted headers available (-ffreestanding, -fno-builtin, |
| 110 | # OMEGA_GPU_NO_POSIX) and the partial link of all of them may leave only the mem*/str* symbols |
| 111 | # undefined. Any other undefined symbol (errno, clock_gettime, printf, malloc, pthread_*, nvrm_*, |
| 112 | # m16_*) fails the target. This proves the first-compute PATH links without Linux headers or |
| 113 | # runtime symbols; it proves nothing about device ownership (NOT_RUN until cut B runs on the Spark). |
| 114 | GPU_FS_DIR = build/gpu_fs |
| 115 | GPU_FS_CFLAGS = -std=gnu11 -O2 -Wall -Wextra -Werror -ffreestanding -fno-builtin -fno-stack-protector \ |
| 116 | -U_FORTIFY_SOURCE -DOMEGA_GPU_NO_POSIX -DOMEGA_NUMERIC_CPU_ONLY -Isrc |
| 117 | # P07 cut C (session part): the persistent session, the matmul and attention APIs, the serving reservation and the |
| 118 | # bounded wait join the link. Their machine comes from an installed OmegaGpuPlatform; the Linux reference |
| 119 | # (src/omega_gpu_platform_linux.c) is deliberately NOT in this list. Still outside it: the elementwise API, the |
| 120 | # numeric launchers, the vector executor, the resident runtime (docs/numeric/OMEGA_GPU_NATIVE_BOUNDARY.md). |
| 121 | # The Omega SHA-256 joins as src/omega_om_units_fs.c (om/units.sh, the bridge's freestanding outputs freest and |
| 122 | # fapic): the hosted binding src/omega_om_units.c needs pthread TLS, mmap/mprotect/munmap and abort. |
| 123 | GPU_FS_SRCS = src/omega_gpu_engine.c src/omega_gpu_platform.c src/omega_blackwell_encoder.c src/omega_blackwell_codegen.c \ |
| 124 | src/omega_blackwell_matmul.c src/omega_blackwell_qmd.c src/omega_blackwell_realize.c src/omega_om_units_fs.c \ |
| 125 | src/omega_gpu_session.c src/omega_gpu_fmt.c src/omega_gpu_matmul_api.c src/omega_gpu_attention_api.c \ |
| 126 | src/omega_gpu_serving.c src/omega_gpu_wait.c |
| 127 | GPU_FS_HDRS = src/omega_gpu_engine.h src/omega_gpu_platform.h src/omega_blackwell_codegen.h src/omega_blackwell_matmul.h \ |
| 128 | src/omega_gpu_session.h src/omega_gpu_fmt.h src/omega_gpu_matmul_api.h src/omega_gpu_attention_api.h \ |
| 129 | src/omega_gpu_serving.h src/omega_gpu_wait.h |
| 130 | GPU_FS_OBJS = $(patsubst src/%.c,$(GPU_FS_DIR)/%.o,$(GPU_FS_SRCS)) |
| 131 | GPU_FS_LINK = $(GPU_FS_DIR)/omega_gpu_freestanding.o |
| 132 | GPU_FS_ALLOWED = memcpy|memmove|memset|memcmp|strlen|strcmp |
| 133 | |
| 134 | $(GPU_FS_DIR)/%.o: src/%.c $(GPU_FS_HDRS) |
| 135 | @mkdir -p $(GPU_FS_DIR) |
| 136 | gcc $(GPU_FS_CFLAGS) -c -o $@ $< |
| 137 | |
| 138 | $(GPU_FS_LINK): $(GPU_FS_OBJS) |
| 139 | gcc -r -nostdlib -o $@ $(GPU_FS_OBJS) |
| 140 | @bad=$$(nm -u $@ | awk '{print $$NF}' | grep -Ev '^(_GLOBAL_OFFSET_TABLE_|($(GPU_FS_ALLOWED)))$$' || true); \ |
| 141 | if [ -n "$$bad" ]; then echo "freestanding GPU link still needs: $$bad"; rm -f $@; exit 1; fi |
| 142 | @echo "freestanding GPU link ($(words $(GPU_FS_SRCS)) files): only $$(nm -u $@ | awk '{print $$NF}' | grep -Ev '^_GLOBAL_OFFSET_TABLE_$$' | sort -u | tr '\n' ' ')undefined" |
| 143 | gpu-engine-freestanding: $(GPU_FS_LINK) |
| 144 | |
| 145 | build/test_omega_gpu_engine_freestanding: tests/test_omega_gpu_engine.c $(GPU_FS_DIR)/omega_gpu_engine.o src/omega_gpu_engine.h |
| 146 | @mkdir -p build |
| 147 | gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -DOMEGA_NUMERIC_CPU_ONLY -DOMEGA_GPU_NO_POSIX \ |
| 148 | -o $@ tests/test_omega_gpu_engine.c $(GPU_FS_DIR)/omega_gpu_engine.o |
| 149 | build/test_omega_gpu_platform: tests/test_omega_gpu_platform.c $(GPU_FS_DIR)/omega_gpu_platform.o src/omega_gpu_platform.h |
| 150 | @mkdir -p build |
| 151 | gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -o $@ tests/test_omega_gpu_platform.c $(GPU_FS_DIR)/omega_gpu_platform.o |
| 152 | test-gpu-engine-freestanding: $(GPU_FS_LINK) build/test_omega_gpu_engine_freestanding build/test_omega_gpu_platform |
| 153 | ./build/test_omega_gpu_engine_freestanding |
| 154 | ./build/test_omega_gpu_platform |
| 155 | |
| 156 | # native v1 P07 cut A.2 (aienos#286): code generation joins the freestanding link above with a caller-owned |
| 157 | # code buffer (omega_blackwell_kernel_encode_into, no allocator). The same test source is built hosted (the |
| 158 | # allocating generators) and freestanding (the *_prog generators into a caller buffer); their instruction |
| 159 | # stream dumps of every fixture must be byte-identical (cmp). The freestanding run then checks the bounded |
| 160 | # buffer contract, the golden-word fixture verifiers on the freestanding object and the bf16 rounding path on |
| 161 | # all 2^32 inputs. The allowlist control links a malloc caller into the freestanding object and requires the |
| 162 | # nm -u check to refuse it (a check that can never fail proves nothing). |
| 163 | .PHONY: test-codegen-freestanding test-gpu-fs-allowlist-control |
| 164 | CODEGEN_FS_TEST_DEPS = tests/test_omega_codegen_freestanding.c src/omega_blackwell_codegen.h src/omega_blackwell_matmul.h |
| 165 | # The hosted side encodes through the .om encoder (om/encoder/bw_enc_sm121.om via src/omega_om_units.c), the |
| 166 | # freestanding side through the migration-pending C encoder, so the cmp below is also an .om-vs-C differential. |
| 167 | build/test_codegen_hosted: $(CODEGEN_FS_TEST_DEPS) src/omega_blackwell_codegen.c src/omega_blackwell_matmul.c src/omega_om_units.c \ |
| 168 | src/omega_native.h |
| 169 | @mkdir -p build |
| 170 | gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -o $@ tests/test_omega_codegen_freestanding.c \ |
| 171 | src/omega_blackwell_codegen.c src/omega_blackwell_matmul.c src/omega_om_units.c |
| 172 | build/test_codegen_freestanding: $(CODEGEN_FS_TEST_DEPS) $(GPU_FS_LINK) |
| 173 | @mkdir -p build |
| 174 | gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -DOMEGA_GPU_NO_POSIX -o $@ tests/test_omega_codegen_freestanding.c \ |
| 175 | $(GPU_FS_DIR)/omega_blackwell_codegen.o $(GPU_FS_DIR)/omega_blackwell_matmul.o $(GPU_FS_DIR)/omega_om_units_fs.o |
| 176 | |
| 177 | # The freestanding SHA-256 binding against the hosted one: tests/test_sha256_freestanding_parity.c built over |
| 178 | # src/omega_om_units.c (hosted) and over the GPU_FS_CFLAGS object of src/omega_om_units_fs.c must print the same |
| 179 | # digests (the FIPS 180-2 vectors; lengths 0..1100, 4096, 65536 and 1048583 of a fixed-seed stream one-shot and |
| 180 | # split), and the FIPS digests must be the published ones. Controls: the hosted codegen test hashes through the |
| 181 | # Omega binding (omega2_sha256_*), and a copy of the freestanding binding whose machine code loads round constant |
| 182 | # K[0] as 0x428a2f99 (movz x1,#0x2f98 -> #0x2f99) must FAIL the comparison. |
| 183 | .PHONY: test-sha256-freestanding-parity |
| 184 | SHA256_FS_PARITY_DEPS = tests/test_sha256_freestanding_parity.c src/sha256.h src/omega_api_decl.h src/omega_native.h |
| 185 | SHA256_FS_RED = build/sha256_parity_red |
| 186 | build/test_sha256_parity_hosted: $(SHA256_FS_PARITY_DEPS) src/omega_om_units.c |
| 187 | @mkdir -p build |
| 188 | gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -Isrc -o $@ tests/test_sha256_freestanding_parity.c src/omega_om_units.c -pthread |
| 189 | build/test_sha256_parity_freestanding: $(SHA256_FS_PARITY_DEPS) $(GPU_FS_DIR)/omega_om_units_fs.o |
| 190 | @mkdir -p build |
| 191 | gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -o $@ tests/test_sha256_freestanding_parity.c $(GPU_FS_DIR)/omega_om_units_fs.o |
| 192 | test-sha256-freestanding-parity: build/test_sha256_parity_hosted build/test_sha256_parity_freestanding build/test_codegen_hosted |
| 193 | ./build/test_sha256_parity_hosted > build/sha256_parity_hosted.txt |
| 194 | ./build/test_sha256_parity_freestanding > build/sha256_parity_freestanding.txt |
| 195 | cmp build/sha256_parity_hosted.txt build/sha256_parity_freestanding.txt |
| 196 | @printf 'fips %s\n' '0 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' \ |
| 197 | '1 ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad' \ |
| 198 | '2 248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1' \ |
| 199 | '3 cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0' > build/sha256_parity_fips.txt |
| 200 | @grep '^fips ' build/sha256_parity_freestanding.txt | cmp -s - build/sha256_parity_fips.txt \ |
| 201 | || { echo "sha256 freestanding parity: FIPS digests wrong"; exit 1; } |
| 202 | @[ "$$(grep -c '^len ' build/sha256_parity_freestanding.txt)" = 1104 ] || { echo "sha256 freestanding parity: expected 1104 lengths"; exit 1; } |
| 203 | @echo "sha256 freestanding parity: hosted and freestanding bindings agree on 4 FIPS vectors and 1104 lengths (0..1100, 4096, 65536, 1048583)" |
| 204 | @n=$$(nm build/test_codegen_hosted | grep -c ' T omega2_sha256_'); [ "$$n" -ge 4 ] || \ |
| 205 | { echo "FAIL: the hosted codegen test does not hash through the Omega binding"; exit 1; }; \ |
| 206 | echo "control: hosted codegen test links $$n omega2_sha256_* functions" |
| 207 | @mkdir -p $(SHA256_FS_RED) |
| 208 | sed 's/0x01,0xf3,0x85,0xd2/0x21,0xf3,0x85,0xd2/' src/omega_om_units_fs.c > $(SHA256_FS_RED)/red.c |
| 209 | @! cmp -s $(SHA256_FS_RED)/red.c src/omega_om_units_fs.c || { echo "RED MUTANT BROKEN: sed changed nothing"; exit 1; } |
| 210 | gcc $(GPU_FS_CFLAGS) -c -o $(SHA256_FS_RED)/red.o $(SHA256_FS_RED)/red.c |
| 211 | gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -o $(SHA256_FS_RED)/parity_red tests/test_sha256_freestanding_parity.c \ |
| 212 | $(SHA256_FS_RED)/red.o |
| 213 | @./$(SHA256_FS_RED)/parity_red > $(SHA256_FS_RED)/red.txt || true; \ |
| 214 | if cmp -s $(SHA256_FS_RED)/red.txt build/sha256_parity_hosted.txt; then echo "RED CHECK BROKEN: a wrong round constant passed"; exit 1; \ |
| 215 | else echo "red check: K[0] changed in the freestanding machine code FAILS the comparison ($$(cmp $(SHA256_FS_RED)/red.txt build/sha256_parity_hosted.txt | head -1))"; fi |
| 216 | test-codegen-freestanding: build/test_codegen_hosted build/test_codegen_freestanding test-gpu-fs-allowlist-control \ |
| 217 | test-sha256-freestanding-parity |
| 218 | ./build/test_codegen_hosted --dump > build/codegen_dump_hosted.txt |
| 219 | ./build/test_codegen_freestanding --dump > build/codegen_dump_freestanding.txt |
| 220 | cmp build/codegen_dump_hosted.txt build/codegen_dump_freestanding.txt |
| 221 | @echo "codegen dumps byte-identical: $$(grep -c '^fixture ' build/codegen_dump_hosted.txt) fixtures, $$(grep -v -E '^(fixture|digest) ' build/codegen_dump_hosted.txt | tr -d '\n' | wc -c | awk '{print $$1/2}') code bytes" |
| 222 | ./build/test_codegen_freestanding |
| 223 | |
| 224 | test-gpu-fs-allowlist-control: $(GPU_FS_LINK) |
| 225 | @mkdir -p $(GPU_FS_DIR)/control |
| 226 | printf 'void *malloc(unsigned long);\nvoid *omega_gpu_fs_control(void) { return malloc(16); }\n' > $(GPU_FS_DIR)/control/canary.c |
| 227 | gcc $(GPU_FS_CFLAGS) -c -o $(GPU_FS_DIR)/control/canary.o $(GPU_FS_DIR)/control/canary.c |
| 228 | gcc -r -nostdlib -o $(GPU_FS_DIR)/control/with_canary.o $(GPU_FS_OBJS) $(GPU_FS_DIR)/control/canary.o |
| 229 | @bad=$$(nm -u $(GPU_FS_DIR)/control/with_canary.o | awk '{print $$NF}' | grep -Ev '^(_GLOBAL_OFFSET_TABLE_|($(GPU_FS_ALLOWED)))$$' || true); \ |
| 230 | if [ "$$bad" != "malloc" ]; then echo "allowlist control: expected exactly malloc refused, got '$$bad'"; exit 1; fi; \ |
| 231 | echo "allowlist control: a malloc caller is refused by the nm -u check (as required)" |
| 232 | |
| 233 | # native v1 P07 cut C, session part (aienos#286): the portable session over OmegaGpuPlatform. |
| 234 | # - test_omega_gpu_session_platform links the FREESTANDING partial-link object and drives it through a fake |
| 235 | # platform: install refusals, no default platform, typed GPU-uncached buffers, polling only, cancel before and |
| 236 | # after submit, timeout (latch + park, nothing released), stale handle after close/reopen, reservation refusal. |
| 237 | # - test_omega_gpu_platform_linux drives the Linux REFERENCE platform (reference only) on the simulated driver: |
| 238 | # same driver calls in the same order as before cut C, its refusals, and a marker that never lands. |
| 239 | # - the mutants prove the session test can fail: each one breaks one rule in a copy of the session and the test |
| 240 | # must report FAIL for it. |
| 241 | .PHONY: test-gpu-session-platform test-gpu-session-mutants |
| 242 | build/test_omega_gpu_session_platform: tests/test_omega_gpu_session_platform.c $(GPU_FS_LINK) |
| 243 | @mkdir -p build |
| 244 | gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -DOMEGA_GPU_NO_POSIX -o $@ tests/test_omega_gpu_session_platform.c $(GPU_FS_LINK) |
| 245 | GPU_LINUX_REF_SRCS = src/omega_gpu_session.c src/omega_gpu_platform.c src/omega_gpu_platform_linux.c src/omega_gpu_fmt.c src/omega_blackwell_qmd.c |
| 246 | # omega #459: the command list over the reference (near-full ring with the #457 L2 invalidate prefix pending) needs the |
| 247 | # cached allocation, the command list and the codegen behind its nop kernel. |
| 248 | GPU_LINUX_REF_CMDLIST_SRCS = src/omega_gpu_mem_cached.c src/omega_gpu_cmdlist.c src/omega_blackwell_codegen.c src/omega_blackwell_encoder.c \ |
| 249 | src/omega_blackwell_matmul.c src/omega_blackwell_realize.c src/omega_om_units.c |
| 250 | build/test_omega_gpu_platform_linux: tests/test_omega_gpu_platform_linux.c tests/fake_m16_native.c tests/fake_m16_native.h $(GPU_LINUX_REF_SRCS) $(GPU_FS_HDRS) src/omega_gpu_platform_linux.h \ |
| 251 | src/omega_gpu_cmdlist.h src/omega_gpu_mem_cached.h $(GPU_LINUX_REF_CMDLIST_SRCS) |
| 252 | @mkdir -p build |
| 253 | gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -pthread -Isrc -Itests $(GPU_ENGINE_PHYS_INC) \ |
| 254 | -o $@ tests/test_omega_gpu_platform_linux.c tests/fake_m16_native.c $(GPU_LINUX_REF_SRCS) $(GPU_LINUX_REF_CMDLIST_SRCS) -lm |
| 255 | test-gpu-session-platform: build/test_omega_gpu_session_platform build/test_omega_gpu_platform_linux test-gpu-session-mutants |
| 256 | ./build/test_omega_gpu_session_platform |
| 257 | ./build/test_omega_gpu_platform_linux |
| 258 | |
| 259 | GPU_SESSION_MUT_DIR = build/gpu_session_mut |
| 260 | test-gpu-session-mutants: $(GPU_FS_LINK) |
| 261 | @mkdir -p $(GPU_SESSION_MUT_DIR) |
| 262 | @set -e; killed=0; \ |
| 263 | smut() { name=$$1; script=$$2; \ |
| 264 | sed -e "$$script" src/omega_gpu_session.c > $(GPU_SESSION_MUT_DIR)/$$name.c; \ |
| 265 | if cmp -s src/omega_gpu_session.c $(GPU_SESSION_MUT_DIR)/$$name.c; then echo "mutant $$name: pattern not found"; exit 1; fi; \ |
| 266 | gcc $(GPU_FS_CFLAGS) -c -o $(GPU_SESSION_MUT_DIR)/$$name.o $(GPU_SESSION_MUT_DIR)/$$name.c; \ |
| 267 | objs=$$(echo $(GPU_FS_OBJS) | tr ' ' '\n' | grep -v '/omega_gpu_session.o$$' | tr '\n' ' '); \ |
| 268 | gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -DOMEGA_GPU_NO_POSIX -o $(GPU_SESSION_MUT_DIR)/$$name \ |
| 269 | tests/test_omega_gpu_session_platform.c $$objs $(GPU_SESSION_MUT_DIR)/$$name.o; \ |
| 270 | if ./$(GPU_SESSION_MUT_DIR)/$$name > $(GPU_SESSION_MUT_DIR)/$$name.log 2>&1; then echo "mutant $$name SURVIVED"; exit 1; fi; \ |
| 271 | echo "mutant $$name killed: $$(grep -c '^FAIL' $(GPU_SESSION_MUT_DIR)/$$name.log) case(s) failed"; killed=$$((killed+1)); }; \ |
| 272 | smut release-when-latched 's|if (LOAD(g_blocked)) {$$|if (0) {|'; \ |
| 273 | smut ignore-cancel 's|if (LOAD(g_cancel)) return WAIT_CANCELLED;|;|g'; \ |
| 274 | smut no-latch-on-timeout 's|latch(w == WAIT_TIMED_OUT|omega_gpu_session_set_error(w == WAIT_TIMED_OUT|'; \ |
| 275 | smut stale-not-counted 's|else { BUMP(g_stats.stale_refusals, 1u); fail_plat("dma_free", rc); }|else {}|'; \ |
| 276 | smut marker-not-polled 's|RIGHTS_MARKER, PAGE|RIGHTS_DATA, PAGE|'; \ |
| 277 | smut close-while-latched 's|if (g_open \&\& !LOAD(g_blocked) \&\& p) {|if (g_open \&\& p) {|; s|if (!LOAD(g_blocked)) { /\* a hook|if (1) { /* a hook|'; \ |
| 278 | smut recover-keeps-latch 's|STORE(g_blocked, 0u);|;|'; \ |
| 279 | smut recover-without-close 's|const int prc = p->device_close(p->ctx, g_s.dev);|const int prc = OMEGA_GPU_PLAT_OK;|'; \ |
| 280 | smut recover-when-not-latched 's|const int latched = LOAD(g_blocked) \|\| LOAD(g_module_latched);|const int latched = 1;|'; \ |
| 281 | smut recover-ignores-teardown-fault 's|if (prc != OMEGA_GPU_PLAT_OK) {|if (0) {|'; \ |
| 282 | smut recover-ignores-module-latch 's|const int latched = LOAD(g_blocked) \|\| LOAD(g_module_latched);|const int latched = LOAD(g_blocked);|'; \ |
| 283 | echo "test-gpu-session-mutants: $$killed of 11 mutants killed" |