interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / mk / omega-gpu-wait.mk

42 lines · 3095 bytes Raw Blame History
1# Shared GPU completion wait primitive (src/omega_gpu_wait.c, linked by the C GPU paths): host unit
2# test with fake memory and a fake clock, plus a naive wall-clock mutant that must be caught. The same
3# test runs on the live C primitive and on its pure OM-2 port src/omega_gpu_wait.om. Picked up by
4# `-include mk/*.mk`. Host only: opens no device, needs no physics headers, takes no chip lock.
5GPU_WAIT_OMC ?= seed/out/omc
6GPU_WAIT_OM_SRCS := src/omega_gpu_wait.om tests/test_omega_gpu_wait.om
7.PHONY: test-gpu-wait
8build/test_omega_gpu_wait: tests/test_omega_gpu_wait.c src/omega_gpu_wait.c src/omega_gpu_wait.h
9 @mkdir -p build
10 gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -Isrc -o $@ tests/test_omega_gpu_wait.c src/omega_gpu_wait.c
11build/test_omega_gpu_wait_om: $(GPU_WAIT_OM_SRCS) $(GPU_WAIT_OMC)
12 @mkdir -p build
13 (printf 'om2\n'; sed '/^om2$$/d' $(GPU_WAIT_OM_SRCS)) | $(GPU_WAIT_OMC) > $@ && chmod +x $@
14test-gpu-wait: build/test_omega_gpu_wait build/test_omega_gpu_wait_om
15 ./build/test_omega_gpu_wait
16 ./build/test_omega_gpu_wait_om
17
18# Real-code mutants: src/omega_gpu_wait.c carries one-line compile-flag mutants and
19# src/omega_gpu_wait.om the same three as one-line constants. Each flagged C build and each .om copy
20# with one constant set to 1 must FAIL the suite; the unflagged builds must PASS. A mutant that does
21# not compile, or an .om edit that changes nothing, is an error, not a kill.
22GPU_WAIT_MUTANTS := OMEGA_GPU_WAIT_MUTANT_STALL_NO_RESET OMEGA_GPU_WAIT_MUTANT_PROGRESS_EXTENDS_HARD OMEGA_GPU_WAIT_MUTANT_NO_READ_BARRIER
23.PHONY: test-gpu-wait-mutants
24test-gpu-wait-mutants: build/test_omega_gpu_wait build/test_omega_gpu_wait_om
25 @./build/test_omega_gpu_wait >/dev/null || { echo "unflagged build FAILED"; exit 1; }
26 @echo "unflagged: PASS"
27 @set -e; for m in $(GPU_WAIT_MUTANTS); do \
28 gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -D$$m -Isrc -o build/test_omega_gpu_wait_$$m tests/test_omega_gpu_wait.c src/omega_gpu_wait.c; \
29 if ./build/test_omega_gpu_wait_$$m >build/test_omega_gpu_wait_$$m.log 2>&1; then echo "MUTANT SURVIVED: $$m"; exit 1; fi; \
30 echo "$$m: killed ($$(grep -c 'FAIL' build/test_omega_gpu_wait_$$m.log) failing checks)"; \
31 done
32 @./build/test_omega_gpu_wait_om >/dev/null || { echo "OM unedited build FAILED"; exit 1; }
33 @echo "OM unedited: PASS"
34 @set -e; for m in $(GPU_WAIT_MUTANTS); do \
35 sed "s/^const $$m int 0$$/const $$m int 1/" src/omega_gpu_wait.om > build/omega_gpu_wait_om_$$m.om; \
36 if cmp -s build/omega_gpu_wait_om_$$m.om src/omega_gpu_wait.om; then echo "MUTANT BROKEN: OM $$m edit changed nothing"; exit 1; fi; \
37 (printf 'om2\n'; sed '/^om2$$/d' build/omega_gpu_wait_om_$$m.om tests/test_omega_gpu_wait.om) | $(GPU_WAIT_OMC) > build/test_omega_gpu_wait_om_$$m; \
38 chmod +x build/test_omega_gpu_wait_om_$$m; \
39 if ./build/test_omega_gpu_wait_om_$$m >build/test_omega_gpu_wait_om_$$m.log 2>&1; then echo "MUTANT SURVIVED: OM $$m"; exit 1; fi; \
40 echo "OM $$m: killed ($$(grep -c 'FAIL' build/test_omega_gpu_wait_om_$$m.log) failing checks)"; \
41 done
42 @echo "OMEGA_GPU_WAIT_MUTANTS PASS"