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
| 1 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | # Include from Makefile. Hosted .om packer, no GPU; regenerate the checked |
| 3 | # portable TUs with om/units.sh after changing om/cubin/cubin_elf.om. |
| 4 | AMPERE_CUBIN_DIR = $(OUT_DIR)/ampere-cubin |
| 5 | AMPERE_NVDISASM ?= /usr/local/cuda/bin/nvdisasm |
| 6 | AMPERE_CUBIN_SOURCES = tests/ampere_cubin_test.c src/omega_cubin.c $(CUDAPP_BINDING_SRCS) |
| 7 | AMPERE_CUBIN_DEPS = $(AMPERE_CUBIN_SOURCES) src/omega_cubin.h src/cudapp_native.h |
| 8 | |
| 9 | .PHONY: test-ampere-cubin test-ampere-cubin-disasm test-om-ampere-elf-admission |
| 10 | $(AMPERE_CUBIN_DIR)/host: $(AMPERE_CUBIN_DEPS) |
| 11 | @mkdir -p $(AMPERE_CUBIN_DIR) |
| 12 | $(CC) $(CFLAGS) -Isrc -pthread -o $@ $(AMPERE_CUBIN_SOURCES) |
| 13 | |
| 14 | $(AMPERE_CUBIN_DIR)/diff: $(AMPERE_CUBIN_DEPS) |
| 15 | @mkdir -p $(AMPERE_CUBIN_DIR) |
| 16 | $(CC) $(CFLAGS) -Isrc -pthread -DCUDAPP_MIGRATION_PENDING_CUBIN_DIFF -o $@ $(AMPERE_CUBIN_SOURCES) |
| 17 | |
| 18 | test-ampere-cubin: $(AMPERE_CUBIN_DIR)/host $(AMPERE_CUBIN_DIR)/diff |
| 19 | $(AMPERE_CUBIN_DIR)/host $(AMPERE_CUBIN_DIR)/sm86.cubin |
| 20 | $(AMPERE_CUBIN_DIR)/diff |
| 21 | |
| 22 | test-ampere-cubin-disasm: test-ampere-cubin |
| 23 | @test -x "$(AMPERE_NVDISASM)" || { echo 'NOT_RUN: missing offline nvdisasm'; exit 3; } |
| 24 | "$(AMPERE_NVDISASM)" -c $(AMPERE_CUBIN_DIR)/sm86.cubin > $(AMPERE_CUBIN_DIR)/sm86.sass |
| 25 | @grep -q 'EXIT' $(AMPERE_CUBIN_DIR)/sm86.sass || { echo 'FAIL: sm86 EXIT not decoded'; exit 1; } |
| 26 | @echo 'AMPERE CUBIN NVDISASM PASS; device NOT_RUN' |
| 27 | |
| 28 | # tests/cubin_elf_admission.om, composed after om/components/artifact_elf.om, runs the existing ELF admission unit on |
| 29 | # the image test-ampere-cubin writes: original accepted, wrong text section size and truncated ELF refused inside the |
| 30 | # program; a 200-byte prefix of the image must be refused as a file (exit 7). A prerequisite of test-om-cubin-mutants. |
| 31 | test-om-ampere-elf-admission: test-ampere-cubin om/components/artifact_elf.om tests/cubin_elf_admission.om |
| 32 | @[ -x $(OMEGA_MV)/seed/out/omc ] || { echo "NOT_RUN: set OMEGA_MV"; exit 3; } |
| 33 | cat om/components/artifact_elf.om tests/cubin_elf_admission.om | $(OMEGA_MV)/seed/out/omc > $(AMPERE_CUBIN_DIR)/elf-admission |
| 34 | chmod +x $(AMPERE_CUBIN_DIR)/elf-admission |
| 35 | $(AMPERE_CUBIN_DIR)/elf-admission $(AMPERE_CUBIN_DIR)/sm86.cubin |
| 36 | head -c 200 $(AMPERE_CUBIN_DIR)/sm86.cubin > $(AMPERE_CUBIN_DIR)/sm86-trunc.cubin |
| 37 | @rc=0; $(AMPERE_CUBIN_DIR)/elf-admission $(AMPERE_CUBIN_DIR)/sm86-trunc.cubin > /dev/null || rc=$$?; \ |
| 38 | if [ $$rc != 7 ]; then echo "RED CHECK BROKEN: truncated image exited $$rc, not 7"; exit 1; fi; \ |
| 39 | echo "red check: a 200-byte image prefix exits 7, as it must" |
| 40 | |
| 41 | # Numeric defaults to the scalar, tile and remainder units in om/numeric/. |
| 42 | # c selects both default-OFF C oracle flags; diff checks the preserved scalar |
| 43 | # wrappers. test-numeric-rest-om-diff separately compares remainder algorithms. |
| 44 | CUDAPP_NUMERIC ?= om |
| 45 | CUDAPP_NUMERIC_DEFS_om := |
| 46 | CUDAPP_NUMERIC_DEFS_c := -DCUDAPP_MIGRATION_PENDING_C_NUMERIC -DCUDAPP_MIGRATION_PENDING_C_NUMERIC_REST |
| 47 | CUDAPP_NUMERIC_DEFS_diff := -DCUDAPP_MIGRATION_PENDING_C_NUMERIC_DIFF |
| 48 | CUDAPP_NUMERIC_DEFS = $(CUDAPP_NUMERIC_DEFS_$(CUDAPP_NUMERIC)) |
| 49 | ifeq ($(filter om c diff,$(CUDAPP_NUMERIC)),) |
| 50 | $(error CUDAPP_NUMERIC must be om, c or diff) |
| 51 | endif |
| 52 | NUMERIC_SRCS := src/omega_numeric.c src/omega_numeric_reduce.c src/cudapp_om_numeric.c src/cudapp_om_numeric_tile.c src/cudapp_om_numeric_rest.c src/cudapp_om_numeric_patch.c src/cudapp_om_numeric_check.c src/cudapp_om_numeric_trace.c src/cudapp_om_numeric_reduce.c |
| 53 | NUMERIC_DEPS := src/omega_numeric.h src/omega_numeric_reduce.h src/omega_numeric_om.h src/cudapp_native.h src/omega_numeric_rest.inc src/omega_numeric_reduce_rest.inc |
| 54 | |
| 55 | # Independently runnable on a native x86 host before the bridge prerequisite. |
| 56 | .PHONY: test-ampere-numeric-host |
| 57 | $(AMPERE_CUBIN_DIR)/numeric-host: tests/ampere_numeric_host_test.c $(NUMERIC_SRCS) $(NUMERIC_DEPS) src/cudapp_freest_leftovers.c |
| 58 | @mkdir -p $(AMPERE_CUBIN_DIR) |
| 59 | $(CC) $(CFLAGS) -Isrc -ffp-contract=off -ffunction-sections -fdata-sections -Wl,--gc-sections $(CUDAPP_NUMERIC_DEFS) -o $@ tests/ampere_numeric_host_test.c $(NUMERIC_SRCS) src/cudapp_freest_leftovers.c -lm |
| 60 | |
| 61 | test-ampere-numeric-host: $(AMPERE_CUBIN_DIR)/numeric-host |
| 62 | $(AMPERE_CUBIN_DIR)/numeric-host |
| 63 | |
| 64 | # The native floating cast is an independent verification oracle only. |
| 65 | .PHONY: test-ampere-f16-host |
| 66 | $(AMPERE_CUBIN_DIR)/f16-host: tests/ampere/test_f16_behavior.c src/cudapp_freest_f16.c |
| 67 | @mkdir -p $(AMPERE_CUBIN_DIR) |
| 68 | $(CC) $(CFLAGS) -O3 -o $@ tests/ampere/test_f16_behavior.c src/cudapp_freest_f16.c |
| 69 | |
| 70 | test-ampere-f16-host: $(AMPERE_CUBIN_DIR)/f16-host |
| 71 | $(AMPERE_CUBIN_DIR)/f16-host |