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/c2-admission.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 / c2-admission.mk` 77 lines · 6294 bytes Raw Blame History 1 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 # Library GPU admission (developer bars D2, D6; ROADMAP C2). HOST_ONLY: simulated driver, fake PCI trees, no 3 # /dev/nvidia opens. 4 # make test-chip-admission .om decision vs the C host reference, refusals with zero device opens, 5 # the admitted path and the driver-card cross-checks in nvrm_open 6 # make test-chip-admission-mutants each mutant (.om decision or the nvrm_open call sites) must turn the test red 7 # (needs OMEGA_MV and OMEGA_BRIDGE_DIR as in mk/om-encoder.mk; without them exit 3, NOT_RUN, never PASS). 8 CHIP_ADMIT_DIR = $(OUT_DIR)/chip-admission 9 # The simulated driver replaces open/ioctl/close/mmap by macro; since NVRM #281 nvrm.c only takes those through 10 # the explicitly selected C test boundary (nvrm/native_client.h), as mk/ampere-runtime.mk does. 11 CHIP_ADMIT_BUILD = $(CC) -std=gnu11 -O2 -Wall -Wextra -Werror -D_GNU_SOURCE -DCUDAPP_NVRM_TEST_TRANSPORT=1 -Isrc $(GPU_ENGINE_PHYS_INC) 12 CHIP_ADMIT_SRCS = src/omega_gpu_chip.c src/omega_ampere_qmd.c 13 CHIP_ADMIT_OTHER_UNITS = $(filter-out src/cudapp_om_chip_admit.c,$(CUDAPP_BINDING_SRCS)) 14 CHIP_ADMIT_OM_MUTANTS = 's/eq device 11794/eq device 11795/' 's/ne shr cls 16 3/ne shr cls 16 4/' \ 15 's/eq device 9353/eq device 9354/' 's/if eq t 0/if eq t 1/' 's/if gt hit 1/if gt hit 2/' 16 CHIP_ADMIT_C_MUTANTS = 's/if (omega_gpu_chip_admit_open(bdf, rm->err, sizeof rm->err) != 0) return -1;/(void)0;/' \ 17 's/\&admitted_sm, rm->err, sizeof rm->err) != 0) return -1;/\&admitted_sm, rm->err, sizeof rm->err) != 0) (void)0;/' \ 18 's/if (rm->target_sm != admitted_sm)/if (0)/' 19 20 .PHONY: test-chip-admission test-chip-admission-mutants 21 CARRIED_HOST_TESTS += test-chip-admission 22 23 $(CHIP_ADMIT_DIR)/test_chip_admission: tests/test_chip_admission.c nvrm/nvrm.c nvrm/nvrm.h src/omega_gpu_chip.h \ 24 src/cudapp_native.h $(CHIP_ADMIT_SRCS) $(CUDAPP_BINDING_SRCS) 25 @mkdir -p $(CHIP_ADMIT_DIR) 26 $(CHIP_ADMIT_BUILD) -o $@ tests/test_chip_admission.c $(CHIP_ADMIT_SRCS) $(CUDAPP_BINDING_SRCS) 27 28 test-chip-admission: $(CHIP_ADMIT_DIR)/test_chip_admission 29 TMPDIR=$(abspath $(CHIP_ADMIT_DIR)) ./$(CHIP_ADMIT_DIR)/test_chip_admission 30 31 test-chip-admission-mutants: 32 @[ -x $(OMEGA_MV)/seed/out/omc ] && [ -f $(OMEGA_BRIDGE_DIR)/src/native.om ] || { echo "NOT_RUN: set OMEGA_MV and OMEGA_BRIDGE_DIR"; exit 3; } 33 @n=0; for m in $(CHIP_ADMIT_OM_MUTANTS); do n=$$((n+1)); d=$(CHIP_ADMIT_DIR)/mutant$$n; rm -rf $$d; mkdir -p $$d; \ 34 sed "$$m" om/admission/chip_admit.om > $$d/chip_admit.om; \ 35 if cmp -s $$d/chip_admit.om om/admission/chip_admit.om; then echo "MUTANT $$n BROKEN: '$$m' changed nothing"; exit 1; fi; \ 36 OMEGA_UNITS=$$(pwd)/$$d/chip_admit.om OMEGA_UNITS_DEST=$$d OMEGA_OMC=$(OMEGA_MV)/seed/out/omc \ 37 OMEGA_BRIDGE=$(OMEGA_BRIDGE_DIR) sh om/units.sh > /dev/null || exit 1; \ 38 $(CHIP_ADMIT_BUILD) -o $$d/test tests/test_chip_admission.c $(CHIP_ADMIT_SRCS) $(CHIP_ADMIT_OTHER_UNITS) \ 39 $$d/cudapp_om_chip_admit.c || exit 1; \ 40 if TMPDIR=$$(pwd)/$$d $$d/test > $$d/test.log 2>&1; then echo "MUTANT $$n SURVIVED: '$$m'"; exit 1; fi; \ 41 echo "mutant $$n red ('$$m'): $$(grep -m1 -e 'CHIP ADMIT DIFF' -e FAIL $$d/test.log)"; \ 42 done; \ 43 for m in $(CHIP_ADMIT_C_MUTANTS); do n=$$((n+1)); d=$(CHIP_ADMIT_DIR)/mutant$$n; rm -rf $$d; mkdir -p $$d; \ 44 sed "$$m" nvrm/nvrm.c > $$d/nvrm.c; \ 45 if cmp -s $$d/nvrm.c nvrm/nvrm.c; then echo "MUTANT $$n BROKEN: '$$m' changed nothing"; exit 1; fi; \ 46 $(CHIP_ADMIT_BUILD) "-DNVRM_C=\"$$(pwd)/$$d/nvrm.c\"" -o $$d/test tests/test_chip_admission.c $(CHIP_ADMIT_SRCS) \ 47 $(CUDAPP_BINDING_SRCS) || exit 1; \ 48 if TMPDIR=$$(pwd)/$$d $$d/test > $$d/test.log 2>&1; then echo "MUTANT $$n SURVIVED: '$$m'"; exit 1; fi; \ 49 echo "mutant $$n red ('$$m'): $$(grep -m1 -e 'CHIP ADMIT DIFF' -e FAIL $$d/test.log)"; \ 50 done; echo "chip admission mutants: $$n of $$n red" 51 52 # The runtime API version a program linked (omega_runtime_api_version, API 0.14.0), host only. hello_gpu --sim must print 53 # the manifest's MAJOR.MINOR for both the library and the program; the negative control builds hello_gpu against a header 54 # one MINOR ahead of the library, which must stop with exit 2 and its FAIL sentence before anything runs. 55 .PHONY: test-runtime-api-version 56 CARRIED_HOST_TESTS += test-runtime-api-version 57 RUNTIME_VERSION_DIR = $(OUT_DIR)/runtime-api-version 58 test-runtime-api-version: $(OUT_DIR)/hello_gpu $(OUT_DIR)/libomega_gpu.a 59 @mkdir -p $(RUNTIME_VERSION_DIR)/ahead 60 @v=$$(sed -n 's/^abi omega_runtime \([0-9]*\)\.\([0-9]*\)\.[0-9]*$$/\1.\2/p' $(RUNTIME_API_MANIFEST)); \ 61 [ -n "$$v" ] || { echo "FAIL: no abi line in $(RUNTIME_API_MANIFEST)"; exit 1; }; \ 62 nm $(OUT_DIR)/libomega_gpu.a | grep -q ' T omega_runtime_api_version$$' || { echo "FAIL: libomega_gpu.a has no omega_runtime_api_version"; exit 1; }; \ 63 ./$(OUT_DIR)/hello_gpu --sim > $(RUNTIME_VERSION_DIR)/hello.log 2>&1 || { cat $(RUNTIME_VERSION_DIR)/hello.log; exit 1; }; \ 64 grep -qx "runtime API $$v (library), program built against $$v" $(RUNTIME_VERSION_DIR)/hello.log || \ 65 { echo "FAIL: hello_gpu did not report runtime API $$v for library and program"; exit 1; }; \ 66 minor=$$(sed -n 's/^#define OMEGA_RUNTIME_API_VERSION_MINOR \([0-9]*\)$$/\1/p' src/omega_runtime_api.h); \ 67 sed "s/^#define OMEGA_RUNTIME_API_VERSION_MINOR $$minor$$/#define OMEGA_RUNTIME_API_VERSION_MINOR $$((minor+1))/" \ 68 src/omega_runtime_api.h > $(RUNTIME_VERSION_DIR)/ahead/omega_runtime_api.h; \ 69 cmp -s src/omega_runtime_api.h $(RUNTIME_VERSION_DIR)/ahead/omega_runtime_api.h && { echo "FAIL: control header unchanged"; exit 1; }; \ 70 $(CC) -I$(RUNTIME_VERSION_DIR)/ahead $(CFLAGS) -o $(RUNTIME_VERSION_DIR)/hello_ahead examples/hello_gpu/hello_gpu.c \ 71 $(OUT_DIR)/libomega_gpu.a -lpthread -lm || exit 1; \ 72 ./$(RUNTIME_VERSION_DIR)/hello_ahead --sim > $(RUNTIME_VERSION_DIR)/ahead.log 2>&1; rc=$$?; \ 73 if [ $$rc -eq 2 ] && grep -q '^FAIL: the linked CUDA++ library has runtime API ' $(RUNTIME_VERSION_DIR)/ahead.log \ 74 && ! grep -q '^kernel built' $(RUNTIME_VERSION_DIR)/ahead.log; then \ 75 echo "NEGATIVE CONTROL program one MINOR ahead of the library: RED as it must (exit 2)"; \ 76 else cat $(RUNTIME_VERSION_DIR)/ahead.log; echo "NEGATIVE CONTROL not caught (exit $$rc)"; exit 1; fi; \ 77 echo "runtime API version tests passed: library and program $$v (HOST_ONLY, --sim)"