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 / omega-gpu-code-alloc.mk

35 lines · 3035 bytes Raw Blame History
1# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2# GPU code buffer sizing (src/omega_gpu_code_alloc.h): the 2 KB instruction prefetch tail after every
3# kernel (omega#323). Host only: no device, no physics headers. Three parts: the size rule, a NO_TAIL
4# mutant that must fail it, and a source scan that refuses the page-only code sizing idioms the six
5# variable-size upload sites and five fixed-size sites used before.
6CODE_ALLOC_SCAN_SRC := $(wildcard src/*.c src/runtime/*.c)
7CODE_ALLOC_SCAN_RE := code_size \+ 0x[fF]{3}|session_alloc\([^,]*code_size|alloc[a-z_]*\([^,]*, *(0x[0-9a-fA-F]+|OMEGA_DS_MAX_CODE_BYTES), *&[a-z_>.-]*code_mem\)
8.PHONY: test-gpu-code-alloc test-gpu-code-alloc-scan
9build/test_omega_gpu_code_alloc: tests/test_omega_gpu_code_alloc.c src/omega_gpu_code_alloc.h src/omega_bw_policy.h src/cudapp_freest_bw_scalar.c
10 @mkdir -p build
11 gcc -std=gnu11 -O2 -Wall -Wextra -Werror -Isrc -o $@ tests/test_omega_gpu_code_alloc.c src/cudapp_freest_bw_scalar.c
12test-gpu-code-alloc: build/test_omega_gpu_code_alloc
13 ./build/test_omega_gpu_code_alloc
14 @gcc -std=gnu11 -O2 -Wall -Wextra -Werror -DOMEGA_GPU_CODE_ALLOC_MUTANT_NO_TAIL -Isrc -o build/test_omega_gpu_code_alloc_no_tail tests/test_omega_gpu_code_alloc.c src/cudapp_freest_bw_scalar.c
15 @if ./build/test_omega_gpu_code_alloc_no_tail >build/test_omega_gpu_code_alloc_no_tail.log 2>&1; then echo "MUTANT SURVIVED: NO_TAIL"; exit 1; fi
16 @echo "NO_TAIL mutant: killed ($$(grep -c '^FAIL:' build/test_omega_gpu_code_alloc_no_tail.log) failing checks)"
17 @$(MAKE) --no-print-directory test-gpu-code-alloc-scan
18 @if $(MAKE) --no-print-directory test-gpu-code-alloc-scan CODE_ALLOC_SCAN_SRC=build/code-alloc-missing-input.c >build/code-alloc-missing.log 2>&1; then echo "source scan accepted a missing input"; exit 1; fi
19 @grep -q '^source scan failed (grep exit 2)' build/code-alloc-missing.log
20 @if $(MAKE) --no-print-directory test-gpu-code-alloc-scan CODE_ALLOC_SCAN_SRC= >build/code-alloc-empty.log 2>&1; then echo "source scan accepted an empty readset"; exit 1; fi
21 @grep -q '^source scan has no inputs' build/code-alloc-empty.log
22 @printf '%s\n' 'code_size + 0xfff' >build/code-alloc-forbidden.c
23 @if $(MAKE) --no-print-directory test-gpu-code-alloc-scan CODE_ALLOC_SCAN_SRC=build/code-alloc-forbidden.c >build/code-alloc-forbidden.log 2>&1; then echo "source scan accepted forbidden sizing"; exit 1; fi
24 @grep -q '^code buffer sized without the prefetch tail' build/code-alloc-forbidden.log
25 @echo "OMEGA_GPU_CODE_ALLOC_GATE PASS"
26
27# grep: 0 is a forbidden match, 1 is a clean scan, every other status is a scan failure.
28test-gpu-code-alloc-scan:
29 @test -n "$(strip $(CODE_ALLOC_SCAN_SRC))" || { echo "source scan has no inputs"; exit 2; }
30 @rc=0; grep -nE '$(CODE_ALLOC_SCAN_RE)' $(CODE_ALLOC_SCAN_SRC) || rc=$$?; \
31 case $$rc in \
32 1) echo "source scan: no page-only code sizing" ;; \
33 0) echo "code buffer sized without the prefetch tail (use omega_gpu_code_alloc_bytes)"; exit 1 ;; \
34 *) echo "source scan failed (grep exit $$rc)"; exit 2 ;; \
35 esac