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/platform-linux.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 / platform-linux.mk` 117 lines · 7433 bytes Raw Blame History 1 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 # Linux platform policy differential. No device is opened. 3 CARRIED_HOST_TESTS += test-platform-linux-policy test-platform-linux-fake-device test-platform-linux-effects test-platform-linux-wait 4 # The fake device controller is an Omega program compiled by the pinned AArch64 omc. 5 CUDAPP_TARGET_ONLY_TESTS += $(if $(CUDAPP_OMC_HOST),,test-platform-linux-fake-device) 6 .PHONY: test-platform-linux-policy test-platform-linux-fake-device test-platform-linux-effects test-platform-linux-wait 7 8 $(OUT_DIR)/platform_linux_policy: tests/platform_linux_policy.c src/cudapp_om_plat_policy.c src/omega_gpu_platform_linux_cpolicy.h 9 @mkdir -p $(OUT_DIR) 10 $(CC) $(CFLAGS) -Itests -Isrc -o $@ tests/platform_linux_policy.c 11 12 test-platform-linux-policy: $(OUT_DIR)/platform_linux_policy 13 $(OUT_DIR)/platform_linux_policy 14 15 $(OUT_DIR)/plat_fx_effects.o: om/platform-linux/gen/link/plat_fx_effects.c 16 @mkdir -p $(OUT_DIR) 17 $(CC) $(CFLAGS) -c -o $@ $< 18 19 $(OUT_DIR)/plat_fx_wait.o: om/platform-linux/gen/link/plat_fx_wait.c 20 @mkdir -p $(OUT_DIR) 21 $(CC) $(CFLAGS) -c -o $@ $< 22 23 $(OUT_DIR)/platform_linux_effects: tests/platform_linux_effects.c om/platform-linux/gen/plat_effects.c src/cudapp_plat_effects.h 24 @mkdir -p $(OUT_DIR) 25 $(CC) $(CFLAGS) -Isrc -o $@ tests/platform_linux_effects.c om/platform-linux/gen/plat_effects.c -lpthread 26 27 test-platform-linux-effects: $(OUT_DIR)/platform_linux_effects 28 $(OUT_DIR)/platform_linux_effects 29 30 $(OUT_DIR)/platform_linux_wait: tests/platform_linux_wait.c om/platform-linux/gen/plat_wait.c 31 @mkdir -p $(OUT_DIR) 32 $(CC) $(CFLAGS) -o $@ tests/platform_linux_wait.c om/platform-linux/gen/plat_wait.c -lpthread 33 34 test-platform-linux-wait: $(OUT_DIR)/platform_linux_wait $(OUT_DIR)/platform_linux_wait_mutant 35 $(OUT_DIR)/platform_linux_wait 36 @set +e; $(OUT_DIR)/platform_linux_wait_mutant; rc=$$?; set -e; test $$rc -ne 0 37 @echo "PASS platform linux wait mutant caught" 38 39 # The mutant (2^31 bound -> 0) is committed by om/platform-linux/gen_effects.sh like 40 # plat_wait.c, so this carried gate needs no unpinned compiler. 41 $(OUT_DIR)/platform_linux_wait_mutant: tests/platform_linux_wait.c om/platform-linux/gen/plat_wait_mutant.c 42 @mkdir -p $(OUT_DIR) 43 grep -q `2147483648` om/platform-linux/plat_wait.om 44 ! cmp -s om/platform-linux/gen/plat_wait.c om/platform-linux/gen/plat_wait_mutant.c 45 $(CC) $(CFLAGS) -o $@ tests/platform_linux_wait.c om/platform-linux/gen/plat_wait_mutant.c -lpthread 46 47 $(OUT_DIR)/platform_linux_fake_devctl: om/platform-linux/fake_devctl.om 48 @mkdir -p $(OUT_DIR) 49 $(OMEGA_OMC) < om/platform-linux/fake_devctl.om > $@ 50 test -s $@ 51 chmod +x $@ 52 53 ifneq ($(CUDAPP_OMC_HOST),1) 54 test-platform-linux-fake-device: 55 @$(CUDAPP_REQUIRE_OMC) 56 else 57 test-platform-linux-fake-device: $(OUT_DIR)/platform_linux_fake_devctl 58 $(OUT_DIR)/platform_linux_fake_devctl 59 @sed 's/uchar len msg/uchar 18/' om/platform-linux/fake_devctl.om > $(OUT_DIR)/fake_devctl_mutant.om 60 @if cmp -s $(OUT_DIR)/fake_devctl_mutant.om om/platform-linux/fake_devctl.om; then echo "MUTANT BROKEN"; exit 1; fi 61 @$(OMEGA_OMC) < $(OUT_DIR)/fake_devctl_mutant.om > $(OUT_DIR)/fake_devctl_mutant 62 @chmod +x $(OUT_DIR)/fake_devctl_mutant 63 @$(OUT_DIR)/fake_devctl_mutant; test $$? -eq 4 64 @echo "PASS platform linux fake-device fixture (mutant exit 4)" 65 endif 66 67 # omega_gpu_live_marker (nvrm/nvrm.c) and its sole caller ref_poll_word. Host only, no device. The NVRM test maps 68 # memfd pages through the native client; the platform test replaces memfd_create so the poll must take the lookup. 69 # Each mutant breaks one rule in a copy and must fail: the lookup returning no/another context or ignoring the size, 70 # the caller polling plat_wait_ctx, passing NULL for rm or dropping the offset. 71 CARRIED_HOST_TESTS += test-live-marker 72 .PHONY: test-live-marker 73 LIVE_MARKER_MUT = $(OUT_DIR)/live_marker_mut 74 LIVE_MARKER_NVRM_LINK = src/cudapp_om_nvrm_transport.c src/omega_ampere_qmd.c src/cudapp_om_amp_runtime.c src/cudapp_om_amp_qmd.c $(NVRM_SERIALIZER_SRCS) \ 75 $(NVRM_ADMIT_SRCS) om/platform-linux/gen/link/plat_fx_wait.c 76 LIVE_MARKER_NVRM_CC = $(CC) $(CFLAGS) -UCUDAPP_MIGRATION_PENDING_C_NVRM -DCUDAPP_MIGRATION_PENDING_C_NVRM=0 -Invrm -Isrc 77 LIVE_MARKER_PLAT_CC = gcc -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -pthread -Isrc -Itests $(GPU_ENGINE_PHYS_INC) 78 $(OUT_DIR)/nvrm_live_marker: nvrm/live_marker_test.c nvrm/nvrm.c nvrm/nvrm.h nvrm/native_client.h $(LIVE_MARKER_NVRM_LINK) 79 @mkdir -p $(OUT_DIR) 80 $(LIVE_MARKER_NVRM_CC) -o $@ nvrm/live_marker_test.c $(LIVE_MARKER_NVRM_LINK) 81 $(OUT_DIR)/platform_linux_live_marker: tests/platform_linux_live_marker.c tests/fake_m16_native.c $(GPU_LINUX_REF_SRCS) $(GPU_LINUX_REF_CMDLIST_SRCS) 82 @mkdir -p $(OUT_DIR) 83 $(LIVE_MARKER_PLAT_CC) -o $@ tests/platform_linux_live_marker.c tests/fake_m16_native.c $(GPU_LINUX_REF_SRCS) $(GPU_LINUX_REF_CMDLIST_SRCS) -lm 84 test-live-marker: $(OUT_DIR)/nvrm_live_marker $(OUT_DIR)/platform_linux_live_marker 85 ./$(OUT_DIR)/nvrm_live_marker 86 ./$(OUT_DIR)/platform_linux_live_marker 87 @mkdir -p $(LIVE_MARKER_MUT) 88 @set -e; killed=0; \ 89 nmut() { name=$$1; script=$$2; d=$(LIVE_MARKER_MUT)/$$name; mkdir -p $$d; \ 90 sed -e "$$script" nvrm/nvrm.c > $$d/nvrm.c; cp nvrm/live_marker_test.c $$d/; \ 91 if cmp -s nvrm/nvrm.c $$d/nvrm.c; then echo "mutant $$name: pattern not found"; exit 1; fi; \ 92 $(LIVE_MARKER_NVRM_CC) -o $$d/t $$d/live_marker_test.c $(LIVE_MARKER_NVRM_LINK); \ 93 if ./$$d/t > $$d/log 2>&1; then echo "mutant $$name SURVIVED"; exit 1; fi; \ 94 echo "mutant $$name killed"; killed=$$((killed+1)); }; \ 95 pmut() { name=$$1; script=$$2; d=$(LIVE_MARKER_MUT)/$$name; mkdir -p $$d; \ 96 sed -e "$$script" src/omega_gpu_platform_linux.c > $$d/omega_gpu_platform_linux.c; \ 97 if cmp -s src/omega_gpu_platform_linux.c $$d/omega_gpu_platform_linux.c; then echo "mutant $$name: pattern not found"; exit 1; fi; \ 98 srcs=$$(echo $(GPU_LINUX_REF_SRCS) | tr ' ' '\n' | grep -v '^src/omega_gpu_platform_linux.c$$' | tr '\n' ' '); \ 99 $(LIVE_MARKER_PLAT_CC) -o $$d/t tests/platform_linux_live_marker.c tests/fake_m16_native.c $$d/omega_gpu_platform_linux.c $$srcs $(GPU_LINUX_REF_CMDLIST_SRCS) -lm; \ 100 if ./$$d/t > $$d/log 2>&1; then echo "mutant $$name SURVIVED"; exit 1; fi; \ 101 echo "mutant $$name killed"; killed=$$((killed+1)); }; \ 102 nmut ctx-null 's|\*ctx = rm->omega_context;|*ctx = NULL;|'; \ 103 nmut ctx-foreign 's|\*ctx = rm->omega_context;|*ctx = (struct omega_native_context *)rm;|'; \ 104 nmut size-zero 's|nvrm_live_token(rm, cpu, sizeof(uint32_t),|nvrm_live_token(rm, cpu, 0,|'; \ 105 pmut plat-wait-ctx 's| pctx = live;| pctx = plat_wait_ctx;|'; \ 106 pmut ignore-rm 's|omega_gpu_live_marker(&r->m16.rm, |omega_gpu_live_marker(NULL, |'; \ 107 pmut no-offset 's| map_off = byte_off;| map_off = 0;|'; \ 108 test $$killed -eq 6; echo "LIVE MARKER PASS (NVRM lookup + platform caller; 6 mutants killed; HOST_ONLY)" 109 CARRIED_HOST_TESTS += test-platform-linux-rest 110 .PHONY: test-platform-linux-rest 111 $(OUT_DIR)/platform_linux_rest: tests/platform_linux_rest.c src/cudapp_om_plat_rest.c src/omega_gpu_platform_linux_rest_oracle.h 112 @mkdir -p $(OUT_DIR) 113 $(CC) $(CFLAGS) -ffp-contract=off -Isrc -o $@ $< 114 test-platform-linux-rest: $(OUT_DIR)/platform_linux_rest 115 $(OUT_DIR)/platform_linux_rest 116 @if $(OUT_DIR)/platform_linux_rest --red; then echo "FAIL platform rest red control survived"; exit 1; fi 117 $(call CUDAPP_OMC_STEP,python3 tests/platform_linux_rest_mutants.py,platform rest .om mutants)