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/omega-gpu-engine.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 / omega-gpu-engine.mk` 499 lines · 41639 bytes Raw Blame History 1 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 # Omega GPU Engine (docs/numeric/OMEGA_GPU_ENGINE.md). Picked up by 3 # `-include mk/*.mk`. Host only: opens no device; needs no physics headers except the two A3b1 targets, not 4 # part of `all` or `test`. 5 # test-gpu-engine-compile header + core compile, enum names, refusals, no-op backend (A2/A3a) 6 # test-gpu-engine the engine core against a fake backend (every state and failure) 7 # test-gpu-engine-backend-compile syntax-checks src/omega_blackwell_engine.c (A3b1): -c only, no link, no device 8 # test-gpu-engine-prod-build production build of GPU_PROD_TARGET (CUDA++: libomega_gpu.a; Omega: build/omegatool): links only, opens no device 9 # test-gpu-engine-mutants removes each protection from src/omega_gpu_engine.c in a scratch 10 # copy; the host test must fail each one (exit nonzero on a survivor). 11 # First proves the shared runner's JSON receipt escapes every string. 12 # test-gpu-engine-sim (A3b2) the REAL engine core + Blackwell backend + vector wrapper against a simulated driver 13 # (tests/fake_m16_native.c); host only, no device, no physics C sources 14 # test-gpu-engine-backend-mutants (A3b2) one mutant per protection in the backend and the vector wrapper 15 # test-gpu-engine-gb10-compile (A3b2) compile-only check of tests/test_omega_gpu_engine_gb10.c (Phase B chip test, never run here) 16 # gpu-engine-freestanding (native v1 P07 cut A) the portable GPU files built -ffreestanding with 17 # OMEGA_GPU_NO_POSIX: no Linux header, no errno, no clock, no libc beyond mem*/str* 18 # test-codegen-freestanding (cut A.2) codegen hosted vs freestanding byte-identical, bounded code buffers 19 # test-gpu-engine-freestanding the engine contract test and the platform contract test linked against 20 # those freestanding objects (host runner, opens no device) 21 .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 test-mutation-runner-json 22 build/test_omega_gpu_engine_compile: tests/test_omega_gpu_engine_compile.c src/omega_gpu_engine.c src/omega_gpu_engine.h src/cudapp_om_eng.c src/omega_eng_dec.h 23 @mkdir -p build 24 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 src/cudapp_om_eng.c 25 test-gpu-engine-compile: build/test_omega_gpu_engine_compile 26 ./build/test_omega_gpu_engine_compile 27 28 build/test_omega_gpu_engine: tests/test_omega_gpu_engine.c src/omega_gpu_engine.c src/omega_gpu_engine.h src/cudapp_om_eng.c src/omega_eng_dec.h 29 @mkdir -p build 30 gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -DOMEGA_NUMERIC_CPU_ONLY -o $@ tests/test_omega_gpu_engine.c src/omega_gpu_engine.c src/cudapp_om_eng.c 31 test-gpu-engine: build/test_omega_gpu_engine 32 ./build/test_omega_gpu_engine 33 34 test-mutation-runner-json: 35 sh tests/mutation_runner_json_test.sh 36 37 test-gpu-engine-mutants: test-mutation-runner-json 38 sh tools/gpu_engine_mutations.sh 39 40 # A3b1: the Blackwell backend includes physics headers (m16_native.h, nvrm.h), so it 41 # uses the same physics -I paths as the top-level Makefile CFLAGS (Makefile lines 9-14). 42 GPU_ENGINE_PHYS_INC = -I$(PHYSICS_DIR)/m16 -I$(PHYSICS_DIR)/nvrm \ 43 -I$(PHYSICS_DIR)/third_party/nvidia-open-580.173.02/src/common/sdk/nvidia/inc \ 44 -I$(PHYSICS_DIR)/third_party/nvidia-open-580.173.02/kernel-open/common/inc \ 45 -I$(PHYSICS_DIR)/third_party/nvidia-open-580.173.02/kernel-open/nvidia-uvm \ 46 -I$(PHYSICS_DIR)/third_party/nvidia-open-580.173.02/src/nvidia/arch/nvalloc/unix/include 47 48 build/omega_blackwell_engine_syntax.o: src/omega_blackwell_engine.c src/omega_blackwell_engine.h src/omega_gpu_engine.h src/omega_fixture_rest.h 49 @mkdir -p build 50 gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -Isrc $(GPU_ENGINE_PHYS_INC) -c -o $@ src/omega_blackwell_engine.c 51 test-gpu-engine-backend-compile: build/omega_blackwell_engine_syntax.o 52 53 # Links only, opens no device. Uses the real m16_native and nvrm sources at the physics pin. 54 test-gpu-engine-prod-build: 55 $(MAKE) $(GPU_PROD_TARGET) 56 57 # A3b2: simulated-driver host test. Links the sources of the Makefile RX_COMPOSE_GPU_SRCS list (plus the 58 # three core files the vector builder needs) with tests/fake_m16_native.c in place of the physics 59 # m16_native.c and nvrm.c. Opens no device. OMEGA_BLACKWELL_HOST_SIMULATOR opts this 60 # binary into the fake driver. The production library build does not set it. 61 GPU_ENGINE_SIM_SRCS = src/omega_blackwell_submit.c src/omega_blackwell_engine.c src/omega_gpu_engine.c \ 62 src/omega_blackwell_matmul.c src/omega_blackwell_codegen.c src/omega_gpu_om_ir.c $(CUDAPP_BINDING_SRCS) src/omega_blackwell_encoder.c \ 63 src/omega_blackwell_qmd.c src/omega_blackwell_realize.c src/omega_vector.c \ 64 src/omega_core.c src/omega_canonical.c src/sha256.c 65 66 build/test_omega_blackwell_engine: tests/test_omega_blackwell_engine.c tests/fake_m16_native.c tests/fake_m16_native.h \ 67 $(GPU_ENGINE_SIM_SRCS) src/omega_gpu_engine.h src/omega_blackwell_engine.h src/omega_fixture_rest.h 68 @mkdir -p build 69 gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -DOMEGA_BLACKWELL_HOST_SIMULATOR -pthread -ffunction-sections -fdata-sections \ 70 -Isrc -Itests $(GPU_ENGINE_PHYS_INC) -o $@ tests/test_omega_blackwell_engine.c tests/fake_m16_native.c \ 71 $(GPU_ENGINE_SIM_SRCS) -Wl,--gc-sections -lm 72 # The matmul wrappers' dimension and code-size refusals (they also need the fixed-deadline wait). 73 build/test_omega_blackwell_matmul_bounds: tests/test_omega_blackwell_matmul_bounds.c tests/fake_m16_native.c \ 74 tests/fake_m16_native.h $(GPU_ENGINE_SIM_SRCS) src/omega_gpu_wait.c src/omega_blackwell_submit.h src/omega_fixture_rest.h 75 @mkdir -p build 76 gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -DOMEGA_BLACKWELL_HOST_SIMULATOR -pthread -ffunction-sections -fdata-sections \ 77 -Isrc -Itests $(GPU_ENGINE_PHYS_INC) -o $@ tests/test_omega_blackwell_matmul_bounds.c tests/fake_m16_native.c \ 78 $(GPU_ENGINE_SIM_SRCS) src/omega_gpu_wait.c -Wl,--gc-sections -lm 79 test-gpu-engine-sim: build/test_omega_blackwell_engine build/test_omega_blackwell_matmul_bounds 80 ./build/test_omega_blackwell_engine 81 ./build/test_omega_blackwell_matmul_bounds 82 83 # One mutant per backend and vector-wrapper protection; the sim test must fail each one. 84 test-gpu-engine-backend-mutants: 85 PHYSICS_DIR="$(PHYSICS_DIR)" sh tools/gpu_engine_backend_mutations.sh 86 87 # Phase B chip test, compile only here. Never run in Phase A. 88 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 89 @mkdir -p build 90 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 91 test-gpu-engine-gb10-compile: build/test_omega_gpu_engine_gb10.o 92 93 # Measurement (sc#277): driver allocations and frees made by the REAL session + matmul + attention 94 # APIs while serving a Qwen3-4B-shaped sequence, against the simulated driver. Host only, no device. 95 # Prints MEASURE lines; asserts only bookkeeping. Links no physics C sources, only its headers. 96 GPU_SERVE_ALLOC_SRCS = src/omega_gpu_session.c src/omega_gpu_platform.c src/omega_gpu_platform_linux.c om/platform-linux/gen/link/plat_fx_effects.c om/platform-linux/gen/link/plat_fx_wait.c src/omega_gpu_mem_reserve.c src/omega_gpu_fmt.c src/omega_gpu_matmul_api.c src/omega_gpu_attention_api.c src/omega_gpu_serving.c \ 97 src/omega_gpu_wait.c src/omega_blackwell_codegen.c src/omega_gpu_om_ir.c $(CUDAPP_BINDING_SRCS) src/omega_blackwell_encoder.c src/omega_blackwell_qmd.c \ 98 src/omega_blackwell_matmul.c src/omega_ampere_qmd.c src/sha256.c 99 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) 100 @mkdir -p build 101 gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -pthread -ffp-contract=off -Isrc -Itests $(GPU_ENGINE_PHYS_INC) \ 102 -o $@ tests/gpu_serving_alloc_count_test.c tests/fake_m16_native.c tests/omega_gpu_live_marker_fixture.c $(GPU_SERVE_ALLOC_SRCS) -lm 103 .PHONY: test-gpu-serving-alloc 104 test-gpu-serving-alloc: build/gpu_serving_alloc_count_test 105 ./build/gpu_serving_alloc_count_test plain 106 ./build/gpu_serving_alloc_count_test reserve 107 ./build/gpu_serving_alloc_count_test bounds 108 ./build/gpu_serving_alloc_count_test bounds-block 109 ./build/gpu_serving_alloc_count_test rollback 110 ./build/gpu_serving_alloc_count_test sweep 111 ./build/gpu_serving_alloc_count_test pin 112 ./build/gpu_serving_alloc_count_test seal-bare 113 ./build/gpu_serving_alloc_count_test update 114 @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 115 @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 116 @grep -E "^MEASURE sweep" build/gpu_serving_alloc_count_sweep_skip.log | sed "s/^/sweep-skip (control): /" 117 @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 118 @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 119 @echo "reserve-skip (no reservation call): fails as required ($$(grep -c "^FAIL" build/gpu_serving_alloc_count_skip.log) failing checks)" 120 121 # native v1 P07 cut A (aienos#286 cut A, aien-architecture#190): the freestanding link target. 122 # Each file below is compiled with no hosted headers available (-ffreestanding, -fno-builtin, 123 # OMEGA_GPU_NO_POSIX) and the partial link of all of them may leave only the mem*/str* symbols 124 # undefined. Any other undefined symbol (errno, clock_gettime, printf, malloc, pthread_*, nvrm_*, 125 # m16_*) fails the target. This proves the first-compute PATH links without Linux headers or 126 # runtime symbols; it proves nothing about device ownership (NOT_RUN until cut B runs on the Spark). 127 GPU_FS_DIR = build/gpu_fs 128 GPU_NO_POSIX_DIR = build/no_posix/native 129 GPU_NO_POSIX_OBJS = $(GPU_NO_POSIX_DIR)/omega_native.o $(GPU_NO_POSIX_DIR)/omega_api_defs.o 130 GPU_NO_POSIX_CHECKED = $(wildcard om/no-posix/gen/*/*) 131 GPU_NO_POSIX_CHECKED += $(wildcard om/codegen/regalloc*.om om/codegen/cg_matmul*.om om/codegen/cg_pack*.om om/codegen/cg_sentin.om om/codegen/cg_vecadd.om om/codegen/cg_bind.om om/blackwell/identity.om om/blackwell/id_native.om om/cache/digest.om) 132 $(GPU_NO_POSIX_DIR)/.installed: om/no-posix.sh $(GPU_NO_POSIX_CHECKED) om/encoder/bw_enc_sm121.om om/cubin/cubin_elf.om om/numeric/no_bf16.om om/session/admit.om om/session/words.om om/session/park.om om/cmdlist/book.om om/streams/streams.om om/apiviews/no_avbf.om 133 sh om/units.sh --native-no-posix 134 touch $@ 135 $(GPU_NO_POSIX_OBJS): $(GPU_NO_POSIX_DIR)/.installed 136 $(CC) -std=gnu11 -O2 -Wall -Wextra -Werror -Wmissing-prototypes -ffreestanding -fno-builtin -fno-stack-protector -include $(GPU_NO_POSIX_DIR)/omega_native.h -I$(GPU_NO_POSIX_DIR) -c -o $@ $(@:.o=.c) 137 CUDAPP_MIGRATION_PENDING_C_NO_POSIX_SESSION ?= 0 138 GPU_FS_CFLAGS = -std=gnu11 -O2 -Wall -Wextra -Werror -ffreestanding -fno-builtin -fno-stack-protector \ 139 -U_FORTIFY_SOURCE -DOMEGA_GPU_NO_POSIX -DOMEGA_NUMERIC_CPU_ONLY $(if $(filter-out 0,$(CUDAPP_MIGRATION_PENDING_C_NO_POSIX_SESSION)),-DCUDAPP_MIGRATION_PENDING_C_NO_POSIX_SESSION=$(CUDAPP_MIGRATION_PENDING_C_NO_POSIX_SESSION)) -Isrc -I$(GPU_NO_POSIX_DIR) 140 # P07 cut C (session part): the persistent session, the matmul and attention APIs, the serving reservation and the 141 # bounded wait join the link. Their machine comes from an installed OmegaGpuPlatform; the Linux reference 142 # (src/omega_gpu_platform_linux.c) is deliberately NOT in this list. Still outside it: the elementwise API, the 143 # numeric launchers, the vector executor, the resident runtime (docs/numeric/OMEGA_GPU_NATIVE_BOUNDARY.md). 144 GPU_FS_SRCS = src/omega_gpu_engine.c src/omega_gpu_platform.c src/omega_blackwell_encoder.c src/omega_blackwell_codegen.c \ 145 src/omega_blackwell_matmul.c src/omega_blackwell_qmd.c src/omega_blackwell_realize.c src/sha256.c \ 146 src/omega_gpu_session.c src/omega_gpu_fmt.c src/omega_gpu_matmul_api.c src/omega_gpu_attention_api.c \ 147 src/omega_gpu_serving.c src/omega_gpu_wait.c src/omega_gpu_om_ir.c $(CUDAPP_FS_BINDING) 148 GPU_FS_HDRS = src/omega_gpu_engine.h src/omega_gpu_platform.h src/omega_blackwell_codegen.h src/omega_blackwell_matmul.h \ 149 src/omega_gpu_session.h src/omega_gpu_fmt.h src/omega_gpu_matmul_api.h src/omega_gpu_attention_api.h \ 150 src/omega_gpu_serving.h src/omega_gpu_wait.h src/cudapp_native.h src/omega_api_plan.h src/omega_host_policy.h src/omega_gpu_apiviews.h src/omega_no_posix_session.h \ 151 src/omega_fixture_verify.h 152 GPU_FS_OBJS = $(patsubst src/%.c,$(GPU_FS_DIR)/%.o,$(GPU_FS_SRCS)) 153 GPU_FS_LINK = $(GPU_FS_DIR)/omega_gpu_freestanding.o 154 GPU_FS_ALLOWED = memcpy|memmove|memset|memcmp|strlen|strcmp 155 156 $(GPU_FS_DIR)/%.o: src/%.c $(GPU_FS_HDRS) $(GPU_NO_POSIX_OBJS) 157 @mkdir -p $(GPU_FS_DIR) 158 gcc $(GPU_FS_CFLAGS) -c -o $@ $< 159 160 $(GPU_FS_LINK): $(GPU_FS_OBJS) $(GPU_NO_POSIX_OBJS) 161 gcc -r -nostdlib -o $@ $(GPU_FS_OBJS) $(GPU_NO_POSIX_OBJS) 162 @bad=$$(nm -u $@ | awk '{print $$NF}' | grep -Ev '^(_GLOBAL_OFFSET_TABLE_|($(GPU_FS_ALLOWED)))$$' || true); \ 163 if [ -n "$$bad" ]; then echo "freestanding GPU link still needs: $$bad"; rm -f $@; exit 1; fi 164 @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" 165 gpu-engine-freestanding: $(GPU_FS_LINK) 166 167 # ham/cubin-qmd-om: additive QMD and realization root dependencies. 168 $(GPU_NO_POSIX_DIR)/.installed: om/qmd/bw_qmd.om om/codegen/cg_bind.om om/cache/digest.om om/blackwell/identity.om om/blackwell/id_native.om om/encoder/amp_runtime.om om/encoder/amp_qmd.om 169 170 .PHONY: test-no-posix-native 171 test-no-posix-native: $(GPU_NO_POSIX_OBJS) build/test_codegen_freestanding 172 python3 tests/no_posix_native.py 173 174 .PHONY: test-no-posix-session 175 test-no-posix-session: $(GPU_NO_POSIX_OBJS) 176 python3 tests/no_posix_session.py 177 .PHONY: test-no-posix-bf16 178 test-no-posix-bf16: $(GPU_NO_POSIX_OBJS) 179 python3 tests/no_posix_bf16.py 180 181 build/test_omega_gpu_engine_freestanding: tests/test_omega_gpu_engine.c $(GPU_FS_DIR)/omega_gpu_engine.o src/omega_gpu_engine.h 182 @mkdir -p build 183 gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -DOMEGA_NUMERIC_CPU_ONLY -DOMEGA_GPU_NO_POSIX \ 184 -o $@ tests/test_omega_gpu_engine.c $(GPU_FS_DIR)/omega_gpu_engine.o 185 build/test_omega_gpu_platform: tests/test_omega_gpu_platform.c $(GPU_FS_DIR)/omega_gpu_platform.o src/omega_gpu_platform.h 186 @mkdir -p build 187 gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -o $@ tests/test_omega_gpu_platform.c $(GPU_FS_DIR)/omega_gpu_platform.o 188 # The same platform test on the hosted build, where the refusal decisions come from om/engine/eng.om. 189 build/test_omega_gpu_platform_om: tests/test_omega_gpu_platform.c src/omega_gpu_platform.c src/omega_gpu_platform.h \ 190 src/cudapp_om_eng.c src/omega_eng_dec.h 191 @mkdir -p build 192 gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -o $@ tests/test_omega_gpu_platform.c src/omega_gpu_platform.c src/cudapp_om_eng.c 193 test-gpu-engine-freestanding: $(GPU_FS_LINK) build/test_omega_gpu_engine_freestanding build/test_omega_gpu_platform \ 194 build/test_omega_gpu_platform_om 195 ./build/test_omega_gpu_engine_freestanding 196 ./build/test_omega_gpu_platform 197 ./build/test_omega_gpu_platform_om 198 199 # native v1 P07 cut A.2 (aienos#286): code generation joins the freestanding link above with a caller-owned 200 # code buffer (omega_blackwell_kernel_encode_into, no allocator). The same test source is built hosted (the 201 # allocating generators) and freestanding (the *_prog generators into a caller buffer); their instruction 202 # stream dumps of every fixture must be byte-identical (cmp). The freestanding run then checks the bounded 203 # buffer contract, the golden-word fixture verifiers on the freestanding object and the bf16 rounding path on 204 # all 2^32 inputs. The allowlist control links a malloc caller into the freestanding object and requires the 205 # nm -u check to refuse it (a check that can never fail proves nothing). 206 .PHONY: test-codegen-freestanding test-gpu-fs-allowlist-control 207 CODEGEN_FS_TEST_DEPS = tests/test_omega_codegen_freestanding.c src/omega_blackwell_codegen.h src/omega_blackwell_matmul.h src/omega_fixture_verify.h 208 # Hosted uses checked portable Omega; freestanding calls the same root's seeded 209 # machine code on the caller's stack. 210 build/test_codegen_hosted: $(CODEGEN_FS_TEST_DEPS) src/omega_blackwell_codegen.c $(CUDAPP_BINDING_SRCS) src/cudapp_native.h \ 211 src/omega_blackwell_matmul.c src/sha256.c src/omega_gpu_om_ir.c 212 @mkdir -p build 213 gcc -std=gnu11 -O2 -Wall -Wextra -Werror -pthread -Isrc -o $@ tests/test_omega_codegen_freestanding.c \ 214 src/omega_blackwell_codegen.c $(CUDAPP_BINDING_SRCS) src/omega_blackwell_matmul.c src/sha256.c src/omega_gpu_om_ir.c 215 build/test_codegen_freestanding: $(CODEGEN_FS_TEST_DEPS) $(GPU_FS_LINK) 216 @mkdir -p build 217 gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -I$(GPU_NO_POSIX_DIR) -DOMEGA_GPU_NO_POSIX -o $@ tests/test_omega_codegen_freestanding.c \ 218 $(GPU_FS_DIR)/omega_blackwell_codegen.o $(GPU_FS_DIR)/omega_blackwell_matmul.o $(GPU_FS_DIR)/sha256.o $(GPU_FS_DIR)/cudapp_freest_f16.o $(GPU_FS_DIR)/cudapp_freest_bw_scalar.o $(GPU_FS_DIR)/cudapp_freest_cg_fields.o $(GPU_FS_DIR)/cudapp_freest_fixture_verify.o $(GPU_NO_POSIX_OBJS) \ 219 $(GPU_FS_DIR)/omega_gpu_om_ir.o $(GPU_FS_DIR)/cudapp_freest_cg_replay.o $(GPU_FS_DIR)/cudapp_freest_cg_life.o $(GPU_FS_DIR)/cudapp_freest_cg_invar.o 220 test-codegen-freestanding: build/test_codegen_hosted build/test_codegen_freestanding test-gpu-fs-allowlist-control 221 ./build/test_codegen_hosted --dump > build/codegen_dump_hosted.txt 222 ./build/test_codegen_freestanding --dump > build/codegen_dump_freestanding.txt 223 cmp build/codegen_dump_hosted.txt build/codegen_dump_freestanding.txt 224 @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" 225 ./build/test_codegen_freestanding 226 @nm $(GPU_FS_DIR)/omega_blackwell_codegen.o > build/codegen-native-symbols.txt 227 @! grep -E ' [Tt] (bw_c_encode_insn|omega_bw_regalloc_c_oracle)$$' build/codegen-native-symbols.txt 228 @grep -q ' U omega2_ra_run$$' build/codegen-native-symbols.txt 229 @grep -q ' U omega2_cg_i32$$' build/codegen-native-symbols.txt 230 @grep -q ' U omega2_cg_block$$' build/codegen-native-symbols.txt 231 @grep -q ' U omega2_bw_enc_sm121$$' build/codegen-native-symbols.txt 232 @echo 'PASS freestanding core references native seeded encoder/allocator/builders; C encoder and allocator symbols absent' 233 234 test-gpu-fs-allowlist-control: $(GPU_FS_LINK) 235 @mkdir -p $(GPU_FS_DIR)/control 236 printf 'void *malloc(unsigned long);\nvoid *omega_gpu_fs_control(void) { return malloc(16); }\n' > $(GPU_FS_DIR)/control/canary.c 237 gcc $(GPU_FS_CFLAGS) -c -o $(GPU_FS_DIR)/control/canary.o $(GPU_FS_DIR)/control/canary.c 238 gcc -r -nostdlib -o $(GPU_FS_DIR)/control/with_canary.o $(GPU_FS_OBJS) $(GPU_NO_POSIX_OBJS) $(GPU_FS_DIR)/control/canary.o 239 @bad=$$(nm -u $(GPU_FS_DIR)/control/with_canary.o | awk '{print $$NF}' | grep -Ev '^(_GLOBAL_OFFSET_TABLE_|($(GPU_FS_ALLOWED)))$$' || true); \ 240 if [ "$$bad" != "malloc" ]; then echo "allowlist control: expected exactly malloc refused, got '$$bad'"; exit 1; fi; \ 241 echo "allowlist control: a malloc caller is refused by the nm -u check (as required)" 242 243 # Strong providers are required even in a relocatable freestanding link. A 244 # successful link after removing any selected provider is a broken control. 245 .PHONY: test-gpu-fs-view-provider-control 246 test-gpu-fs-view-provider-control: $(GPU_FS_LINK) 247 @mkdir -p $(GPU_FS_DIR)/control 248 @set -eu; for entry in attn_set:omega_av_set attn_buf:omega_av_copy attn_tables:omega_av_fold; do \ 249 unit=$${entry%:*}; symbol=$${entry#*:}; objects=; found=0; \ 250 for object in $(GPU_FS_OBJS); do \ 251 if [ "$$object" = "$(GPU_FS_DIR)/cudapp_freest_$$unit.o" ]; then found=1; else objects="$$objects $$object"; fi; \ 252 done; \ 253 [ "$$found" = 1 ] || { echo "FAIL missing registered provider $$unit"; exit 1; }; \ 254 if gcc -r -nostdlib -Wl,--require-defined=$$symbol -o $(GPU_FS_DIR)/control/without-$$unit.o \ 255 $$objects $(GPU_NO_POSIX_OBJS) >$(GPU_FS_DIR)/control/without-$$unit.log 2>&1; then \ 256 echo "FAIL missing-provider link unexpectedly succeeded: $$symbol"; exit 1; \ 257 fi; \ 258 grep -q "$$symbol" $(GPU_FS_DIR)/control/without-$$unit.log || { cat $(GPU_FS_DIR)/control/without-$$unit.log; exit 1; }; \ 259 echo "strong missing-provider control caught: $$symbol"; \ 260 done 261 @echo "freestanding view provider controls: PASS (3 required strong providers)" 262 263 # native v1 P07 cut C, session part (aienos#286): the portable session over OmegaGpuPlatform. 264 # - test_omega_gpu_session_platform links the FREESTANDING partial-link object and drives it through a fake 265 # platform: install refusals, no default platform, typed GPU-uncached buffers, polling only, cancel before and 266 # after submit, timeout (latch + park, nothing released), stale handle after close/reopen, reservation refusal. 267 # - test_omega_gpu_platform_linux drives the Linux REFERENCE platform (reference only) on the simulated driver: 268 # same driver calls in the same order as before cut C, its refusals, and a marker that never lands. 269 # - the mutants prove the session test can fail: each one breaks one rule in a copy of the session and the test 270 # must report FAIL for it. 271 .PHONY: test-gpu-session-platform test-gpu-session-mutants 272 build/test_omega_gpu_session_platform: tests/test_omega_gpu_session_platform.c $(GPU_FS_LINK) 273 @mkdir -p build 274 gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -DOMEGA_GPU_NO_POSIX -o $@ tests/test_omega_gpu_session_platform.c $(GPU_FS_LINK) 275 276 # Same typed synthetic platform and real session, with hosted native bridge/cache 277 # consumers. No Linux platform is linked, so this target cannot open a GPU. 278 GPU_NATIVE_RUNTIME_SRCS = src/omega_gpu_cmdlist.c src/omega_gpu_fp8_api.c \ 279 src/omega_gpu_fp8gemm_api.c src/omega_blackwell_codegen_moe.c src/omega_blackwell_codegen_moe2.c \ 280 src/omega_blackwell_codegen_gemm.c src/omega_gpu_fp8_pack.c src/omega_gpu_mem_cached.c \ 281 src/omega_gpu_hostmath.c src/omega_native_artifact.c src/omega_cubin.c $(CUDAPP_HOST_BINDING) \ 282 src/omega_gpu_q36_graph.c src/omega_gpu_decode_graph.c src/omega_gpu_router_api.c \ 283 src/omega_gpu_gemm_ex.c src/omega_gpu_gemm.c src/omega_blackwell_codegen_qmma.c 284 .PHONY: test-gpu-native-runtime 285 build/test_omega_gpu_native_runtime: tests/test_omega_gpu_session_platform.c tests/native_runtime_controls.h \ 286 $(GPU_FS_LINK) $(GPU_NATIVE_RUNTIME_SRCS) src/omega_gpu_native_runtime.h src/omega_gpu_q36_native.h \ 287 src/omega_gpu_cmdlist_native.h src/omega_native_artifact_snapshot.h 288 @mkdir -p build 289 gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -I$(GPU_NO_POSIX_DIR) -DOMEGA_GPU_NO_POSIX -DOMEGA_NATIVE_RUNTIME_TEST \ 290 -DCUDAPP_NATIVE_RUNTIME_TEST -ffunction-sections -fdata-sections -Wl,--gc-sections \ 291 -o $@ tests/test_omega_gpu_session_platform.c $(GPU_FS_LINK) $(GPU_NATIVE_RUNTIME_SRCS) -lpthread -lm 292 test-gpu-native-runtime: build/test_omega_gpu_native_runtime test-gpu-fs-view-provider-control 293 ./build/test_omega_gpu_native_runtime 294 GPU_LINUX_REF_SRCS = src/omega_gpu_session.c src/omega_gpu_platform.c src/omega_gpu_platform_linux.c om/platform-linux/gen/link/plat_fx_effects.c om/platform-linux/gen/link/plat_fx_wait.c src/omega_gpu_mem_reserve.c src/omega_gpu_fmt.c src/omega_blackwell_qmd.c src/omega_ampere_qmd.c $(CUDAPP_FS_BINDING) 295 # omega #459: the command list over the reference (near-full ring with the #457 L2 invalidate prefix pending) needs the 296 # cached allocation, the command list and the codegen behind its nop kernel. 297 GPU_LINUX_REF_CMDLIST_SRCS = src/omega_gpu_mem_cached.c src/omega_gpu_cmdlist.c src/omega_blackwell_codegen.c src/omega_gpu_om_ir.c $(CUDAPP_HOST_BINDING) src/omega_blackwell_encoder.c \ 298 src/omega_blackwell_matmul.c src/omega_blackwell_realize.c src/sha256.c 299 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 \ 300 src/omega_gpu_cmdlist.h src/omega_gpu_mem_cached.h $(GPU_LINUX_REF_CMDLIST_SRCS) 301 @mkdir -p build 302 gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -pthread -Isrc -Itests $(GPU_ENGINE_PHYS_INC) \ 303 -Wl,--wrap=omega2_ctx_plat_wait_ge -o $@ tests/test_omega_gpu_platform_linux.c tests/fake_m16_native.c tests/omega_gpu_live_marker_fixture.c $(GPU_LINUX_REF_SRCS) $(GPU_LINUX_REF_CMDLIST_SRCS) -lm 304 # The driver client's VA slots and close path on the host (no device opened, nvrm_open never called). 305 build/test_nvrm_va_slots: tests/test_nvrm_va_slots.c $(PHYSICS_DIR)/nvrm/nvrm.c $(PHYSICS_DIR)/nvrm/nvrm.h src/omega_ampere_qmd.c \ 306 src/omega_gpu_chip.c $(CUDAPP_BINDING_SRCS) 307 @mkdir -p build 308 gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -Isrc $(GPU_ENGINE_PHYS_INC) -o $@ tests/test_nvrm_va_slots.c src/omega_ampere_qmd.c \ 309 src/omega_gpu_chip.c $(CUDAPP_BINDING_SRCS) 310 test-gpu-session-platform: build/test_omega_gpu_session_platform build/test_omega_gpu_platform_linux build/test_nvrm_va_slots \ 311 test-gpu-session-mutants 312 ./build/test_omega_gpu_session_platform 313 ./build/test_omega_gpu_platform_linux 314 ./build/test_nvrm_va_slots 315 316 # The aien-gpu platform (src/omega_gpu_platform_aien.c, second implementation of the contract over aien-gpu.ko) on a 317 # simulated /dev/aien-gpu (tests/test_omega_gpu_platform_aien.c): no device opened. It links the Linux reference, 318 # m16_native.c and nvrm.c only to compare caps, the GP entry and the USERD layout with them; nothing in it calls the 319 # NVIDIA driver. Decisions and request bytes come from native/aiengpu/context.om (CUDApp#128) through the generated 320 # src/cudapp_om_aiengpu.c; the C they replaced is the oracle under CUDAPP_MIGRATION_PENDING_C_PLATFORM_AIEN=1. 321 # make test-gpu-platform-aien (in `make test`, no Omega tools needed) 322 # 1. the test through the .om decisions, and through the C oracle; 323 # 2. the differential: AIEN_TRACE of both (every ioctl's bytes in and out, map/unmap arguments, the final 324 # ring, USERD GPPut, pushbuffer and doorbell) must be byte-identical; 325 # 3. the C-glue mutants: each breaks one effect in a copy of the platform; the test must fail AND its trace 326 # must differ from the oracle's (the red check of step 2). 327 # make test-gpu-platform-aien-om-mutants mutant context.om files, each compiled by the pinned omc, must fail the 328 # test or change the trace (needs OMEGA_OMC and OMEGA_BRIDGE as in om/units.sh; without them exit 3, NOT_RUN). 329 GPU_AIEN_INC = -I$(PHYSICS_DIR)/third_party/aien-gpu-abi1 330 # AArch64: the effects through native/aiengpu/effects.om (src/cudapp_aiengpu_effects.c, regenerated by 331 # native/aiengpu/units.sh); elsewhere the C system calls (CUDAPP_MIGRATION_PENDING_C_PLATFORM_AIEN_EFFECTS=1 by default). 332 GPU_AIEN_EFFECTS_SRCS = $(if $(filter aarch64,$(CUDAPP_HOST_ARCH)),src/cudapp_aiengpu_effects.c) 333 GPU_AIEN_OTHER_SRCS = src/omega_gpu_platform.c src/omega_gpu_mem_reserve.c src/omega_gpu_session.c \ 334 src/omega_gpu_platform_linux.c om/platform-linux/gen/link/plat_fx_effects.c om/platform-linux/gen/link/plat_fx_wait.c src/omega_gpu_fmt.c src/omega_blackwell_qmd.c src/omega_ampere_qmd.c src/omega_gpu_chip.c \ 335 $(PHYSICS_DIR)/m16/m16_native.c $(PHYSICS_DIR)/nvrm/nvrm.c $(GPU_AIEN_EFFECTS_SRCS) 336 # The platform uses nvrm.c only for its pure encoders (nvrm_mthd, nvrm_gp_entry) and never opens the RM, so nvrm.c takes 337 # the C test transport and the NVRM native unit (src/cudapp_om_nvrm_transport.c, NVRM #281) stays out: each native unit 338 # carries its own omega_native_context_create/destroy, and on AArch64 cudapp_aiengpu_effects.c is already linked. 339 GPU_AIEN_BINDING = $(filter-out src/cudapp_om_nvrm_transport.c,$(CUDAPP_BINDING_SRCS)) 340 GPU_AIEN_SRCS = src/omega_gpu_platform_aien.c $(GPU_AIEN_OTHER_SRCS) $(GPU_AIEN_BINDING) 341 # MIGRATION-PENDING C: the platform's code exists only with CUDAPP_MIGRATION_PENDING_AIEN_GPU=1, set here for the test and 342 # its mutants and OFF in libomega_gpu.a and every other build (the effects wait on devctl/maphold for AGPU requests). 343 GPU_AIEN_CFLAGS = -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -pthread -DCUDAPP_MIGRATION_PENDING_AIEN_GPU=1 \ 344 -DCUDAPP_NVRM_TEST_TRANSPORT=1 -Isrc $(GPU_ENGINE_PHYS_INC) $(GPU_AIEN_INC) 345 GPU_AIEN_DEPS = tests/test_omega_gpu_platform_aien.c $(GPU_AIEN_SRCS) src/omega_gpu_platform_aien.h \ 346 src/omega_gpu_mem_reserve.h src/cudapp_native.h third_party/aien-gpu-abi1/aien_gpu_uapi.h \ 347 $(if $(GPU_AIEN_EFFECTS_SRCS),src/cudapp_aiengpu_native.h) 348 build/test_omega_gpu_platform_aien: $(GPU_AIEN_DEPS) 349 @mkdir -p build 350 gcc $(GPU_AIEN_CFLAGS) -o $@ tests/test_omega_gpu_platform_aien.c $(GPU_AIEN_SRCS) 351 build/test_omega_gpu_platform_aien_c: $(GPU_AIEN_DEPS) 352 @mkdir -p build 353 gcc $(GPU_AIEN_CFLAGS) -DCUDAPP_MIGRATION_PENDING_C_PLATFORM_AIEN=1 -o $@ tests/test_omega_gpu_platform_aien.c \ 354 $(GPU_AIEN_SRCS) 355 GPU_AIEN_MUT_DIR = build/gpu_aien_mut 356 .PHONY: test-gpu-platform-aien test-gpu-platform-aien-mutants test-gpu-platform-aien-om-mutants 357 test-gpu-platform-aien: build/test_omega_gpu_platform_aien build/test_omega_gpu_platform_aien_c test-gpu-platform-aien-mutants \ 358 $(if $(GPU_AIEN_EFFECTS_SRCS),test-gpu-platform-aien-effects) 359 @mkdir -p $(GPU_AIEN_MUT_DIR) 360 @rm -f $(GPU_AIEN_MUT_DIR)/om.trace $(GPU_AIEN_MUT_DIR)/c.trace 361 AIEN_TRACE=$(GPU_AIEN_MUT_DIR)/om.trace ./build/test_omega_gpu_platform_aien 362 AIEN_TRACE=$(GPU_AIEN_MUT_DIR)/c.trace ./build/test_omega_gpu_platform_aien_c 363 @cmp $(GPU_AIEN_MUT_DIR)/om.trace $(GPU_AIEN_MUT_DIR)/c.trace || { echo "AIEN DIFF FAIL: .om and C oracle traces differ"; exit 1; } 364 @echo "AIEN DIFF PASS: .om and C oracle traces identical ($$(grep -c '^case ' $(GPU_AIEN_MUT_DIR)/om.trace) cases, $$(grep -c '^ioctl 0x' $(GPU_AIEN_MUT_DIR)/om.trace) ioctls, $$(wc -c < $(GPU_AIEN_MUT_DIR)/om.trace) bytes)" 365 test-gpu-platform-aien-mutants: build/test_omega_gpu_platform_aien_c 366 @mkdir -p $(GPU_AIEN_MUT_DIR) 367 @rm -f $(GPU_AIEN_MUT_DIR)/oracle.trace; AIEN_TRACE=$(GPU_AIEN_MUT_DIR)/oracle.trace ./build/test_omega_gpu_platform_aien_c > /dev/null 368 @set -e; killed=0; \ 369 amut() { name=$$1; script=$$2; \ 370 sed -e "$$script" src/omega_gpu_platform_aien.c > $(GPU_AIEN_MUT_DIR)/$$name.c; \ 371 if cmp -s src/omega_gpu_platform_aien.c $(GPU_AIEN_MUT_DIR)/$$name.c; then echo "mutant $$name: pattern not found"; exit 1; fi; \ 372 gcc $(GPU_AIEN_CFLAGS) -o $(GPU_AIEN_MUT_DIR)/$$name tests/test_omega_gpu_platform_aien.c $(GPU_AIEN_MUT_DIR)/$$name.c \ 373 $(GPU_AIEN_OTHER_SRCS) $(GPU_AIEN_BINDING); \ 374 rm -f $(GPU_AIEN_MUT_DIR)/$$name.trace; \ 375 if AIEN_TRACE=$(GPU_AIEN_MUT_DIR)/$$name.trace ./$(GPU_AIEN_MUT_DIR)/$$name > $(GPU_AIEN_MUT_DIR)/$$name.log 2>&1; then \ 376 echo "mutant $$name SURVIVED"; exit 1; fi; \ 377 if cmp -s $(GPU_AIEN_MUT_DIR)/$$name.trace $(GPU_AIEN_MUT_DIR)/oracle.trace; then \ 378 echo "mutant $$name: trace equals the oracle's, the differential cannot see it"; exit 1; fi; \ 379 echo "mutant $$name killed: $$(grep -c '^FAIL' $(GPU_AIEN_MUT_DIR)/$$name.log) case(s) failed, trace differs"; killed=$$((killed+1)); }; \ 380 amut no-doorbell 's|= r->token;|= 0;|'; \ 381 amut no-l2-prefix 's|r->l2_inval_pending = 1; /\* omega #457 \*/|{ }|'; \ 382 echo "test-gpu-platform-aien-mutants: $$killed of 2 mutants killed" 383 # Each sed must match exactly one line of context.om (refused otherwise). A mutant is killed when the test fails or 384 # its trace differs from the C oracle's. 385 GPU_AIEN_OM_MUTANTS = \ 386 'no-gpput|s/^ag_put b 36 rem and add get m 5 1 `4294967295` AGRING 4$$/ag_put b 36 0 4/' \ 387 'state-unchecked|s/^if ne ag_load b 4 4 4$$/if ne ag_load b 4 4 ag_load b 4 4/' \ 388 'always-cached|s/^const AGUNC ulong 1$$/const AGUNC ulong 0/' \ 389 'ring-never-full|s/ sub AGRING 1$$/ `4294967295`/' \ 390 'l2-word|s/^ag_put b 0 `537133066` 4$$/ag_put b 0 0 4/' \ 391 'gp-bit|s/ shl ulong 1 41$$/ shl ulong 1 40/' \ 392 'alloc-va|s/^ag_put b 8 get m 2 8$$/ag_put b 8 0 8/' \ 393 'userd-off|s/^ag_put b 24 AGUSERD 8$$/ag_put b 24 0 8/' 394 test-gpu-platform-aien-om-mutants: build/test_omega_gpu_platform_aien_c 395 @[ -n "$(OMEGA_OMC)" ] && [ -n "$(OMEGA_BRIDGE)" ] || { echo "NOT_RUN: set OMEGA_OMC and OMEGA_BRIDGE"; exit 3; } 396 @mkdir -p $(GPU_AIEN_MUT_DIR) 397 @rm -f $(GPU_AIEN_MUT_DIR)/oracle.trace; AIEN_TRACE=$(GPU_AIEN_MUT_DIR)/oracle.trace ./build/test_omega_gpu_platform_aien_c > /dev/null 398 @n=0; k=0; for m in $(GPU_AIEN_OM_MUTANTS); do n=$$((n+1)); name=$${m%%|*}; s=$${m#*|}; d=$(GPU_AIEN_MUT_DIR)/om-$$name; \ 399 rm -rf $$d; mkdir -p $$d; sed "$$s" native/aiengpu/context.om > $$d/context.om; \ 400 c=$$(diff native/aiengpu/context.om $$d/context.om | grep -c '^>'); \ 401 if [ "$$c" != 1 ]; then echo "MUTANT $$name BROKEN: '$$s' changed $$c lines, not 1"; exit 1; fi; \ 402 OMEGA_UNITS="aiengpu=$$(pwd)/$$d/context.om" OMEGA_UNITS_DEST=$$d OMEGA_OMC="$(OMEGA_OMC)" \ 403 OMEGA_BRIDGE="$(OMEGA_BRIDGE)" sh om/units.sh > $$d/units.log 2>&1 || { echo "MUTANT $$name: omc refused it"; cat $$d/units.log; exit 1; }; \ 404 gcc $(GPU_AIEN_CFLAGS) -o $$d/test tests/test_omega_gpu_platform_aien.c src/omega_gpu_platform_aien.c $(GPU_AIEN_OTHER_SRCS) \ 405 $(filter-out src/cudapp_om_aiengpu.c,$(GPU_AIEN_BINDING)) $$d/cudapp_om_aiengpu.c || exit 1; \ 406 t=0; AIEN_TRACE=$$d/trace $$d/test > $$d/test.log 2>&1 || t=1; \ 407 r=0; cmp -s $$d/trace $(GPU_AIEN_MUT_DIR)/oracle.trace || r=1; \ 408 if [ $$t = 0 ] && [ $$r = 0 ]; then echo "MUTANT $$name SURVIVED"; exit 1; fi; \ 409 k=$$((k+1)); echo "mutant $$name killed: test $$( [ $$t = 1 ] && echo failed || echo passed ), trace $$( [ $$r = 1 ] && echo differs || echo equal )"; done; \ 410 echo "test-gpu-platform-aien-om-mutants: $$k of $$n mutants killed" 411 412 # aien-gpu effects through device words (native/aiengpu/effects.om, AArch64 only, CUDApp #128): 413 # make test-gpu-platform-aien-effects (AArch64: part of test-gpu-platform-aien, so in `make test`; no Omega tools) 414 # tests/test_omega_gpu_platform_aien_fx.c runs the platform's real effects against a memfd fake device whose 415 # 'A' ioctls a seccomp trap answers, once through effects.om (the committed src/cudapp_aiengpu_effects.c) and once 416 # through the C system calls (CUDAPP_MIGRATION_PENDING_C_PLATFORM_AIEN_EFFECTS=1); descriptor-3 traces of both (every 417 # ioctl's bytes in and out, every nonzero line of the fake device) must be byte-identical. One C-glue mutant 418 # (the unmap that never drops the unit's mapping) must fail the test or change the trace. 419 # make test-gpu-platform-aien-effects-mutants needs OMEGA_AIENGPU_BRIDGE (the bridge checkout named in 420 # src/cudapp_aiengpu_effects.ident), OMEGA_NATIVE_OMC (generator omc `734f0a39`) and OMEGA_NATIVE_OMC2 (device-word 421 # omc `b8f8f137`); without them exit 3, NOT_RUN. Regenerates the unit into build/ and requires the committed C and 422 # header to be byte-identical, then mutant effects.om files, each changing exactly one line, must fail the test 423 # or change the trace. 424 GPU_AIEN_FX_DIR = build/gpu_aien_fx 425 GPU_AIEN_FX_OM_SRCS = $(filter-out src/cudapp_aiengpu_effects.c,$(GPU_AIEN_SRCS)) 426 GPU_AIEN_FX_MUTANTS = \ 427 'doorbell-off|s/mapset db 144 4/mapset db 148 4/' \ 428 'gpput-off|s/fifo 8332 4/fifo 8336 4/' \ 429 'prefix-half|s/a = mapwrite pb 0 plan 0 mul pre 4/a = mapwrite pb 0 plan 0 mul pre 2/' \ 430 'destroy-len|s/eq req `3222815012` eq len b 24/eq req `3222815012` eq len b 25/' 431 GPU_AIEN_FX_DEPS = tests/test_omega_gpu_platform_aien_fx.c $(GPU_AIEN_DEPS) 432 build/test_omega_gpu_platform_aien_fx: $(GPU_AIEN_FX_DEPS) 433 @mkdir -p build 434 gcc $(GPU_AIEN_CFLAGS) -o $@ tests/test_omega_gpu_platform_aien_fx.c $(GPU_AIEN_SRCS) 435 build/test_omega_gpu_platform_aien_fx_c: $(GPU_AIEN_FX_DEPS) 436 @mkdir -p build 437 gcc $(GPU_AIEN_CFLAGS) -DCUDAPP_MIGRATION_PENDING_C_PLATFORM_AIEN_EFFECTS=1 -o $@ tests/test_omega_gpu_platform_aien_fx.c \ 438 $(GPU_AIEN_FX_OM_SRCS) 439 # judge NAME DIR: DIR/test must fail, or its trace must differ from the C system calls' ($(GPU_AIEN_FX_DIR)/c.trace). 440 GPU_AIEN_FX_JUDGE = judge() { name=$$1; t=0; AIEN_FX_TRACE_FD=3 $$2/test 3>$$2/trace > $$2/test.log 2>&1 || t=1; \ 441 r=0; cmp -s $$2/trace $(GPU_AIEN_FX_DIR)/c.trace || r=1; \ 442 if [ $$t = 0 ] && [ $$r = 0 ]; then echo "MUTANT $$name SURVIVED"; exit 1; fi; \ 443 k=$$((k+1)); echo "mutant $$name killed: test $$( [ $$t = 1 ] && echo failed || echo passed ), trace $$( [ $$r = 1 ] && echo differs || echo equal )"; } 444 .PHONY: test-gpu-platform-aien-effects test-gpu-platform-aien-effects-mutants 445 test-gpu-platform-aien-effects: $(if $(GPU_AIEN_EFFECTS_SRCS),build/test_omega_gpu_platform_aien_fx build/test_omega_gpu_platform_aien_fx_c) 446 @[ -n "$(GPU_AIEN_EFFECTS_SRCS)" ] || { echo "NOT_RUN: the aien-gpu effects unit is AArch64 only"; exit 3; } 447 @set -e; d=$(GPU_AIEN_FX_DIR); mkdir -p $$d; rm -f $$d/c.trace $$d/om.trace; \ 448 AIEN_FX_TRACE_FD=3 ./build/test_omega_gpu_platform_aien_fx_c 3>$$d/c.trace; \ 449 AIEN_FX_TRACE_FD=3 ./build/test_omega_gpu_platform_aien_fx 3>$$d/om.trace; \ 450 cmp $$d/om.trace $$d/c.trace || { echo "AIEN EFFECTS DIFF FAIL: effects.om and C system-call traces differ"; exit 1; }; \ 451 echo "AIEN EFFECTS DIFF PASS: effects.om and C system-call traces identical ($$(grep -c '^ioctl ' $$d/om.trace) ioctls, $$(grep -c '^dev ' $$d/om.trace) device lines, $$(wc -c < $$d/om.trace) bytes)"; \ 452 k=0; $(GPU_AIEN_FX_JUDGE); md=$$d/c-glue-drop; rm -rf $$md; mkdir -p $$md; \ 453 sed 's/drop(g_om.ctx, &res, m->handle)/address(g_om.ctx, \&res, m->handle)/' src/omega_gpu_platform_aien.c > $$md/platform.c; \ 454 c=$$(diff src/omega_gpu_platform_aien.c $$md/platform.c | grep -c '^>' || true); \ 455 if [ "$$c" != 1 ]; then echo "MUTANT c-glue-drop BROKEN: changed $$c lines, not 1"; exit 1; fi; \ 456 gcc $(GPU_AIEN_CFLAGS) -o $$md/test tests/test_omega_gpu_platform_aien_fx.c $$md/platform.c $(GPU_AIEN_OTHER_SRCS) \ 457 $(GPU_AIEN_BINDING); \ 458 judge c-glue-drop $$md; \ 459 echo "test-gpu-platform-aien-effects: $$k of 1 C-glue mutants killed" 460 test-gpu-platform-aien-effects-mutants: test-gpu-platform-aien-effects 461 @[ -n "$(OMEGA_AIENGPU_BRIDGE)" ] && [ -n "$(OMEGA_NATIVE_OMC)" ] && [ -n "$(OMEGA_NATIVE_OMC2)" ] || \ 462 { echo "NOT_RUN: set OMEGA_AIENGPU_BRIDGE, OMEGA_NATIVE_OMC and OMEGA_NATIVE_OMC2"; exit 3; } 463 @set -e; d=$(GPU_AIEN_FX_DIR); rm -rf $$d/gen; \ 464 pin=$$(tr ' ' '\n' < src/cudapp_aiengpu_effects.ident | sed -n 's/^bridge=//p'); \ 465 [ "$$(git -C "$(OMEGA_AIENGPU_BRIDGE)" rev-parse HEAD)" = "$$pin" ] || { echo "NOT_RUN: OMEGA_AIENGPU_BRIDGE is not at the pinned bridge $$pin"; exit 3; }; \ 466 sh native/aiengpu/units.sh --candidate $$d/gen; \ 467 cmp $$d/gen/cudapp_aiengpu_effects.c src/cudapp_aiengpu_effects.c && cmp $$d/gen/cudapp_aiengpu_native.h src/cudapp_aiengpu_native.h || \ 468 { echo "AIEN EFFECTS REGEN FAIL: src/ differs from native/aiengpu/units.sh output"; exit 1; }; \ 469 echo "AIEN EFFECTS REGEN PASS: src/cudapp_aiengpu_effects.c and cudapp_aiengpu_native.h reproduce at bridge $$pin"; \ 470 n=0; k=0; $(GPU_AIEN_FX_JUDGE); \ 471 for m in $(GPU_AIEN_FX_MUTANTS); do n=$$((n+1)); name=$${m%%|*}; s=$${m#*|}; md=$$d/om-$$name; rm -rf $$md; mkdir -p $$md; \ 472 sed "$$s" native/aiengpu/effects.om > $$md/effects.om; \ 473 c=$$(diff native/aiengpu/effects.om $$md/effects.om | grep -c '^>' || true); \ 474 if [ "$$c" != 1 ]; then echo "MUTANT $$name BROKEN: '$$s' changed $$c lines, not 1"; exit 1; fi; \ 475 sh native/aiengpu/units.sh --candidate $$md/gen $$md/effects.om > $$md/units.log 2>&1 || { echo "MUTANT $$name: generation refused it"; cat $$md/units.log; exit 1; }; \ 476 gcc -I$$md/gen $(GPU_AIEN_CFLAGS) -o $$md/test tests/test_omega_gpu_platform_aien_fx.c $(GPU_AIEN_FX_OM_SRCS) \ 477 $$md/gen/cudapp_aiengpu_effects.c; \ 478 judge $$name $$md; done; \ 479 echo "test-gpu-platform-aien-effects-mutants: $$k of $$n mutants killed" 480 481 # Compile the hosted session against the explicit fake provider: NO_POSIX would 482 # select the C oracle and leave the default Omega units untested. The runner 483 # rejects missing sites/build failures before counting behavioral mutant kills. 484 # The seven Omega-unit mutants regenerate .om with the pinned AArch64 omc; off a 485 # CUDAPP_OMC_HOST they print NOT_RUN and only the session-shell mutants count. 486 test-gpu-session-mutants: $(GPU_FS_LINK) 487 SESSION_FS_OBJECTS='$(GPU_FS_OBJS) $(GPU_NO_POSIX_OBJS)' CC='$(CC)' SESSION_UNIT_MUTANTS='$(if $(CUDAPP_OMC_HOST),1,0)' \ 488 OMEGA_OMC="$(OMEGA_OMC)" OMEGA_BRIDGE="$(OMEGA_BRIDGE)" python3 tests/check_session_mutants.py 489 490 # Existing .om process helper and a new .om conductor; no new host test script. 491 CARRIED_HOST_TESTS += test-session-memory-om 492 CUDAPP_TARGET_ONLY_TESTS += $(if $(CUDAPP_OMC_HOST),,test-session-memory-om) 493 .PHONY: test-session-memory-om 494 test-session-memory-om: om/session/reserve.om om/engine/fixture_rest.om om/engine/eng.om om/api/apish_slot.om tests/components/proc.om tests/session_memory_test.om tests/session_memory_gate.om 495 @$(CUDAPP_REQUIRE_OMC) 496 @mkdir -p build/session-memory build/components 497 cat tests/components/proc.om tests/session_memory_gate.om | "$(OMEGA_OMC)" > build/session-memory/gate 498 chmod +x build/session-memory/gate 499 ./build/session-memory/gate "$(OMEGA_OMC)"