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 | # C4 streams (CUDApp#115): the method words of a cmdlist submission (setup, wait_for ACQUIRE, barrier choice, stamps, |
| 3 | # PCAS or inline QMD headers, completion tail), the submit_pair marker layout, AIEN_OMEGA_GPU_CHANNELS and the extra |
| 4 | # queue admission come from seeded Omega, om/streams/streams.om, through the generated src/cudapp_om_streams.c. |
| 5 | # The C rules are migration-pending oracles (CUDAPP_MIGRATION_PENDING_C_STREAMS, CUDAPP_MIGRATION_PENDING_STREAMS_DIFF). |
| 6 | # make test-om-streams (in `make test`, no Omega tools needed) |
| 7 | # 1. gpu_streams_test --host-only / --sim and gpu_isolation_test --host-only on the Omega path (the CI tiers); |
| 8 | # 2. tests/streams_diff_test.c built with CUDAPP_MIGRATION_PENDING_STREAMS_DIFF (the host and sim tiers never |
| 9 | # submit a cmdlist, so a sweep drives emit_chunk): every chunk configuration, both pair markers, channel |
| 10 | # values and extra queue indexes are computed both ways and abort on any difference; only SAME log lines; |
| 11 | # 3. red check: the diff build with one flipped Omega word must abort. |
| 12 | # make test-om-streams-mutants mutant streams.om units, each compiled by the pinned omc, must turn the diff red |
| 13 | # (needs OMEGA_MV and OMEGA_BRIDGE_DIR as in mk/om-encoder.mk; without them exit 3, NOT_RUN, never PASS). |
| 14 | OM_STREAMS_DIR = $(OUT_DIR)/om-streams |
| 15 | OM_STREAMS_DIFF = -DCUDAPP_MIGRATION_PENDING_STREAMS_DIFF |
| 16 | OM_STREAMS_SRCS = src/omega_gpu_cmdlist.c src/omega_gpu_session.c src/omega_gpu_platform_linux.c |
| 17 | OM_STREAMS_HDRS = src/omega_gpu_cmdlist.h src/omega_gpu_session.h src/cudapp_native.h tests/bw_warp_sim.h src/omega_bw_em.h |
| 18 | # $(1) output, $(2) test source, $(3) extra flags, $(4) binding source: the diff-built streams sources go ahead of the |
| 19 | # archive, so its own copies of those objects are never pulled in. |
| 20 | om_streams_link = $(CC) $(CFLAGS) $(OM_STREAMS_DIFF) $(3) -ffp-contract=off -Itests -o $(1) $(2) $(OM_STREAMS_SRCS) $(4) \ |
| 21 | $(OUT_DIR)/libomega_gpu.a -lpthread -lm |
| 22 | |
| 23 | .PHONY: test-om-streams test-om-streams-mutants |
| 24 | $(OM_STREAMS_DIR)/streams_diff: tests/streams_diff_test.c $(OM_STREAMS_SRCS) $(OM_STREAMS_HDRS) src/cudapp_om_streams.c $(OUT_DIR)/libomega_gpu.a |
| 25 | @mkdir -p $(OM_STREAMS_DIR) |
| 26 | $(call om_streams_link,$@,tests/streams_diff_test.c,,) |
| 27 | $(OM_STREAMS_DIR)/streams_diff_red: tests/streams_diff_test.c $(OM_STREAMS_SRCS) $(OM_STREAMS_HDRS) src/cudapp_om_streams.c $(OUT_DIR)/libomega_gpu.a |
| 28 | @mkdir -p $(OM_STREAMS_DIR) |
| 29 | $(call om_streams_link,$@,tests/streams_diff_test.c,-DCUDAPP_STREAMS_DIFF_SELFTEST,) |
| 30 | |
| 31 | test-om-streams: $(GPU_STREAMS_TEST) $(GPU_ISOLATION_TEST) $(OM_STREAMS_DIR)/streams_diff $(OM_STREAMS_DIR)/streams_diff_red |
| 32 | ./$(GPU_STREAMS_TEST) --host-only |
| 33 | ./$(GPU_STREAMS_TEST) --sim |
| 34 | ./$(GPU_ISOLATION_TEST) --host-only |
| 35 | @rm -f $(OM_STREAMS_DIR)/diff.log |
| 36 | CUDAPP_STREAMS_DIFF_LOG=$(OM_STREAMS_DIR)/diff.log ./$(OM_STREAMS_DIR)/streams_diff |
| 37 | @other=$$(grep -vc '^SAME ' $(OM_STREAMS_DIR)/diff.log || true); \ |
| 38 | if [ "$$other" -ne 0 ]; then echo "FAIL streams diff: $$other non-SAME lines"; exit 1; fi; \ |
| 39 | echo "streams diff: Omega and C identical on $$(grep -c '^SAME chunk' $(OM_STREAMS_DIR)/diff.log) chunks ($$(grep '^SAME chunk' $(OM_STREAMS_DIR)/diff.log | sed 's/.*words=//' | awk '{s+=$$1} END {print s}') words), $$(grep -c '^SAME pair' $(OM_STREAMS_DIR)/diff.log) pair markers" |
| 40 | @if ./$(OM_STREAMS_DIR)/streams_diff_red > /dev/null 2>&1; then \ |
| 41 | echo "RED CHECK BROKEN: a flipped Omega word passed the streams diff"; exit 1; \ |
| 42 | else echo "red check: one flipped Omega word aborts the streams diff, as it must"; fi |
| 43 | |
| 44 | # Each mutant is one edit of streams.om (1-4) or xq.om (5-7), compiled by the pinned omc into its own binding; the diff |
| 45 | # build linked with it must abort. 1 ACQUIRE method offset, 2 ACQUIRE payload, 3 completion marker payload, 4 pair |
| 46 | # marker stride, 5 extra-queue index bound, 6 queue 2 order check, 7 queue 3 order check. |
| 47 | OM_STREAMS_MUTANTS = 's/^k = pw o 0 mthd 0 92 5$$/k = pw o 0 mthd 0 96 5/' \ |
| 48 | 's/^const DONE ulong 6$$/const DONE ulong 7/' \ |
| 49 | 's/^const MARKER1 ulong 1145324612$$/const MARKER1 ulong 1145324613/' \ |
| 50 | 's/^ret add add get a 0 256 mul k 128$$/ret add add get a 0 256 mul k 64/' |
| 51 | OM_STREAMS_XQ_MUTANTS = 's/^if or eq i 0 gt i 3$$/if or eq i 0 gt i 2/' \ |
| 52 | 's/^if eq q1 0$$/if ne q1 0/' \ |
| 53 | 's/^if or eq q1 0 eq q2 0$$/if eq q1 0/' |
| 54 | test-om-streams-mutants: $(OUT_DIR)/libomega_gpu.a |
| 55 | @[ -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; } |
| 56 | @n=0; for m in $(OM_STREAMS_MUTANTS); do n=$$((n+1)); d=$(OM_STREAMS_DIR)/mutant$$n; rm -rf $$d; mkdir -p $$d; \ |
| 57 | sed "$$m" om/streams/streams.om > $$d/streams.om; \ |
| 58 | if cmp -s $$d/streams.om om/streams/streams.om; then echo "MUTANT $$n BROKEN: '$$m' changed nothing"; exit 1; fi; \ |
| 59 | OMEGA_UNITS=$$(pwd)/$$d/streams.om OMEGA_UNITS_DEST=$$d OMEGA_OMC=$(OMEGA_MV)/seed/out/omc \ |
| 60 | OMEGA_BRIDGE=$(OMEGA_BRIDGE_DIR) sh om/units.sh > /dev/null || exit 1; \ |
| 61 | $(call om_streams_link,$$d/streams,tests/streams_diff_test.c,,$$d/cudapp_om_streams.c) || exit 1; \ |
| 62 | if $$d/streams > $$d/streams.log 2>&1; then echo "MUTANT $$n SURVIVED: '$$m'"; exit 1; fi; \ |
| 63 | echo "mutant $$n red ('$$m'): $$(grep -m1 -e 'streams diff' -e FAIL $$d/streams.log)"; \ |
| 64 | done; \ |
| 65 | for m in $(OM_STREAMS_XQ_MUTANTS); do n=$$((n+1)); d=$(OM_STREAMS_DIR)/mutant$$n; rm -rf $$d; mkdir -p $$d; \ |
| 66 | sed "$$m" om/streams/xq.om > $$d/xq.om; \ |
| 67 | if cmp -s $$d/xq.om om/streams/xq.om; then echo "MUTANT $$n BROKEN: '$$m' changed nothing"; exit 1; fi; \ |
| 68 | OMEGA_SEEDED_OMC=$(OMEGA_MV)/seed/out/omc sh $(OMEGA_BRIDGE_DIR)/tools/bridge-freest c $$d/xq.om \ |
| 69 | > $$d/cudapp_freest_streams_xq.c || exit 1; \ |
| 70 | $(call om_streams_link,$$d/streams,tests/streams_diff_test.c,,$$d/cudapp_freest_streams_xq.c) || exit 1; \ |
| 71 | if $$d/streams > $$d/streams.log 2>&1; then echo "MUTANT $$n SURVIVED: '$$m'"; exit 1; fi; \ |
| 72 | echo "mutant $$n red ('$$m'): $$(grep -m1 -e 'streams diff' -e FAIL $$d/streams.log)"; \ |
| 73 | done |