interplane.Get Omega
Read in your language

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

branch main Branches Tags History

CUDApp / Makefile

835 lines · 56200 bytes Raw Blame History
1# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2# CUDA++ build. Plain make + gcc; no CUDA toolkit, no NVIDIA user-space library.
3#
4# make libomega_gpu.a (= libcudapp.a): GPU toolchain + runtime + libraries + driver client
5# make test every host-only test (no GPU needed)
6# make doctor is this machine ready? one line per check, each FAIL with its fix (no GPU opened);
7# with OMC=/abs/pinned/omc it also lists every GPU target row (backend/targets.om)
8# make test-multitarget OMC=... portable-backend host gate: SPIR-V on CPU drivers, HSACO checks
9# make hello-gpu run the doctor, then build examples/hello_gpu and run it (on a GB10)
10#
11# The driver client (nvrm/, m16/) and the NVIDIA open headers (third_party/) are in
12# this repository, so PHYSICS_DIR is "." here. Omega is meant to build the same sources
13# with PHYSICS_DIR pointing at a pinned CUDA++ checkout (cudapp.lock); that pin does not
14# exist yet and Omega main still takes nvrm/m16 from physics-mv (#106, #107).
15.DEFAULT_GOAL := all
16PHYSICS_DIR ?= .
17# om/units.sh emits every seeded Omega unit as checked portable C (omega-bridge,
18# om/omega-bridge.lock): src/cudapp_om_<unit>.c hosted, src/cudapp_freest_<unit>.c
19# import-free checked roots, including borrowed runtime views. Every host compiles the same units, so x86-64 runs the .om
20# encoder, cubin packer and native units that AArch64 runs.
21# The pinned compiler omc is an AArch64 binary. The rows that execute it
22# (CUDAPP_TARGET_ONLY_TESTS) run on AArch64, or on another host when OMEGA_OMC
23# is given explicitly and executes there (the pinned QEMU provenance oracle in
24# .github/workflows/ampere-x86.yml). Otherwise they print NOT_RUN and exit 2.
25# On AArch64, CC stays make's built-in (CC ?= gcc does not replace it), so a
26# GB10 `make` invokes the same compiler it did before this portability guard.
27CUDAPP_HOST_ARCH := $(shell uname -m)
28ifeq ($(filter aarch64 arm64,$(CUDAPP_HOST_ARCH)),)
29# GNU make defines CC as cc before this file is read, and ?= does not replace
30# that built-in. The documented x86-64 compiler is gcc. An explicit CC= on the
31# command line or in the environment still wins.
32ifeq ($(origin CC),default)
33CC := gcc
34endif
35CUDAPP_HOST_IS_AARCH64 :=
36CUDAPP_OMC_HOST := $(if $(filter environment command,$(firstword $(origin OMEGA_OMC))),1,)
37else
38# Same assignment as before this branch. Make's built-in CC=cc wins, because ?=
39# does not replace a variable make already defined.
40CC ?= gcc
41CUDAPP_HOST_IS_AARCH64 := 1
42CUDAPP_OMC_HOST := 1
43endif
44CUDAPP_TARGET_ONLY_TESTS := $(if $(CUDAPP_OMC_HOST),,test-om-spec-encoder test-portable-receipts test-model-capacity test-prof)
45# First recipe line of a CUDAPP_TARGET_ONLY_TESTS member defined in mk/*.mk:
46# off a CUDAPP_OMC_HOST, invoking the target directly prints NOT_RUN and exits 2.
47CUDAPP_REQUIRE_OMC = $(if $(CUDAPP_OMC_HOST),:,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)"; exit 2)
48# One pinned-compiler step inside a portable target, as a whole recipe line:
49# $(call CUDAPP_OMC_STEP,<command>,<what>) runs <command> on a CUDAPP_OMC_HOST and
50# elsewhere prints "<target>: <what> NOT_RUN" instead. The other lines still run.
51CUDAPP_OMC_STEP = $(if $(CUDAPP_OMC_HOST),$(1),@echo "$@: $(2) NOT_RUN (requires the pinned AArch64 omc; set OMEGA_OMC to a pin that executes on this host)")
52# Portable checked Omega-to-C output; each unit has a separate private runtime namespace.
53CUDAPP_HOST_BINDING = $(wildcard src/cudapp_om_*.c)
54CUDAPP_FS_BINDING = src/cudapp_freest_revision.c src/cudapp_freest_epoch.c src/cudapp_freest_f16.c src/cudapp_freest_leftovers.c src/cudapp_freest_bw_scalar.c src/cudapp_freest_pathcopy.c src/cudapp_freest_streams_xq.c src/cudapp_freest_fixture_verify.c
55CUDAPP_FS_BINDING += src/cudapp_freest_regalloc.c src/cudapp_freest_cg_fields.c src/cudapp_freest_core_cubinmsg.c src/cudapp_freest_core_cubadmit.c $(wildcard src/cudapp_freest_attn_*.c) src/cudapp_freest_attention_ir.c src/cudapp_freest_cg_replay.c src/cudapp_freest_cg_life.c src/cudapp_freest_cg_invar.c
56CUDAPP_BINDING_SRCS = $(CUDAPP_HOST_BINDING) $(CUDAPP_FS_BINDING)
57# Units every explicit host link of src/omega_blackwell_codegen.c needs since RegAlloc #309, RegAllocRest and
58# FreestLeftovers #320: the allocator, the bind step, the kernel-dump leftovers and the SHA core under sha256.c.
59# With -Wl,--gc-sections only the referenced ones stay. Links that also take src/omega_cubin.c add
60# src/cudapp_freest_core_cubinmsg.c and src/cudapp_freest_core_cubadmit.c.
61BW_CODEGEN_BINDING = src/cudapp_freest_regalloc.c src/cudapp_om_regalloc_ir.c src/cudapp_om_regalloc_live.c \
62 src/cudapp_om_cg_bind.c src/cudapp_freest_leftovers.c src/cudapp_om_core_sha.c src/cudapp_freest_cg_fields.c \
63 src/cudapp_freest_pathcopy.c src/cudapp_om_cg_em.c src/cudapp_freest_cg_replay.c src/cudapp_freest_cg_life.c src/cudapp_freest_cg_invar.c
64OUT_DIR ?= build
65GPU_PROD_TARGET ?= $(OUT_DIR)/libomega_gpu.a
66NVIDIA_OPEN := $(PHYSICS_DIR)/third_party/nvidia-open-580.173.02
67CFLAGS ?= -std=gnu11 -Wall -Wextra -Werror -MMD -MP -D_GNU_SOURCE -O2 -Isrc \
68 -I$(PHYSICS_DIR)/m16 -I$(PHYSICS_DIR)/nvrm \
69 -I$(NVIDIA_OPEN)/src/common/sdk/nvidia/inc \
70 -I$(NVIDIA_OPEN)/kernel-open/common/inc \
71 -I$(NVIDIA_OPEN)/kernel-open/nvidia-uvm \
72 -I$(NVIDIA_OPEN)/src/nvidia/arch/nvalloc/unix/include \
73 -I$(PHYSICS_DIR)/third_party/aien-gpu-abi1
74-include $(filter-out mk/host-policy.mk,$(wildcard mk/*.mk))
75
76# sm_121 instruction encoder (CUDApp#79): om (default) = om/encoder/bw_enc_sm121.om through the generated binding
77# portable generated C units in CUDAPP_BINDING_SRCS; c = the migration-pending C encoder, the differential oracle; diff = both on every call,
78# abort on any difference (mk/om-encoder.mk). Use a separate OUT_DIR per value.
79CUDAPP_ENCODER ?= om
80CUDAPP_ENCODER_DEFS_om :=
81CUDAPP_ENCODER_DEFS_c := -DCUDAPP_MIGRATION_PENDING_C_ENCODER
82CUDAPP_ENCODER_DEFS_diff := -DCUDAPP_MIGRATION_PENDING_ENCODER_DIFF
83CUDAPP_ENCODER_DEFS = $(CUDAPP_ENCODER_DEFS_$(CUDAPP_ENCODER))
84ifeq ($(filter om c diff,$(CUDAPP_ENCODER)),)
85$(error CUDAPP_ENCODER must be om, c or diff)
86endif
87# sm_121 disassembler (CUDA++ C6, DRA-475): om (default) = om/disasm/sm121_dis.om through the generated binding
88# src/cudapp_om_sm121_dis.c; c = the migration-pending C decoder in src/omega_sm121_disasm.c, the differential oracle;
89# diff = both on every word, abort on any difference (mk/sm121dis.mk). Use a separate OUT_DIR per value.
90CUDAPP_DISASM ?= om
91CUDAPP_DISASM_DEFS_om :=
92CUDAPP_DISASM_DEFS_c := -DCUDAPP_MIGRATION_PENDING_C_DISASM
93CUDAPP_DISASM_DEFS_diff := -DCUDAPP_MIGRATION_PENDING_DISASM_DIFF
94CUDAPP_DISASM_DEFS = $(CUDAPP_DISASM_DEFS_$(CUDAPP_DISASM))
95ifeq ($(filter om c diff,$(CUDAPP_DISASM)),)
96$(error CUDAPP_DISASM must be om, c or diff)
97endif
98
99# Every C file of the GPU part, the shared base (tools/extract/shared.txt), the driver client and the generated
100# binding of the seeded Omega units (om/units.sh). src/omega_fp8_slot_table.c is the slot table under
101# src/omega_gpu_fp8_slots.c (Expert Ribbon P1, omega #533).
102SRCS := $(sort $(wildcard src/omega_blackwell_*.c src/omega_gpu_*.c src/omega_ampere_*.c)) src/omega_fp8_slot_table.c \
103 src/omega_cubin.c src/omega_native_artifact.c src/omega_sm121_disasm.c src/omega_runtime_api.c \
104 src/sha256.c src/omega_canonical.c src/omega_core.c src/omega_vector.c $(CUDAPP_BINDING_SRCS) \
105 $(PHYSICS_DIR)/m16/m16_native.c $(PHYSICS_DIR)/nvrm/nvrm.c $(AMPERE_CORPUS_SRCS)
106OBJS = $(patsubst %.c,$(OUT_DIR)/%.o,$(notdir $(SRCS)))
107DEPS = $(OBJS:.o=.d)
108-include $(DEPS)
109vpath %.c src $(PHYSICS_DIR)/m16 $(PHYSICS_DIR)/nvrm
110
111$(OUT_DIR):
112 mkdir -p $@
113$(OUT_DIR)/%.o: %.c | $(OUT_DIR)
114 $(CC) $(CFLAGS) $(CUDAPP_ENCODER_DEFS) $(CUDAPP_DISASM_DEFS) -c $< -o $@
115
116.PHONY: all libcudapp test clean
117all: $(OUT_DIR)/libomega_gpu.a $(OUT_DIR)/libcudapp.a
118$(OUT_DIR)/libcudapp.a: $(OUT_DIR)/libomega_gpu.a
119 cp $< $@
120libcudapp: $(OUT_DIR)/libcudapp.a
121clean:
122 rm -rf $(OUT_DIR) build
123
124# FB-1 cut 1: native (no CUDA) matmul entry point for the inference stack.
125# libomega_gpu.a = everything the tool links except its main; the Rust FFI crate
126# (cut 2) links it. test-gpu-matmul-api runs the host-only refusals; the chip
127# sweep is `./build/gpu_matmul_api_test --out receipt.json` through the heavy queue.
128.PHONY: artifact-export test-native-artifact
129# Offline handoff for one native realization (CUDApp #68 / #69). Opens no device.
130ARTIFACT_EXPORT = $(OUT_DIR)/artifact-export
131artifact-export: $(ARTIFACT_EXPORT)
132ARTIFACT_TEST = $(OUT_DIR)/gpu_artifact_export_test
133# These two recipes compile omega_cubin.c on the command line, which overrides the
134# archive member with the same .om packer the library links.
135$(ARTIFACT_EXPORT): tools/artifact_export.c src/omega_native_artifact.c src/omega_native_artifact_om.inc src/omega_cubin.c $(OUT_DIR)/libomega_gpu.a
136 $(CC) $(CFLAGS) -o $@ tools/artifact_export.c src/omega_native_artifact.c src/omega_cubin.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
137$(ARTIFACT_TEST): tests/gpu_artifact_export_test.c src/omega_native_artifact.c src/omega_native_artifact_om.inc src/omega_cubin.c $(OUT_DIR)/libomega_gpu.a
138 $(CC) $(CFLAGS) -o $@ tests/gpu_artifact_export_test.c src/omega_native_artifact.c src/omega_cubin.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
139# cubin-probe is the only target that links NVIDIA's libcuda: an interop check that NVIDIA's own loader accepts
140# CUDA++'s cubin. It is not in `make test`; zero-cuda-gate (in HOST_TESTS) checks hello_gpu and the API test link no CUDA.
141CUDA_INC ?= /usr/local/cuda/include
142CUDA_LIB ?= /usr/local/cuda/lib64
143$(OUT_DIR)/cubin_probe: tools/interop/cubin_probe.c $(OUT_DIR)/libomega_gpu.a
144 $(CC) $(CFLAGS) -I$(CUDA_INC) -o $@ tools/interop/cubin_probe.c $(OUT_DIR)/libomega_gpu.a -L$(CUDA_LIB) -lcuda -lpthread -lm
145cubin-probe: $(OUT_DIR)/cubin_probe
146# Artifacts are immutable (export refuses an existing file), so each run starts from an empty directory.
147# The shape checks run first so the C test's summary stays the last line (docs/CI_ACCEPTANCE.md).
148test-native-artifact: $(ARTIFACT_EXPORT) $(ARTIFACT_TEST)
149 sh tools/artifact_export_shapes.sh ./$(ARTIFACT_EXPORT) $(OUT_DIR)/artifact-shapes
150 rm -rf $(OUT_DIR)/artifact-test
151 ./$(ARTIFACT_TEST) $(OUT_DIR)/artifact-test
152# Pure artifact-format boundary: portable host test, no driver or device objects.
153.PHONY: test-native-artifact-manifest
154$(OUT_DIR)/native_artifact_manifest_test: tests/native_artifact_manifest_test.c src/omega_native_artifact.c src/omega_native_artifact_om.inc src/omega_cubin.c src/omega_blackwell_realize.c src/sha256.c $(CUDAPP_BINDING_SRCS) | $(OUT_DIR)
155 $(CC) $(CFLAGS) -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,--wrap=fopen -o $@ $(filter %.c,$^) -lpthread
156test-native-artifact-manifest: $(OUT_DIR)/native_artifact_manifest_test
157 ./$(OUT_DIR)/native_artifact_manifest_test
158.PHONY: libomega_gpu test-gpu-matmul-api
159# The two gate-runner objects (omegatool's M17/M18/M19 and World gates) are NOT part of the
160# library: nothing in the library or in the Rust FFI crate calls them (checked with nm), and
161# they compile the physics checkout path into the object (-DOMEGA_PHYSICS_DIR), which made the
162# archive digest depend on where physics was checked out. Without them libomega_gpu.a is
163# byte-identical for any PHYSICS_DIR and any omega checkout directory.
164GPU_API_OBJS = $(OBJS) $(OUT_DIR)/plat_fx_effects.o $(OUT_DIR)/plat_fx_wait.o
165GPU_API_TEST = $(OUT_DIR)/gpu_matmul_api_test
166GPU_R4_RECEIPT = $(OUT_DIR)/gpu_matmul_r4_receipt
167$(OUT_DIR)/libomega_gpu.a: $(GPU_API_OBJS)
168 rm -f $@
169 ar rcs $@ $(GPU_API_OBJS)
170libomega_gpu: $(OUT_DIR)/libomega_gpu.a
171$(GPU_API_TEST): tests/gpu_matmul_api_test.c src/omega_gpu_matmul_api.h $(OUT_DIR)/libomega_gpu.a
172 $(CC) $(CFLAGS) -o $@ tests/gpu_matmul_api_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
173test-gpu-matmul-api: $(GPU_API_TEST) $(GPU_R4_RECEIPT)
174 ./$(GPU_API_TEST) --host-only
175 ./$(GPU_R4_RECEIPT) --host-only
176
177# omega #473 R4: the sealed CTA-budget receipt (full-output comparison at the training shapes,
178# every budget, repeats, I42 stale-output check, negative controls). Host-only self-test above; the
179# chip receipt is `quietlock run -- ./build/gpu_matmul_r4_receipt --out receipt.json`.
180$(GPU_R4_RECEIPT): tests/gpu_matmul_r4_receipt.c src/omega_gpu_matmul_api.h $(OUT_DIR)/libomega_gpu.a
181 $(CC) $(CFLAGS) -o $@ tests/gpu_matmul_r4_receipt.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
182
183# FB-1 cut 4: native rmsnorm / rope / swiglu (+ EX2 and shared-exchange probes).
184# test-gpu-elementwise is host-only (refusals, codegen, word fixtures, nvdisasm
185# listing); the chip gate is `./build/gpu_elementwise_test --out receipt.json`
186# through the heavy queue. -ffp-contract=off keeps the f32 oracle free of FMA.
187.PHONY: test-gpu-elementwise
188GPU_EW_TEST = $(OUT_DIR)/gpu_elementwise_test
189$(GPU_EW_TEST): tests/gpu_elementwise_test.c src/omega_gpu_elementwise_api.h $(OUT_DIR)/libomega_gpu.a
190 $(CC) $(CFLAGS) -ffp-contract=off -o $@ tests/gpu_elementwise_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
191test-gpu-elementwise: $(GPU_EW_TEST)
192 ./$(GPU_EW_TEST) --host-only
193
194# GB10 fixed-latency chains versus Mesa NAK. test-gpu-latmeas is host-only
195# (encode, disassemble, oracle, diff). The chip gate is tools/latmeas/run_spark.sh.
196.PHONY: test-gpu-latmeas
197GPU_LATMEAS_TEST = $(OUT_DIR)/gpu_latmeas_test
198$(GPU_LATMEAS_TEST): tests/gpu_latmeas_test.c $(OUT_DIR)/libomega_gpu.a
199 $(CC) $(CFLAGS) -ffp-contract=off -o $@ tests/gpu_latmeas_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
200test-gpu-latmeas: $(GPU_LATMEAS_TEST)
201 sh tools/latmeas/selftest.sh $(GPU_LATMEAS_TEST)
202
203# Audit rows 29/30: GB10 xoshiro256** (aien-math stream) and batched f32 complex FFT, kernels from
204# om/mathlibs/mathlibs_ir.om. test-gpu-mathlibs is host-only (fixture, refusals, codegen, listing, normal sweep)
205# plus the warp simulator (bit-exact streams, FFT within the Wolfram tolerance, mutants); the chip gate is
206# `./build/gpu_mathlibs_test --out receipt.txt` under the GB10 lock.
207.PHONY: test-gpu-mathlibs
208GPU_MATHLIBS_TEST = $(OUT_DIR)/gpu_mathlibs_test
209$(GPU_MATHLIBS_TEST): tests/gpu_mathlibs_test.c tests/bw_warp_sim.h src/omega_gpu_mathlibs_api.h src/omega_gpu_om_ir.h $(OUT_DIR)/libomega_gpu.a
210 $(CC) $(CFLAGS) -ffp-contract=off -Itests -o $@ tests/gpu_mathlibs_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
211test-gpu-mathlibs: $(GPU_MATHLIBS_TEST)
212 ./$(GPU_MATHLIBS_TEST) --sim
213
214# Host-policy migration gate: C oracle, source-derived partitions, red/link
215# negatives, gcov and seeded .om mutants. Run with the device-masked wrapper.
216.PHONY: test-mathlibs-host-om
217test-mathlibs-host-om:
218 python3 tests/mathlibs_host_om.py
219
220# omega #308: structured warp reconvergence (BSSY/BSYNC regions). test-gpu-reconv is
221# host-only (encoder goldens, region bookkeeping, refusals, nvdisasm listing, every probe
222# kernel through the SIMT warp simulator tests/bw_warp_sim.h against the oracle, mutation
223# controls); the chip gate is tools/run_gpu_reconv_chip.sh.
224.PHONY: test-gpu-reconv
225GPU_RECONV_TEST = $(OUT_DIR)/gpu_reconv_test
226$(GPU_RECONV_TEST): tests/gpu_reconv_test.c tests/bw_warp_sim.h src/omega_gpu_elementwise_api.h src/omega_bw_reconv.h $(OUT_DIR)/libomega_gpu.a
227 $(CC) $(CFLAGS) -Itests -o $@ tests/gpu_reconv_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
228test-gpu-reconv: $(GPU_RECONV_TEST)
229 ./$(GPU_RECONV_TEST) --host-only
230
231# FB-1 cut 5: native gqa_attention (f32 KV) and paged_attention (bf16 KV, + batch).
232# head_dim 128 (Qwen3-4B): the same battery with --hd 128 through both host simulators; GB10 parity PASS 126/0
233# at 7dd92dc (evidence/FB1-CUT5-HD128-7dd92dc).
234# test-gpu-attention runs host-only (refusals, codegen, nvdisasm listing) and then the
235# whole parity battery through the host IR simulator (--sim, no chip); the chip
236# gate is `./build/gpu_attention_test --out receipt.json` through the heavy queue
237# (tools/run_gpu_attention_chip.sh). -ffp-contract=off keeps the oracle free of FMA.
238# General kernel (0.6.0): --general --sim runs the predeclared 318-config sweep (head_dim 1..256, MHA/GQA/MQA,
239# causal/windows, strides, paged) and the general mutants on the host simulator; the chip run is
240# `./build/gpu_attention_test --general --out g.json` under /tmp/aien-gb10.lock.
241.PHONY: test-gpu-attention
242GPU_ATTN_TEST = $(OUT_DIR)/gpu_attention_test
243$(GPU_ATTN_TEST): tests/gpu_attention_test.c tests/bw_warp_sim.h src/omega_gpu_attention_api.h $(OUT_DIR)/libomega_gpu.a
244 $(CC) $(CFLAGS) -ffp-contract=off -Itests -o $@ tests/gpu_attention_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
245test-gpu-attention: $(GPU_ATTN_TEST)
246 ./$(GPU_ATTN_TEST) --host-only
247 ./$(GPU_ATTN_TEST) --sim
248 ./$(GPU_ATTN_TEST) --sweep --sim --out $(OUT_DIR)/gpu_attention_sweep_sim.json
249 ./$(GPU_ATTN_TEST) --hd 128 --host-only
250 ./$(GPU_ATTN_TEST) --hd 128 --sim
251 ./$(GPU_ATTN_TEST) --hd 128 --divergent --sim
252 ./$(GPU_ATTN_TEST) --general --sim --out $(OUT_DIR)/gpu_attention_general_sim.json
253
254# FB-1 cut 4b: fresh-process device-open probe (flake investigation, tools/probe_gpu_open.sh)
255$(OUT_DIR)/gpu_session_probe: tests/gpu_session_probe.c src/omega_gpu_session.h $(OUT_DIR)/libomega_gpu.a
256 $(CC) $(CFLAGS) -o $@ tests/gpu_session_probe.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
257
258# OWN-30B cut 2: window matmul gate (tests/gpu_moe_window_test.c). test-gpu-moe-window runs the host-only
259# refusals and the packed-window byte rule; the chip gate is `./build/gpu_moe_window_test --out r.json`
260# under /tmp/aien-gb10.lock (equivalence to the whole-tensor columns, mutants, window timing).
261GPU_MOE_TEST = $(OUT_DIR)/gpu_moe_window_test
262$(GPU_MOE_TEST): tests/gpu_moe_window_test.c src/omega_gpu_moe_api.h src/omega_gpu_matmul_api.h $(OUT_DIR)/libomega_gpu.a
263 $(CC) $(CFLAGS) -o $@ tests/gpu_moe_window_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
264.PHONY: test-gpu-moe-window
265test-gpu-moe-window: $(GPU_MOE_TEST)
266 ./$(GPU_MOE_TEST) --host-only
267
268# OWN-30B Cut 6 / Cut 5 (2026-10-13): FP8 e4m3 block-scaled GEMV (omega_gpu_fp8_api.h). test-gpu-fp8 is host-only
269# (exhaustive conversion, pack refusals, codegen budgets, nvdisasm listing) then the warp-simulator battery
270# (parity, grouped experts, mutants, both fragment orders); the chip gate is tools/run_gpu_fp8_chip.sh.
271# -ffp-contract=off keeps the double oracle free of FMA.
272.PHONY: test-gpu-fp8
273GPU_FP8_TEST = $(OUT_DIR)/gpu_fp8_api_test
274$(GPU_FP8_TEST): tests/gpu_fp8_api_test.c tests/bw_warp_sim.h src/omega_gpu_fp8_api.h src/omega_blackwell_codegen_moe.h $(OUT_DIR)/libomega_gpu.a
275 $(CC) $(CFLAGS) -ffp-contract=off -Itests -o $@ tests/gpu_fp8_api_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
276test-gpu-fp8: $(GPU_FP8_TEST)
277 sh tests/grid_ab_exit_test.sh ./$(GPU_FP8_TEST)
278 ./$(GPU_FP8_TEST) --host-only
279 ./$(GPU_FP8_TEST) --sim
280
281# omega #457 (2026-10-15): host rewrite of a GPU-cached buffer must be visible to the next launch. Chip only; the gate
282# is tools/run_gpu_l2_stale_chip.sh.
283GPU_L2_STALE_TEST = $(OUT_DIR)/gpu_l2_stale_test
284$(GPU_L2_STALE_TEST): tests/gpu_l2_stale_test.c src/omega_gpu_fp8_api.h src/omega_gpu_fp8_internal.h src/omega_gpu_session.h $(OUT_DIR)/libomega_gpu.a
285 $(CC) $(CFLAGS) -ffp-contract=off -o $@ tests/gpu_l2_stale_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
286
287# Expert Ribbon P1 (aienix#4 / omega#533, 2026-10-18): versioned replaceable FP8 expert slots (omega_gpu_fp8_slots.h).
288# test-gpu-fp8-slots is host-only (slot state machine, threaded race, mutant); the chip gate is omega's
289# tools/run_gpu_fp8_slots_chip.sh under the GB10 lock (parity vs resident, churn, reader fence via a command list,
290# negative control). That runner reads omega's physics.lock and is not carried here.
291.PHONY: test-gpu-fp8-slots
292GPU_FP8_SLOTS_TEST = $(OUT_DIR)/gpu_fp8_slots_test
293$(GPU_FP8_SLOTS_TEST): tests/gpu_fp8_slots_test.c src/omega_gpu_fp8_slots.h src/omega_fp8_slot_table.h src/omega_gpu_fp8_api.h src/omega_gpu_cmdlist.h $(OUT_DIR)/libomega_gpu.a
294 $(CC) $(CFLAGS) -ffp-contract=off -o $@ tests/gpu_fp8_slots_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
295test-gpu-fp8-slots: $(GPU_FP8_SLOTS_TEST)
296 ./$(GPU_FP8_SLOTS_TEST) --host-only
297
298# OWN-30B cut 8 (2026-10-13): one-launch decode attention (omega_gpu_decode_attn_api.h). The target below is host-only.
299# Chip: build/gpu_decode_attn_test --out decode.json, only during an explicitly authorized GB10 window.
300.PHONY: test-gpu-decode-attn
301GPU_DATTN_TEST = $(OUT_DIR)/gpu_decode_attn_test
302$(GPU_DATTN_TEST): tests/gpu_decode_attn_test.c tests/bw_warp_sim_k.h src/omega_gpu_decode_attn_api.h src/omega_blackwell_codegen_attn.h $(OUT_DIR)/libomega_gpu.a
303 $(CC) $(CFLAGS) -ffp-contract=off -Itests -o $@ tests/gpu_decode_attn_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
304test-gpu-decode-attn: $(GPU_DATTN_TEST) test-gpu-decode-attn-maxpos
305 $(GPU_DATTN_TEST) --host-only
306
307
308# omega #535: the 128k position bound on a fake platform, no device. ASan/UBSan
309# check the adapter against exact-size buffers. The seven controls now mutate
310# the generated policy binding; read/write/step share one span predicate.
311# Canonical .om source mutation remains in test-api-plan-mutants.
312.PHONY: test-gpu-decode-attn-maxpos
313GPU_DATTN_MAXPOS_TEST = $(OUT_DIR)/test_omega_gpu_decode_attn_maxpos
314GPU_DATTN_MAXPOS_MUT = $(OUT_DIR)/dattn_maxpos_mut
315GPU_DATTN_MAXPOS_SAN = -O1 -g -fsanitize=address,undefined -fno-sanitize-recover=all
316$(GPU_DATTN_MAXPOS_TEST): tests/test_omega_gpu_decode_attn_maxpos.c src/omega_gpu_decode_attn_api.c src/omega_gpu_decode_attn_api.h src/omega_blackwell_codegen_attn.h $(OUT_DIR)/libomega_gpu.a
317 $(CC) $(filter-out -MMD -MP -O2,$(CFLAGS)) $(GPU_DATTN_MAXPOS_SAN) -o $@ tests/test_omega_gpu_decode_attn_maxpos.c \
318 src/omega_gpu_decode_attn_api.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
319test-gpu-decode-attn-maxpos: $(GPU_DATTN_MAXPOS_TEST)
320 $(GPU_DATTN_MAXPOS_TEST)
321 CC="$(CC)" python3 tests/runtime/api_plan_maxpos_mutants.py "$(OUT_DIR)/libomega_gpu.a" "$(filter-out -MMD -MP -O2,$(CFLAGS))"
322
323# OWN-30B cut 8 item 2 (2026-10-13): one-launch MoE router (omega_gpu_router_api.h). test-gpu-router is host-only
324# (oracle, budgets) plus the warp simulator; the chip gate is tools/run_gpu_router_chip.sh under the GB10 lock.
325.PHONY: test-gpu-router
326GPU_ROUTER_TEST = $(OUT_DIR)/gpu_router_test
327$(GPU_ROUTER_TEST): tests/gpu_router_test.c tests/bw_warp_sim_k.h src/omega_gpu_router_api.h src/omega_blackwell_codegen_router.h src/omega_gpu_fp8_api.h $(OUT_DIR)/libomega_gpu.a
328 $(CC) $(CFLAGS) -ffp-contract=off -Itests -o $@ tests/gpu_router_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
329test-gpu-router: $(GPU_ROUTER_TEST)
330 ./$(GPU_ROUTER_TEST) --host-only
331 ./$(GPU_ROUTER_TEST) --sim
332
333# OWN-30B (2026-10-13): bf16 streaming GEMV, the lm_head (omega_gpu_bf16_gemv_api.h). test-gpu-bf16-gemv is host-only
334# (emulation, budgets) plus the warp simulator (bit-identical to the host f32 emulation, mutants 1-3 caught); the chip
335# gate is tools/run_gpu_bf16_gemv_chip.sh under the GB10 lock.
336.PHONY: test-gpu-bf16-gemv
337GPU_BF16_TEST = $(OUT_DIR)/gpu_bf16_gemv_test
338$(GPU_BF16_TEST): tests/gpu_bf16_gemv_test.c tests/bw_warp_sim_k.h src/omega_gpu_bf16_gemv_api.h src/omega_blackwell_codegen_bf16.h $(OUT_DIR)/libomega_gpu.a
339 $(CC) $(CFLAGS) -ffp-contract=off -Itests -o $@ tests/gpu_bf16_gemv_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
340test-gpu-bf16-gemv: $(GPU_BF16_TEST)
341 $(GPU_BF16_TEST) --host-only
342 $(GPU_BF16_TEST) --sim
343
344# The ternary GEMV host test (tests/gpu_tern_test.c) stays in Omega: its reference is Omega's ternary
345# algebra oracle (src/algebra), which is not part of CUDA++. The library itself (omega_gpu_tern_api) is here.
346# Sass#4 (2026-10-27): the generator's I2FP consumer rule (scoreboard or >= 19 cycles), host only, with its negative
347# control (mutant 4, the pre-fix stall 6, must be refused). No reference oracle needed, so it lives here.
348.PHONY: test-gpu-tern-sched
349GPU_TERN_SCHED_TEST = $(OUT_DIR)/gpu_tern_sched_test
350$(GPU_TERN_SCHED_TEST): tests/gpu_tern_sched_test.c tests/bw_warp_sim_k.h tests/bw_mufu_ftz.h src/omega_blackwell_codegen_tern.h $(OUT_DIR)/libomega_gpu.a
351 $(CC) $(CFLAGS) -o $@ tests/gpu_tern_sched_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
352test-gpu-tern-sched: $(GPU_TERN_SCHED_TEST)
353 $(GPU_TERN_SCHED_TEST)
354
355
356# OWN-30B (2026-10-13): report-only lm_head study, fp8 vs bf16 argmax agreement on the real checkpoint (chip, GB10 lock).
357$(OUT_DIR)/gpu_lmhead_fp8_study: tests/gpu_lmhead_fp8_study.c src/omega_gpu_bf16_gemv_api.h src/omega_gpu_fp8_api.h $(OUT_DIR)/libomega_gpu.a
358 $(CC) $(CFLAGS) -O2 -o $@ tests/gpu_lmhead_fp8_study.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
359
360# OWN-30B prefill (2026-10-13): FP8 grouped GEMM (omega_gpu_fp8gemm_api.h). test-gpu-fp8gemm is host-only (emulation,
361# permutation, budgets) plus the warp simulator (512 threads); the chip gate is tools/run_gpu_fp8gemm_chip.sh under the GB10 lock.
362.PHONY: test-gpu-fp8gemm
363GPU_FP8GEMM_TEST = $(OUT_DIR)/gpu_fp8gemm_test
364$(GPU_FP8GEMM_TEST): tests/gpu_fp8gemm_test.c tests/bw_warp_sim_k.h src/omega_gpu_fp8gemm_api.h src/omega_blackwell_codegen_gemm.h src/omega_gpu_fp8_api.h $(OUT_DIR)/libomega_gpu.a
365 $(CC) $(CFLAGS) -ffp-contract=off -DWS_MAX_THREADS=512 -Itests -o $@ tests/gpu_fp8gemm_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
366test-gpu-fp8gemm: $(GPU_FP8GEMM_TEST)
367 $(GPU_FP8GEMM_TEST) --host-only
368 $(GPU_FP8GEMM_TEST) --sim
369
370# OWN-30B (2026-10-13): host-only audit that every launcher declares peak + 2 registers (the chip hung at peak + 1).
371.PHONY: test-gpu-gpr-boundary
372GPU_GPR_BOUNDARY_TEST = $(OUT_DIR)/gpu_gpr_boundary_test
373$(GPU_GPR_BOUNDARY_TEST): tests/gpu_gpr_boundary_test.c src/omega_blackwell_codegen.h $(OUT_DIR)/libomega_gpu.a
374 $(CC) $(CFLAGS) -o $@ tests/gpu_gpr_boundary_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
375test-gpu-gpr-boundary: $(GPU_GPR_BOUNDARY_TEST)
376 $(GPU_GPR_BOUNDARY_TEST)
377
378# OWN-30B T3 (2026-10-13): HMMA arithmetic probe (host model self-checks; chip run under the GB10 lock).
379GPU_TC_PROBE_TEST = $(OUT_DIR)/gpu_tc_probe_test
380$(GPU_TC_PROBE_TEST): tests/gpu_tc_probe_test.c tests/bw_hmma_model.h src/omega_blackwell_codegen_tc.h $(OUT_DIR)/libomega_gpu.a
381 $(CC) $(CFLAGS) -ffp-contract=off -Itests -o $@ tests/gpu_tc_probe_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
382
383GPU_TCGEMM_TEST = $(OUT_DIR)/gpu_tcgemm_test
384$(GPU_TCGEMM_TEST): tests/gpu_tcgemm_test.c tests/bw_hmma_model.h tests/bw_warp_sim_tc.h src/omega_blackwell_codegen_tc.h $(OUT_DIR)/libomega_gpu.a
385 $(CC) $(CFLAGS) -ffp-contract=off -DWS_MAX_THREADS=512 -Itests -o $@ tests/gpu_tcgemm_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
386
387GPU_TC_PEAK_TEST = $(OUT_DIR)/gpu_tc_peak_test
388$(GPU_TC_PEAK_TEST): tests/gpu_tc_peak_test.c tests/bw_hmma_model.h tests/bw_warp_sim_tc.h src/omega_blackwell_codegen_tc.h $(OUT_DIR)/libomega_gpu.a
389 $(CC) $(CFLAGS) -ffp-contract=off -DWS_MAX_THREADS=512 -Itests -o $@ tests/gpu_tc_peak_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
390
391# OWN-30B L1 attention (2026-10-13): tensor-core causal prefill attention. --host-only and --sim are host proofs.
392# Chip: build/gpu_prefill_attn_test --out prefill.json, only during an explicitly authorized GB10 window.
393GPU_PATTN_TEST = $(OUT_DIR)/gpu_prefill_attn_test
394$(GPU_PATTN_TEST): tests/gpu_prefill_attn_test.c tests/bw_hmma_model.h tests/bw_warp_sim_pa.h src/omega_gpu_prefill_attn_api.h src/omega_blackwell_codegen_pattn.h $(OUT_DIR)/libomega_gpu.a
395 $(CC) $(CFLAGS) -ffp-contract=off -DWS_MAX_THREADS=256 -Itests -o $@ tests/gpu_prefill_attn_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
396# OWN-30B T3b (2026-10-13): device-resident prefill module tests (host sim first; chip parts under the GB10 lock)
397GPU_PF_MEM_TEST = $(OUT_DIR)/gpu_pf_mem_test
398$(GPU_PF_MEM_TEST): tests/gpu_pf_mem_test.c tests/bw_warp_sim_tc.h src/omega_gpu_prefill.h src/omega_blackwell_codegen_pf.h $(OUT_DIR)/libomega_gpu.a
399 $(CC) $(CFLAGS) -ffp-contract=off -DWS_MAX_THREADS=512 -Itests -o $@ tests/gpu_pf_mem_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
400GPU_PFGEMM_TEST = $(OUT_DIR)/gpu_pfgemm_test
401$(GPU_PFGEMM_TEST): tests/gpu_pfgemm_test.c tests/bw_hmma_model.h tests/bw_warp_sim_tc.h src/omega_gpu_prefill.h src/omega_blackwell_codegen_tc2.h $(OUT_DIR)/libomega_gpu.a
402 $(CC) $(CFLAGS) -ffp-contract=off -DWS_MAX_THREADS=512 -Itests -o $@ tests/gpu_pfgemm_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
403GPU_QMMA_PROBE_TEST = $(OUT_DIR)/gpu_qmma_probe_test
404$(GPU_QMMA_PROBE_TEST): tests/gpu_qmma_probe_test.c tests/bw_qmma_model.h src/omega_blackwell_codegen_qmma.h $(OUT_DIR)/libomega_gpu.a
405 $(CC) $(CFLAGS) -ffp-contract=off -Itests -o $@ tests/gpu_qmma_probe_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
406GPU_QGEMM_TEST = $(OUT_DIR)/gpu_qgemm_test
407$(GPU_QGEMM_TEST): tests/gpu_qgemm_test.c tests/bw_qmma_model.h tests/bw_warp_sim_tc.h src/omega_gpu_prefill.h src/omega_blackwell_codegen_qg.h $(OUT_DIR)/libomega_gpu.a
408 $(CC) $(CFLAGS) -ffp-contract=off -DWS_MAX_THREADS=1024 -Itests -o $@ tests/gpu_qgemm_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
409.PHONY: test-gemm-selectors
410test-gemm-selectors: $(GPU_PFGEMM_TEST) $(GPU_QGEMM_TEST) $(GPU_FP8GEMM_TEST)
411 python3 tests/gemm_selectors.py $(OUT_DIR)
412
413GPU_PFHOST_TEST = $(OUT_DIR)/gpu_pfhost_test
414$(GPU_PFHOST_TEST): tests/gpu_pfhost_test.c tests/bw_warp_sim_tc.h src/omega_gpu_pfhost.h src/omega_blackwell_codegen_pfhost.h $(OUT_DIR)/libomega_gpu.a
415 $(CC) $(CFLAGS) -ffp-contract=off -DWS_MAX_THREADS=1024 -Itests -o $@ tests/gpu_pfhost_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
416# omega#456: the prefill tests above, host model and warp simulator only. Every run names --host-only or --sim, the two
417# modes that never open the device (each test's main returns before its chip part); chip runs stay under the GB10 lock.
418.PHONY: test-gpu-prefill-host
419test-gpu-prefill-host: $(GPU_TC_PROBE_TEST) $(GPU_TCGEMM_TEST) $(GPU_PATTN_TEST) $(GPU_PF_MEM_TEST) $(GPU_PFGEMM_TEST) \
420 $(GPU_QMMA_PROBE_TEST) $(GPU_QGEMM_TEST) $(GPU_PFHOST_TEST)
421 ./$(GPU_TC_PROBE_TEST) --host-only
422 ./$(GPU_QMMA_PROBE_TEST) --host-only
423 ./$(GPU_PF_MEM_TEST) --host-only
424 ./$(GPU_TCGEMM_TEST) --host-only
425 ./$(GPU_TCGEMM_TEST) --sim
426 ./$(GPU_PATTN_TEST) --host-only
427 ./$(GPU_PATTN_TEST) --sim
428 ./$(GPU_PFGEMM_TEST) --host-only
429 ./$(GPU_PFGEMM_TEST) --sim
430 ./$(GPU_QGEMM_TEST) --host-only
431 ./$(GPU_QGEMM_TEST) --sim
432 ./$(GPU_PFHOST_TEST) --host-only
433 ./$(GPU_PFHOST_TEST) --sim
434 @echo "test-gpu-prefill-host: PASS (8 prefill tests, host model + warp simulator, no device)"
435# omega#456: tools/own30b_decode_profile.c is a link-only recorder built by hand on the Spark; compile it with the
436# project's -Werror flags so a warning cannot land unseen.
437.PHONY: check-own30b-decode-profile
438check-own30b-decode-profile: tools/own30b_decode_profile.c
439 @mkdir -p $(OUT_DIR)
440 $(CC) $(CFLAGS) -c -o $(OUT_DIR)/own30b_decode_profile.o tools/own30b_decode_profile.c
441 @echo "check-own30b-decode-profile: PASS (compiles with -Werror)"
442# OWN-30B W-L2 (2026-10-13): command list (many launches, one submission) + decode glue kernels. test-gpu-cmdlist is
443# host-only + warp simulator; the chip gate is tools/run_gpu_cmdlist_chip.sh under the GB10 lock.
444.PHONY: test-gpu-cmdlist
445GPU_CMDLIST_TEST = $(OUT_DIR)/gpu_cmdlist_test
446$(GPU_CMDLIST_TEST): tests/gpu_cmdlist_test.c tests/bw_warp_sim_k.h src/omega_gpu_cmdlist.h src/omega_blackwell_codegen_dec.h $(OUT_DIR)/libomega_gpu.a
447 $(CC) $(CFLAGS) -ffp-contract=off -Itests -o $@ tests/gpu_cmdlist_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
448test-gpu-cmdlist: $(GPU_CMDLIST_TEST)
449 ./$(GPU_CMDLIST_TEST) --host-only
450 ./$(GPU_CMDLIST_TEST) --sim
451
452# OWN-30B W-L2a (2026-10-13): one decode token as one command list (omega_gpu_decode_graph). test-gpu-decode-graph is
453# host-only; the chip gate is tools/run_gpu_decode_graph_chip.sh under the GB10 lock.
454.PHONY: test-gpu-decode-graph
455GPU_DECODE_GRAPH_TEST = $(OUT_DIR)/gpu_decode_graph_test
456GPU_DGRAPH_ABORT_TEST = $(OUT_DIR)/test_omega_gpu_decode_graph_abort
457$(GPU_DECODE_GRAPH_TEST): tests/gpu_decode_graph_test.c src/omega_gpu_decode_graph.h src/omega_gpu_cmdlist.h $(OUT_DIR)/libomega_gpu.a
458 $(CC) $(CFLAGS) -ffp-contract=off -o $@ tests/gpu_decode_graph_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
459test-gpu-decode-graph: $(GPU_DECODE_GRAPH_TEST) $(GPU_DGRAPH_ABORT_TEST) test-gpu-decode-graph-abort-mutants test-gpu-decode-graph-timeline
460 ./$(GPU_DECODE_GRAPH_TEST) --host-only
461 ./$(GPU_DGRAPH_ABORT_TEST)
462
463# omega #518: lock and token-state recovery of the split API (failed begin_token, abort_token, end_token after a failed
464# record, latched session) on a fake platform whose lock refuses a second acquisition. Host only, opens no device.
465# Each mutant breaks one rule in a copy of omega_gpu_decode_graph.c linked ahead of the library; the test must FAIL on it.
466.PHONY: test-gpu-decode-graph-abort-mutants
467GPU_DGRAPH_MUT_DIR = $(OUT_DIR)/dgraph_mut
468$(GPU_DGRAPH_ABORT_TEST): tests/test_omega_gpu_decode_graph_abort.c src/omega_gpu_decode_graph.h src/omega_gpu_platform.h $(OUT_DIR)/libomega_gpu.a
469 $(CC) $(CFLAGS) -o $@ tests/test_omega_gpu_decode_graph_abort.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
470test-gpu-decode-graph-abort-mutants: $(OUT_DIR)/libomega_gpu.a
471 @mkdir -p $(GPU_DGRAPH_MUT_DIR)
472 @set -e; killed=0; \
473 dmut() { name=$$1; script=$$2; \
474 sed -e "$$script" src/omega_gpu_decode_graph.c > $(GPU_DGRAPH_MUT_DIR)/$$name.c; \
475 if cmp -s src/omega_gpu_decode_graph.c $(GPU_DGRAPH_MUT_DIR)/$$name.c; then echo "mutant $$name: pattern not found"; exit 1; fi; \
476 $(CC) $(filter-out -MMD -MP,$(CFLAGS)) -c -o $(GPU_DGRAPH_MUT_DIR)/$$name.o $(GPU_DGRAPH_MUT_DIR)/$$name.c; \
477 $(CC) $(filter-out -MMD -MP,$(CFLAGS)) -o $(GPU_DGRAPH_MUT_DIR)/$$name tests/test_omega_gpu_decode_graph_abort.c \
478 $(GPU_DGRAPH_MUT_DIR)/$$name.o $(OUT_DIR)/libomega_gpu.a -lpthread -lm; \
479 if ./$(GPU_DGRAPH_MUT_DIR)/$$name > $(GPU_DGRAPH_MUT_DIR)/$$name.log 2>&1; then echo "mutant $$name SURVIVED"; exit 1; fi; \
480 nfail=$$(grep -c '^FAIL' $(GPU_DGRAPH_MUT_DIR)/$$name.log || true); \
481 if [ "$$nfail" -eq 0 ]; then echo "mutant $$name: nonzero exit but no FAIL case (did not run?)"; cat $(GPU_DGRAPH_MUT_DIR)/$$name.log; exit 1; fi; \
482 echo "mutant $$name killed: $$nfail case(s) failed"; killed=$$((killed+1)); }; \
483 dmut begin-fail-keeps-lock 's| omega_gpu_session_unlock(); /\* begin_fail releases \*/| ;|'; \
484 dmut begin-fail-stays-in-token 's| g->in_token = 0; g->failed = 1;| g->failed = 1;|'; \
485 dmut oneshot-old-bad-args-only 's|if (brc != OMEGA_GPU_DGRAPH_OK) {|if (brc == OMEGA_GPU_DGRAPH_BAD_ARGS) {|'; \
486 dmut abort-keeps-lock 's|g->n_stamp = 0; /\* no timeline for an abandoned token \*/|&\n return OMEGA_GPU_DGRAPH_OK;|'; \
487 dmut abort-submits 's|^int omega_gpu_decode_graph_abort_token(OmegaGpuDecodeGraph \*g) {$$|&\n if (g \&\& g->in_token) return omega_gpu_decode_graph_end_token(g, NULL, NULL);|'; \
488 echo "test-gpu-decode-graph-abort-mutants: $$killed of 5 mutants killed"
489
490# omega #456: the per-token timeline (set_stamps) never writes past stamp[]: 4096 stamped launches fill it, the 4097th
491# (flush_each, one submission per launch) fails the token and leaves no timeline. Fake platform that completes every
492# submission; no device. Each mutant breaks one rule in a copy of omega_gpu_decode_graph.c linked ahead of the library;
493# the overflow case must FAIL on it.
494.PHONY: test-gpu-decode-graph-timeline
495GPU_DGRAPH_TL_TEST = $(OUT_DIR)/test_omega_gpu_decode_graph_timeline
496GPU_DGRAPH_TL_MUT = $(OUT_DIR)/dgraph_tl_mut
497$(GPU_DGRAPH_TL_TEST): tests/test_omega_gpu_decode_graph_timeline.c src/omega_gpu_decode_graph.h src/omega_gpu_platform.h $(OUT_DIR)/libomega_gpu.a
498 $(CC) $(CFLAGS) -o $@ tests/test_omega_gpu_decode_graph_timeline.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
499test-gpu-decode-graph-timeline: $(GPU_DGRAPH_TL_TEST)
500 ./$(GPU_DGRAPH_TL_TEST)
501 @mkdir -p $(GPU_DGRAPH_TL_MUT)
502 @set -e; \
503 tmut() { name=$$1; script=$$2; \
504 sed -e "$$script" src/omega_gpu_decode_graph.c > $(GPU_DGRAPH_TL_MUT)/$$name.c; \
505 if cmp -s src/omega_gpu_decode_graph.c $(GPU_DGRAPH_TL_MUT)/$$name.c; then echo "mutant $$name: pattern not found"; exit 1; fi; \
506 $(CC) $(filter-out -MMD -MP,$(CFLAGS)) -o $(GPU_DGRAPH_TL_MUT)/$$name tests/test_omega_gpu_decode_graph_timeline.c \
507 $(GPU_DGRAPH_TL_MUT)/$$name.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm; \
508 if ./$(GPU_DGRAPH_TL_MUT)/$$name > $(GPU_DGRAPH_TL_MUT)/$$name.log 2>&1; then echo "mutant $$name SURVIVED"; exit 1; fi; \
509 if ! grep -q '^FAIL one launch past the timeline' $(GPU_DGRAPH_TL_MUT)/$$name.log; then \
510 echo "mutant $$name: no FAIL case (did not run?)"; cat $(GPU_DGRAPH_TL_MUT)/$$name.log; exit 1; fi; \
511 echo "mutant $$name killed"; }; \
512 tmut room-off-by-one 's|OMEGA_GPU_CMDLIST_MAX_LAUNCHES + 1u, \&from)|OMEGA_GPU_CMDLIST_MAX_LAUNCHES + 2u, \&from)|'; \
513 tmut timeline-after-failure 's#if (!g->stamps || g->failed || #if (!g->stamps || #'; \
514 echo "test-gpu-decode-graph-timeline: 2 of 2 mutants killed"
515
516# OWN-30B W-L2c (2026-10-14): per-launch fixed cost inside a command list (tests/gpu_launch_cost_test.c, chip only, GB10 lock).
517GPU_LAUNCH_COST_TEST = $(OUT_DIR)/gpu_launch_cost_test
518$(GPU_LAUNCH_COST_TEST): tests/gpu_launch_cost_test.c src/omega_gpu_fp8_api.h src/omega_gpu_cmdlist.h $(OUT_DIR)/libomega_gpu.a
519 $(CC) $(CFLAGS) -ffp-contract=off -o $@ tests/gpu_launch_cost_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
520
521# OWN-30B W-L2d (2026-10-14): L2 reuse of FP8 GEMV weights between two launches of one list (tests/gpu_l2_reuse_test.c, chip only, GB10 lock).
522GPU_L2_REUSE_TEST = $(OUT_DIR)/gpu_l2_reuse_test
523$(GPU_L2_REUSE_TEST): tests/gpu_l2_reuse_test.c src/omega_gpu_fp8_api.h src/omega_gpu_cmdlist.h $(OUT_DIR)/libomega_gpu.a
524 $(CC) $(CFLAGS) -ffp-contract=off -o $@ tests/gpu_l2_reuse_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
525
526# The Blackwell QMD shared-memory field (word 36): the encoding of every size, the fixed SM-config
527# fields beside it, and the refusal one byte over OMEGA_BW_QMD_MAX_SHARED_BYTES (a host check, no GPU).
528.PHONY: test-gpu-qmd-shared test-gpu-qmd-shared-clean-build
529QMD_SHARED_TEST = $(OUT_DIR)/test_omega_bw_qmd_shared
530$(QMD_SHARED_TEST): tests/test_omega_bw_qmd_shared.c src/omega_blackwell_qmd.h src/omega_blackwell_qmd.c src/cudapp_om_bw_qmd.c src/cudapp_native.h | $(OUT_DIR)
531 $(CC) $(CFLAGS) -o $@ tests/test_omega_bw_qmd_shared.c src/omega_blackwell_qmd.c src/cudapp_om_bw_qmd.c
532test-gpu-qmd-shared: $(QMD_SHARED_TEST)
533 $(QMD_SHARED_TEST)
534
535# Build the same host-only test with an output directory that does not exist yet.
536# The normal test target does not recurse through this regression target.
537test-gpu-qmd-shared-clean-build:
538 +@set -eu; out=$$(mktemp -d); trap 'rm -rf "$$out"' EXIT; \
539 $(MAKE) --no-print-directory OUT_DIR="$$out/new" test-gpu-qmd-shared
540
541# Fresh-checkout contract for issue 15. The slice runner and the barrier contract
542# need no sibling compiler. The architecture guard runs on x86-64. On AArch64
543# the target prints NOT_RUN and does not build the binary, so this check never
544# asks the production path to open a device. test-omega-slices is the
545# eight-slice gate and is not part of `make test`.
546.PHONY: test-omega-slice-runner test-omega-arch-guard test-omega-barrier-contract test-omega-binding-portable test-omega-target-only test-omega-slices
547ARCH_GUARD_TEST = $(OUT_DIR)/omega_blackwell_arch_guard_test
548$(ARCH_GUARD_TEST): tests/test_omega_blackwell_arch_guard.c tests/fake_m16_native.c tests/fake_m16_native.h \
549 $(GPU_ENGINE_SIM_SRCS) src/omega_gpu_wait.c | $(OUT_DIR)
550 $(CC) -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -pthread -ffunction-sections -fdata-sections \
551 -Isrc -Itests $(GPU_ENGINE_PHYS_INC) -o $@ tests/test_omega_blackwell_arch_guard.c tests/fake_m16_native.c \
552 $(GPU_ENGINE_SIM_SRCS) src/omega_gpu_wait.c -Wl,--gc-sections -lm
553ifeq ($(CUDAPP_HOST_IS_AARCH64),1)
554test-omega-arch-guard:
555 OUT_DIR=$(OUT_DIR) sh tests/omega/test-arch-guard.sh
556else
557test-omega-arch-guard: $(ARCH_GUARD_TEST)
558 OUT_DIR=$(OUT_DIR) sh tests/omega/test-arch-guard.sh $(ARCH_GUARD_TEST)
559endif
560test-omega-slice-runner:
561 sh tests/omega/test-runner.sh
562test-omega-barrier-contract:
563 sh tests/omega/test-barrier-contract.sh
564test-omega-binding-portable:
565 CC=$(CC) OUT_DIR=$(OUT_DIR) sh tests/omega/test-binding-portable.sh
566test-omega-target-only:
567 sh tests/omega/test-target-only.sh $(CUDAPP_TARGET_ONLY_TESTS)
568test-omega-slices:
569 sh tests/omega/run.sh $(or $(OMEGA_SLICE_FUZZ),120)
570
571# Every host-only check: no GPU, no device opened. The chip gates are listed in README.md.
572# Portable commands and the AArch64-only rows are separated in docs/OMEGA_HOST_TESTS.md.
573HOST_TESTS = test-drift test-pin-sync test-gpu-matmul-api test-gpu-elementwise test-gpu-latmeas test-gpu-mathlibs test-gpu-reconv test-gpu-attention test-gpu-moe-window \
574 test-gpu-fp8 test-gpu-decode-attn test-gpu-router test-gpu-bf16-gemv test-gpu-fp8gemm test-gpu-tern-sched test-gpu-gpr-boundary \
575 test-gpu-cmdlist test-gpu-decode-graph test-gpu-code-alloc test-gpu-engine-compile test-gpu-engine \
576 test-gpu-engine-mutants test-gpu-engine-backend-compile test-gpu-engine-prod-build test-gpu-engine-sim \
577 test-gpu-engine-backend-mutants test-gpu-engine-gb10-compile test-gpu-serving-alloc test-gpu-engine-freestanding \
578 test-codegen-freestanding test-gpu-session-platform test-gpu-native-runtime test-gpu-wait test-gpu-wait-mutants host-tests-m16 \
579 test-runtime-api test-runtime-portability test-doctor test-hello-sim test-native-artifact-manifest test-gemm-selectors \
580 test-native-artifact zero-cuda-gate verify-vendored test-swap-cli test-om-encoder test-om-spec-encoder test-om-cubin test-om-streams \
581 test-ampere-encoder test-ampere-cubin test-ampere-numeric-host test-ampere-f16-host test-ampere-runtime test-ampere-plan \
582 test-portable-receipts test-gpu-qmd-shared test-model-capacity test-gpu-qmd-shared-clean-build \
583 test-omega-slice-runner test-omega-arch-guard test-omega-barrier-contract test-omega-binding-portable \
584 test-gpu-imadhi-rc test-dagsim test-costmodel test-gpu-fp8-slots test-bw-hazard test-mufu-ftz \
585 test-zero-cuda-tool-argv $(CARRIED_HOST_TESTS) test-gpu-platform-aien test-prof
586ifneq ($(CUDAPP_TARGET_ONLY_TESTS),)
587HOST_TESTS := $(filter-out $(CUDAPP_TARGET_ONLY_TESTS),$(HOST_TESTS)) test-omega-target-only
588endif
589test: $(HOST_TESTS)
590 @echo "CUDA++ HOST TESTS PASS ($(words $(HOST_TESTS)) targets)"
591
592# Pre-landing host AMD gate set, separate from the CUDA++ host suite.
593# OMEGA_OMC must name the absolute seeded compiler; each gate checks its own pin.
594# AMD_WEIGHTS supplies the local checkpoint oracle used by documented commands.
595# Caller holds CPU-pool isolation and supplies python3 with the documented dependencies.
596.PHONY: test-amd
597test-amd:
598 sh tests/amd/run.sh "$(OMEGA_OMC)"
599 sh tests/amd-kfd/run.sh "$(OMEGA_OMC)"
600 sh tests/amd-exec/run.sh "$(OMEGA_OMC)"
601 sh tests/multitarget/run.sh "$(OMEGA_OMC)"
602
603.PHONY: test-prof
604ifeq ($(CUDAPP_OMC_HOST),1)
605test-prof:
606 OMEGA_OMC="$${OMEGA_OMC:-$(HOME)/work/cudastack/omega-mv/seed/out/omc}" bash tools/prof/selftest.sh
607else
608test-prof:
609 @echo "test-prof: 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)"
610 @exit 2
611endif
612
613.PHONY: test-model-capacity
614ifeq ($(CUDAPP_OMC_HOST),1)
615test-model-capacity:
616 OMEGA_OMC="$(OMEGA_OMC)" sh tests/models/capacity.sh
617else
618test-model-capacity:
619 @echo "test-model-capacity: 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)"
620 @exit 2
621endif
622
623# CUDApp#184 C0 frozen CUDA compatibility profile: host-only static admission plus negative controls.
624.PHONY: test-cuda-c0-profile
625test-cuda-c0-profile:
626 rm -rf build/cuda-c0-profile
627 OMEGA_OMC="$(OMEGA_OMC)" sh compat/cuda/test.sh build/cuda-c0-profile
628
629.PHONY: test-drift
630test-drift:
631 bash tools/extract/test-drift.sh
632
633# Original Git blobs are read-only verification oracles, not a replacement receipt authority.
634.PHONY: test-portable-receipts
635ifeq ($(CUDAPP_OMC_HOST),1)
636test-portable-receipts: test-om-units tests/portable_receipts.om tests/portable_receipts.tsv om/cache/digest.om
637 @mkdir -p build/portable_receipts
638 cat om/cache/digest.om tests/portable_receipts.om > build/portable_receipts.source.om
639 "$(OMEGA_OMC)" < build/portable_receipts.source.om > build/portable_receipts_check
640 chmod +x build/portable_receipts_check
641 @set -eu; tab=$$(printf '\t'); \
642 while IFS="$$tab" read -r path blob derived_sha; do \
643 test -n "$$path" && test -n "$$blob" && test -n "$$derived_sha"; \
644 printf '%s %s\n' "$$derived_sha" "$$path" | sha256sum -c -; \
645 GIT_NO_REPLACE_OBJECTS=1 git cat-file blob "$$blob" > build/portable_receipts/original; \
646 ./build/portable_receipts_check build/portable_receipts/original "$$path" "$$blob"; \
647 done < tests/portable_receipts.tsv
648else
649test-portable-receipts:
650 @echo "test-portable-receipts: 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)"
651 @exit 2
652endif
653
654# The vendored NVIDIA headers match THIRD_PARTY.md's SHA256SUMS; the self-test (flipped byte, extra file) must FAIL.
655.PHONY: verify-vendored test-swap-cli
656verify-vendored:
657 tools/verify-vendored.sh --self-test
658 tools/verify-vendored.sh
659# `cudapp swap` on a fake machine root: no root rights, no GPU, nothing outside a temp dir touched.
660test-swap-cli:
661 bash tests/swap/test_swap_cli.sh
662
663# Zero-CUDA gate (tools/zero-cuda-gate.sh): the built programs need no NVIDIA CUDA library and import
664# no CUDA symbol. The self-test is the negative control (a stub libcudart must FAIL).
665.PHONY: zero-cuda-gate
666zero-cuda-gate: $(HELLO_GPU) $(GPU_API_TEST)
667 tools/zero-cuda-gate.sh --self-test
668 tools/zero-cuda-gate.sh $(HELLO_GPU) $(GPU_API_TEST)
669
670# omega #492: IMAD.HI.U32 with a register Rc. The chip reads Rc as a 64-bit register pair (nvcc 13.0
671# sm_121 oracle, evidence/IMADHI-RC-ORACLE-nvcc13.0-20261016; chip probe pending), so the four warp
672# simulators model an even Rc as the pair Rc+1:Rc and refuse an odd Rc, and replay the PR #487
673# odd-column pack (it must come out wrong, as on the chip). One binary per simulator header.
674.PHONY: test-gpu-imadhi-rc
675GPU_IMADHI_SIMS = bw_warp_sim bw_warp_sim_tc bw_warp_sim_k bw_warp_sim_pa
676GPU_IMADHI_TESTS = $(GPU_IMADHI_SIMS:%=$(OUT_DIR)/gpu_imadhi_rc_test_%)
677$(OUT_DIR)/gpu_imadhi_rc_test_%: tests/gpu_imadhi_rc_test.c tests/%.h $(OUT_DIR)/libomega_gpu.a
678 $(CC) $(CFLAGS) -Itests -DSIM_HEADER='"$*.h"' -o $@ tests/gpu_imadhi_rc_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
679test-gpu-imadhi-rc: $(GPU_IMADHI_TESTS)
680 @for t in $(GPU_IMADHI_TESTS); do ./$$t || exit 1; done
681
682# omega-mv#554: static scoreboard hazard checker (RAW / WAR / WAW) over the encoded bytes of every kernel the generators
683# build, after the launchers' patch steps. Host only: decoder vs encoder, the pre-#553 attend red receipt
684# (tests/fixtures/bw_hazard), negative controls, then the sweep. test-bw-hazard-nvdisasm (the name it had when it
685# called nvdisasm) adds the decoder cross-check against Omega's own sm_121 disassembler, in process, on every distinct
686# kernel (bar C6: every check that called nvdisasm calls ours; test-sm121dis checks that disassembler against the oracle).
687.PHONY: test-bw-hazard test-bw-hazard-nvdisasm
688BW_HAZARD_TEST = $(OUT_DIR)/bw_hazard_test
689$(BW_HAZARD_TEST): tests/bw_hazard_test.c src/omega_bw_hazard.c src/omega_bw_hazard.h src/omega_sm121_disasm.h $(OUT_DIR)/libomega_gpu.a
690 $(CC) $(CFLAGS) -o $@ tests/bw_hazard_test.c src/omega_bw_hazard.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
691test-bw-hazard: $(BW_HAZARD_TEST)
692 $(BW_HAZARD_TEST)
693test-bw-hazard-nvdisasm: $(BW_HAZARD_TEST)
694 $(BW_HAZARD_TEST) --disasm
695
696# Offline resource-DAG evaluator, imported verbatim from closed PR #590
697# (commit 3bd56731). Host arithmetic on the numbers written in the fixtures.
698# Not a validated cost model and not a hardware measurement.
699# src/omega_om_units.c is not in this tree. src/sha256.c is sha256_hash on every host.
700# tests/dagsim/sha256_host.c is omega's non-AArch64 stub and aborts if a digest is requested.
701# dagsim.o keeps the #590 (3bd56731) nm guard: no generation store, authority,
702# world, or a call that maps or runs code.
703.PHONY: test-dagsim
704DS_OBJ = $(OUT_DIR)/dagsim.o
705DS_UNIT = $(OUT_DIR)/dagsim_unit
706DS_CLI = $(OUT_DIR)/dagsim
707# sha256.c binds the seeded om/core/sha256.om unit (CoreUtil #308), so its generated C links beside it.
708DS_SHA_SRC = src/sha256.c src/cudapp_om_core_sha.c
709RX_CM_OBJ = $(OUT_DIR)/rx_costmodel.o
710RX_CM_BINDING = src/cudapp_om_cm_sort.c src/cudapp_om_cm_math.c src/cudapp_om_cm_fit.c src/cudapp_om_cm_stats.c src/cudapp_om_cm_features.c src/cudapp_om_cm_quantile.c src/cudapp_om_cm_decision.c src/cudapp_om_cm_prediction.c src/cudapp_om_cm_calibration.c src/cudapp_om_cm_blob.c src/cudapp_om_cm_digest.c
711RX_CM_BINDING += src/cudapp_om_cm_route.c
712
713# Host-policy prerequisites expand while this include is parsed.
714include mk/host-policy.mk
715
716$(RX_CM_OBJ): src/runtime/rx_costmodel.c src/runtime/rx_costmodel.h src/runtime/rx_cm_sort.h src/runtime/rx_cm_math.h src/cudapp_native.h | $(OUT_DIR)
717 $(CC) $(CFLAGS) -ffp-contract=off -c -o $@ src/runtime/rx_costmodel.c
718 @if nm -u $@ | grep -E 'rx_gen_|aienos_cap_|rx_caproot_|rx_capadmin_|rx_world_|mmap|mprotect|fork|exec|dlopen|system' ; then \
719 echo "rx_costmodel.o references an operation a cost model must not have"; \
720 rm -f $@; exit 1; fi
721
722# omega OMEGA_EMPIRICAL_OPTIMIZER cost model, any host: synthetic measurements; fit, calibration, decisions, blob.
723# The restore-op-clamp mutant (omega #934) must be killed by unsupported-op-not-aliased-to-matvec.
724.PHONY: test-costmodel
725RX_CM_UNIT = $(OUT_DIR)/rx_costmodel_unit
726$(RX_CM_UNIT): tests/runtime/rx_costmodel_unit.c $(RX_CM_OBJ) $(DS_SHA_SRC) $(RX_CM_BINDING) | $(OUT_DIR)
727 $(CC) $(CFLAGS) -ffp-contract=off -o $@ tests/runtime/rx_costmodel_unit.c $(RX_CM_OBJ) $(DS_SHA_SRC) $(RX_CM_BINDING) -lm
728
729$(OUT_DIR)/cm_route_unit: tests/runtime/cm_route_unit.c src/cudapp_om_cm_route.c | $(OUT_DIR)
730 $(CC) $(CFLAGS) -ffp-contract=off -Isrc -o $@ $<
731
732$(OUT_DIR)/cm_route_oracle: tests/runtime/cm_route_oracle.c src/runtime/rx_costmodel.c $(RX_CM_BINDING) $(DS_SHA_SRC) | $(OUT_DIR)
733 $(CC) $(CFLAGS) -ffp-contract=off -Isrc -o $@ $< $(RX_CM_BINDING) $(DS_SHA_SRC) -lm
734
735.PHONY: test-cm-route
736test-cm-route: $(OUT_DIR)/cm_route_unit $(OUT_DIR)/cm_route_oracle
737 ./$(OUT_DIR)/cm_route_unit
738 ./$(OUT_DIR)/cm_route_oracle
739 @if ./$(OUT_DIR)/cm_route_unit --red; then echo "FAIL route red control survived"; exit 1; fi
740 $(call CUDAPP_OMC_STEP,python3 tests/runtime/cm_route_mutants.py,cm_route .om mutants)
741
742test-costmodel: $(RX_CM_UNIT) test-cm-route
743 ./$(RX_CM_UNIT)
744 @set -eu; dir=$(OUT_DIR)/costmodel-mutant; rm -rf $$dir; mkdir -p $$dir; \
745 sed "/CM704:refuse-unsupported-op/c\\ uint32_t op = f && f->op < RX_CM_OPS ? f->op : RX_CM_OPS - 1u; /* CM704:refuse-unsupported-op */" \
746 src/runtime/rx_costmodel.c > $$dir/rx_costmodel.c; \
747 if cmp -s src/runtime/rx_costmodel.c $$dir/rx_costmodel.c; then \
748 echo "mutant restore-op-clamp: sed changed nothing"; exit 1; fi; \
749 $(CC) $(CFLAGS) -ffp-contract=off -DCUDAPP_MIGRATION_PENDING_C_CM_FEATURES=1 -c -o $$dir/rx_costmodel.o $$dir/rx_costmodel.c; \
750 $(CC) $(CFLAGS) -ffp-contract=off -o $$dir/unit tests/runtime/rx_costmodel_unit.c $$dir/rx_costmodel.o $(DS_SHA_SRC) $(RX_CM_BINDING) -lm; \
751 rc=0; $$dir/unit refuse > $$dir/out.txt 2> $$dir/err.txt || rc=$$?; \
752 if [ $$rc -eq 0 ] || ! grep -q unsupported-op-not-aliased-to-matvec $$dir/err.txt; then \
753 echo "mutant restore-op-clamp was not killed by unsupported-op-not-aliased-to-matvec (exit $$rc)"; \
754 cat $$dir/err.txt; exit 1; fi; \
755 echo "mutant restore-op-clamp: killed by unsupported-op-not-aliased-to-matvec (exit $$rc)"
756
757$(DS_OBJ): tools/dagsim/dagsim.c tools/dagsim/dagsim.h tools/dagsim/dagsim_format.h tools/dagsim/dagsim_resolve.h src/cudapp_native.h src/runtime/rx_costmodel.h | $(OUT_DIR)
758 $(CC) $(CFLAGS) -ffp-contract=off -Itools/dagsim -c -o $@ tools/dagsim/dagsim.c
759 @if nm -u $@ | grep -E 'rx_gen_|aienos_cap_|rx_caproot_|rx_capadmin_|rx_world_|mmap|mprotect|fork|exec|dlopen|system' ; then \
760 echo "dagsim.o references an operation an offline evaluator must not have"; \
761 rm -f $@; exit 1; fi
762
763DS_OM = src/cudapp_om_dag_eval.c src/cudapp_om_dag_parse.c src/cudapp_om_dag_fmt.c src/cudapp_om_dag_res.c src/cudapp_om_dag_diff.c
764DS_OM += src/cudapp_om_dag_jstr.c
765$(DS_UNIT): tests/dagsim/dagsim_unit.c $(DS_OBJ) $(RX_CM_OBJ) $(DS_SHA_SRC) $(RX_CM_BINDING) $(DS_OM) | $(OUT_DIR)
766 $(CC) $(CFLAGS) -ffp-contract=off -Itools/dagsim -o $@ tests/dagsim/dagsim_unit.c $(DS_OBJ) $(RX_CM_OBJ) $(DS_SHA_SRC) $(RX_CM_BINDING) $(DS_OM) -Wl,--wrap=rx_cm_predict -lm
767
768$(DS_CLI): tools/dagsim/dagsim_cli.c $(DS_OBJ) $(RX_CM_OBJ) $(DS_SHA_SRC) $(RX_CM_BINDING) $(DS_OM) | $(OUT_DIR)
769 $(CC) $(CFLAGS) -ffp-contract=off -Itools/dagsim -o $@ tools/dagsim/dagsim_cli.c $(DS_OBJ) $(RX_CM_OBJ) $(DS_SHA_SRC) $(RX_CM_BINDING) $(DS_OM) -lm
770
771test-dagsim: $(DS_UNIT) $(DS_CLI)
772 ./$(DS_UNIT)
773 sh tests/dagsim/run_cli.sh $(DS_CLI) $(OUT_DIR)/dagsim-cli-out
774 sh tests/dagsim/mutant_lifetime.sh
775 sh tests/dagsim/mutant_predict.sh
776 $(call CUDAPP_OMC_STEP,sh tests/dagsim/mutant_omega.sh $(DS_CLI),dag_eval .om mutants)
777
778# Pure emitter/reconvergence and fragment-provider source differentials. Invoke
779# the entire make command under the device-free bwrap contract.
780.PHONY: test-checkers-om test-frag-packers-om
781test-checkers-om:
782 sh tests/regalloc_om/checkers.sh
783 python3 tests/regalloc_om/checkers_mutants.py
784
785test-frag-packers-om:
786 sh tests/regalloc_om/packers.sh
787 python3 tests/regalloc_om/packers_mutants.py
788
789.PHONY: test-dagsim-parse-om
790test-dagsim-parse-om:
791 python3 tests/dagsim/parse_check.py
792
793.PHONY: test-dagsim-resolve-om
794test-dagsim-resolve-om:
795 python3 tests/dagsim/resolve_check.py
796
797.PHONY: test-dagsim-corpus-om
798test-dagsim-corpus-om:
799 sh tests/dagsim/corpus_gate.sh
800
801# The shared CLI is consumed by both original-seed AMD tools and the newer
802# native launcher. Release readiness must validate both compiler paths.
803AMD_LAUNCH_OMC ?=
804.PHONY: test-amd-launch test-amd-release
805test-amd-launch:
806 @test -n "$(AMD_LAUNCH_OMC)" || { echo "Set AMD_LAUNCH_OMC to the launcher COMPILER pin" >&2; exit 64; }
807 python3 -I tests/amd-kfd-launch/check.py "$(AMD_LAUNCH_OMC)"
808
809# backend/amd/kfd/launch/COMPILER is generated from the root PIN (moved by pin-follow.sh); never edit it by hand.
810# PIN_COMPILER writes it to $(1) after checking PIN is the two lines `omega-mv <40 hex>` / `omc-sha256 <64 hex>`.
811PIN_COMPILER = r=$$(sed -n 's/^omega-mv \([0-9a-f]\{40\}\)$$/\1/p' PIN); s=$$(sed -n 's/^omc-sha256 \([0-9a-f]\{64\}\)$$/\1/p' PIN); \
812 [ -n "$$r" ] && [ -n "$$s" ] && [ "$$(wc -l < PIN)" -eq 2 ] || { echo "PIN is not omega-mv <40 hex> / omc-sha256 <64 hex>" >&2; exit 1; }; \
813 printf '%s\n%s seed/out/omc\n' "$$r" "$$s" > $(1)
814.PHONY: pin-compiler test-pin-sync pin-hand-list
815pin-compiler:
816 @$(call PIN_COMPILER,backend/amd/kfd/launch/COMPILER)
817test-pin-sync:
818 @t=$$(mktemp) && trap 'rm -f "$$t"' EXIT && $(call PIN_COMPILER,"$$t") && \
819 cmp "$$t" backend/amd/kfd/launch/COMPILER || { echo "FAIL pin-sync: backend/amd/kfd/launch/COMPILER differs from PIN; run make pin-compiler" >&2; exit 1; }; \
820 echo "PASS pin-sync COMPILER generated from PIN"
821# pin-hand-list prints every tracked file outside evidence/ that names an omega-mv build other than PIN's: an
822# omega-mv commit (any 40-hex that is a commit of OMEGA_MV_GIT) or an omc sha256 seed/out/omc.sha256 held in any commit there.
823# These still type their own compiler pin; the list is generated, never copied.
824OMEGA_MV_GIT ?= $(HOME)/git/omega-mv.git
825pin-hand-list:
826 @git -C "$(OMEGA_MV_GIT)" rev-parse -q --verify HEAD >/dev/null || { echo "FAIL pin-hand-list: no omega-mv store at $(OMEGA_MV_GIT)" >&2; exit 1; }; \
827 t=$$(mktemp) && trap 'rm -f "$$t"' EXIT && { git -C "$(OMEGA_MV_GIT)" log --all --full-history -m -p --format= -- seed/out/omc.sha256 | \
828 sed -n 's/^+\([0-9a-f]\{64\}\).*/\1/p'; git grep -hoIE '\b[0-9a-f]{40}\b' -- ':!evidence' | sort -u | \
829 git -C "$(OMEGA_MV_GIT)" cat-file --batch-check | awk '$$2 == "commit" { print $$1 }'; } | sort -u | \
830 grep -vxF -e "$$(sed -n 's/^omega-mv //p' PIN)" -e "$$(sed -n 's/^omc-sha256 //p' PIN)" > "$$t"; \
831 [ -s "$$t" ] || { echo "FAIL pin-hand-list: no omc digests read from $(OMEGA_MV_GIT)" >&2; exit 1; }; \
832 git grep -lIF -f "$$t" -- ':!evidence' ':!PIN'; [ $$? -le 1 ]
833
834test-amd-release: test-amd
835 $(MAKE) test-amd-launch AMD_LAUNCH_OMC="$(AMD_LAUNCH_OMC)"