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
CUDApp / tools / gemm_ex_bench.sh
| 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | # gemm_ex_bench.sh OMEGA_BIN C_BIN OUT_DIR: the host-path cost of omega_gpu_gemm_ex on the Omega path against the C |
| 4 | # oracle (CUDApp#144). Each binary runs `--bench` (tests/gpu_gemm_ex_test.c: every edge and sweep case plus the fp8 |
| 5 | # block-rows shapes, a null core, 5 timed calls per case, median/min/max ns) on one core; the lines are joined by case |
| 6 | # id. Prints one line per case "ratio <omega/c median> <id> <omega med> <c med> <name>" into OUT_DIR/ratio.txt, and a |
| 7 | # summary: cases, sum of medians each side, the ratio of the sums, the worst case, the cases above 2x. Pinning |
| 8 | # (taskset/nice) is the caller's. Exit 1 when the two runs disagree on the case list or a return code. |
| 9 | set -eu |
| 10 | o=$1 c=$2 d=$3 |
| 11 | mkdir -p "$d" |
| 12 | "$o" --bench > "$d/omega.txt" |
| 13 | "$c" --bench > "$d/c.txt" |
| 14 | awk -v out="$d/ratio.txt" ' |
| 15 | FNR == NR { if ($1 == "bench") { orc[$2] = $3; om[$2] = $4; omin[$2] = $5; omax[$2] = $6 } next } |
| 16 | $1 == "bench" { |
| 17 | id = $2; n++ |
| 18 | if (!(id in om)) { print "FAIL gemm_ex bench: case " id " only in the C run"; bad = 1; next } |
| 19 | if (orc[id] != $3) { print "FAIL gemm_ex bench: case " id " rc omega " orc[id] " c " $3; bad = 1 } |
| 20 | name = $0; sub(/^bench [^ ]+ [^ ]+ [^ ]+ [^ ]+ [^ ]+ /, "", name) |
| 21 | r = $4 > 0 ? om[id] / $4 : 0 |
| 22 | printf "ratio %.3f %s %d %d %s\n", r, id, om[id], $4, name > out |
| 23 | so += om[id]; sc += $4 |
| 24 | if (r > worst) { worst = r; wid = id; wname = name } |
| 25 | if (r > 2) over++ |
| 26 | seen[id] = 1 |
| 27 | } |
| 28 | END { |
| 29 | for (id in om) if (!(id in seen)) { print "FAIL gemm_ex bench: case " id " only in the Omega run"; bad = 1 } |
| 30 | printf "gemm_ex bench: %d cases, sum of medians omega %.3f ms, c %.3f ms, ratio %.3f; worst %.3f (%s %s); %d cases above 2x\n", |
| 31 | n, so / 1e6, sc / 1e6, (sc > 0 ? so / sc : 0), worst, wid, wname, over |
| 32 | exit bad |
| 33 | }' "$d/omega.txt" "$d/c.txt" |