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 / mk / runtime-r2.mk

31 lines · 2098 bytes Raw Blame History
1# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2# R2 (omega-mv#595): "Hello GPU" from a fresh checkout. `make hello-gpu` builds examples/hello_gpu and runs it.
3# Picked up by the `-include mk/*.mk` line at the top of the Makefile. The driver client is in this
4# repository (nvrm/, m16/), so nothing is fetched.
5HELLO_GPU = $(OUT_DIR)/hello_gpu
6
7.PHONY: hello-gpu hello-gpu-build hello-gpu-control
8$(HELLO_GPU): examples/hello_gpu/hello_gpu.c $(OUT_DIR)/libomega_gpu.a
9 $(CC) $(CFLAGS) -o $@ examples/hello_gpu/hello_gpu.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
10
11hello-gpu-build: $(HELLO_GPU)
12
13hello-gpu: hello-gpu-build $(DOCTOR)
14 $(DOCTOR)
15 ./$(HELLO_GPU)
16
17# The negative control for hello-gpu on the chip: `hello_gpu_control --bug=short` tells the last launch one element
18# too few (nothing is written outside a buffer). The check must catch the one unwritten answer: exit 1 and FAIL.
19# This target passes only when it does; a PASS from the broken run would mean the check checks nothing.
20# MIGRATION-PENDING C: --bug=short exists only in this separate binary, built with the switch
21# CUDAPP_MIGRATION_PENDING_HELLO_CONTROL=1; the switch is OFF for build/hello_gpu and every other build.
22# .om successor: the native .om hello of aien-dev/CUDApp#79 (OM-GPU-RETIRE).
23HELLO_GPU_CONTROL = $(OUT_DIR)/hello_gpu_control
24$(HELLO_GPU_CONTROL): examples/hello_gpu/hello_gpu.c $(OUT_DIR)/libomega_gpu.a
25 $(CC) $(CFLAGS) -DCUDAPP_MIGRATION_PENDING_HELLO_CONTROL=1 -o $@ examples/hello_gpu/hello_gpu.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm
26
27hello-gpu-control: $(HELLO_GPU_CONTROL)
28 @./$(HELLO_GPU_CONTROL) --bug=short > $(OUT_DIR)/hello_gpu_control.log 2>&1; rc=$$?; cat $(OUT_DIR)/hello_gpu_control.log; \
29 if [ $$rc -eq 1 ] && grep -q '^checked 1048576 of 1048576 elements: 1 wrong, 1 never written$$' $(OUT_DIR)/hello_gpu_control.log \
30 && grep -qx FAIL $(OUT_DIR)/hello_gpu_control.log; then echo "NEGATIVE CONTROL hello-gpu --bug=short: RED as it must (exit 1, the one unwritten answer caught)"; \
31 else echo "NEGATIVE CONTROL hello-gpu --bug=short: NOT CAUGHT (exit $$rc)"; exit 1; fi