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/tests/dx/hello_sim_test.sh # 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 / tests / dx / hello_sim_test.sh` 73 lines · 4401 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 # Host test for developer bar rows D3, D4, D7, D10 and D12 (docs/PAIN_POINTS.md), on hello_gpu --sim. 4 # usage: tests/dx/hello_sim_test.sh build/hello_gpu [build/hello_gpu_control] 5 # No GPU: --sim runs the same kernel program on the host warp simulator (tests/bw_warp_sim.h). 6 # D4 --sim checks all `1048576` answers bit for bit and passes 7 # D3 --sim --bug=past-end (the host passes n+1 on the last launch, a classic off-by-one) fails 8 # AT that launch and names the kernel, launch, instruction, block, thread, address, the buffer 9 # and how far past its end, and the next command 10 # D7 two runs print the same output hash 11 # D10 two runs print the same machine-code hash, and the build time is printed 12 # D12 the work line gives the exact bytes moved and the floor time at the measured ceiling 13 set -u 14 H=${1:?usage: hello_sim_test.sh path/to/hello_gpu [path/to/hello_gpu_control]} 15 HC=${2:-} 16 pass=0; fail=0 17 want() { # name, text, pattern... 18 n=$1; t=$2; shift 2; ok=1 19 for p in "$@"; do printf '%s\n' "$t" | grep -qF -- "$p" || { echo " missing: $p"; ok=0; }; done 20 if [ $ok -eq 1 ]; then pass=$((pass+1)); echo "PASS $n"; else fail=$((fail+1)); echo "FAIL $n"; printf '%s\n' "$t" | sed 's/^/ | /'; fi 21 } 22 exitis() { # name, got, want 23 if [ "$2" -eq "$3" ]; then pass=$((pass+1)); echo "PASS $1 (exit $2)"; else fail=$((fail+1)); echo "FAIL $1: exit $2, want $3"; fi 24 } 25 26 out1=$("$H" --sim 2>&1); rc1=$? 27 exitis sim-pass "$rc1" 0 28 want sim-checks "$out1" \ 29 'on the host simulator (no GPU)' \ 30 'checked `1048576` of `1048576` elements: 0 wrong, 0 never written' \ 31 'PASS' 32 want work-line "$out1" \ 33 'work: `12582912` bytes moved (`8388608` read, `4194304` written), `1048576` floating-point operations' \ 34 'at the GB10'"'"'s measured 195.1 GB/s read ceiling this needs at least 64.5 us' 35 want hashes-printed "$out1" 'output sha256 ' 'machine code sha256 ' 'kernel built in ' 36 out2=$("$H" --sim 2>&1) 37 h1=$(printf '%s\n' "$out1" | grep -E 'output sha256|machine code sha256'); h2=$(printf '%s\n' "$out2" | grep -E 'output sha256|machine code sha256') 38 if [ -n "$h1" ] && [ "$h1" = "$h2" ]; then pass=$((pass+1)); echo "PASS same-bits-twice"; else fail=$((fail+1)); echo "FAIL same-bits-twice"; echo " run1: $h1"; echo " run2: $h2"; fi 39 printf '%s\n' "$out1" | grep -q FAULT && { fail=$((fail+1)); echo "FAIL clean run printed FAULT"; } 40 41 bad=$("$H" --sim --bug=past-end 2>&1); rcb=$? 42 exitis fault-exit "$rcb" 1 43 want fault-report "$bad" \ 44 'FAULT at launch 8 of 8 of kernel vecadd (simulator): global load outside every buffer' \ 45 'instruction: ' 'LDG.E (4-byte load)' \ 46 'thread: block 1024, thread 0 (element `1048576` of the whole job)' \ 47 'address: 0x' '0 bytes past the end of buffer a = [' \ 48 'next: ' 49 printf '%s\n' "$bad" | grep -q 'checked `1048576`' && { fail=$((fail+1)); echo "FAIL fault run went on past the faulting launch"; } 50 # The address line must name the real end of a: parse "a = [lo, hi)" and the faulting address. 51 lo_hi=$(printf '%s\n' "$bad" | sed -n 's/.*buffer a = \[\(0x[0-9a-f]*\), \(0x[0-9a-f]*\)).*/\1 \2/p') 52 addr=$(printf '%s\n' "$bad" | sed -n 's/^ *address: \(0x[0-9a-f]*\).*/\1/p') 53 set -- $lo_hi 54 if [ -n "$addr" ] && [ $# -eq 2 ] && [ $(( addr )) -eq $(( $2 )) ] && [ $(( $2 - $1 )) -eq `4194304` ]; then pass=$((pass+1)); echo "PASS fault-address-is-end-of-a" 55 else fail=$((fail+1)); echo "FAIL fault-address-is-end-of-a (addr=$addr range=$lo_hi)"; fi 56 57 # --bug=short (the check's own negative control, also used on the GPU by `make hello-gpu-control`): the last 58 # launch is told one element too few, so exactly one answer is never written and the check must go red. It is 59 # migration-pending C that exists only in hello_gpu_control (switch CUDAPP_MIGRATION_PENDING_HELLO_CONTROL=1); 60 # the default hello_gpu must not know the flag. 61 "$H" --sim --bug=short > /dev/null 2>&1; rco=$? 62 exitis short-absent-from-default-build "$rco" 2 63 if [ -n "$HC" ]; then 64 short=$("$HC" --sim --bug=short 2>&1); rcs=$? 65 exitis short-exit "$rcs" 1 66 want short-report "$short" 'checked `1048576` of `1048576` elements: 1 wrong, 1 never written' 'first mismatch: c[`1048575`]' 'FAIL' 67 printf '%s\n' "$short" | grep -qx PASS && { fail=$((fail+1)); echo "FAIL short run printed PASS"; } 68 fi 69 "$H" --bug=past-end > /dev/null 2>&1; rcu=$? 70 exitis past-end-refused-on-gpu "$rcu" 2 71 72 echo "hello --sim tests: $pass passed, $fail failed" 73 [ "$fail" -eq 0 ]