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 / tools / artifact_export_shapes.sh

38 lines · 1797 bytes Raw Blame History
1#!/bin/sh
2# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3# Shape checks for `artifact-export matmul` against the matmul-bf16-v1 bounds. Opens no device.
4# K = 16 uses the single-tile kernel, whose CTA computes one 16 x 8 tile: grid must be (n/8, m/16).
5# K > 16 uses the looped kernel, whose CTA x walks column tiles x, x + grid_x, ...: 1 <= grid_x <= n/8.
6# Shapes off the 16 x 8 x 16 tiling are refused (exit 3).
7# usage: artifact_export_shapes.sh EXPORTER OUTDIR
8set -eu
9exp=$1 out=$2
10rm -rf "$out"; mkdir -p "$out"
11cm=647116fc1ba1e1394982fc8ba181ce565293f160a6b56afc0f02b2128a675704
12commit=0000000000000000000000000000000000000000
13fail=0
14grid() { sed -n 's/^grid=//p' "$out/mm_$1.manifest"; }
15for s in 16x16x8 32x16x64 64x2048x512 16x32x8 8192x16384x8192; do
16 IFS=x read -r m k n <<EOF
17$s
18EOF
19 if ! "$exp" matmul --m "$m" --k "$k" --n "$n" --contract-id $cm --out "$out/mm_$s" --commit $commit >/dev/null; then
20 echo "FAIL: in-contract matmul $s refused"; fail=1; continue
21 fi
22 g=$(grid "$s"); gx=${g%%,*}; rest=${g#*,}; gy=${rest%%,*}
23 [ "$gy" = $((m / 16)) ] || { echo "FAIL: $s grid_y $gy != m/16"; fail=1; }
24 if [ "$k" = 16 ]; then
25 [ "$gx" = $((n / 8)) ] || { echo "FAIL: $s single-tile grid_x $gx != n/8 (columns left unwritten)"; fail=1; }
26 elif [ "$gx" -lt 1 ] || [ "$gx" -gt $((n / 8)) ]; then
27 echo "FAIL: $s looped grid_x $gx outside 1..n/8"; fail=1
28 fi
29done
30for s in 16x24x8 24x16x8 16x16x12; do
31 IFS=x read -r m k n <<EOF
32$s
33EOF
34 rc=0; "$exp" matmul --m "$m" --k "$k" --n "$n" --contract-id $cm --out "$out/bad_$s" --commit $commit >/dev/null 2>&1 || rc=$?
35 [ "$rc" = 3 ] || { echo "FAIL: off-tiling matmul $s exit $rc, want 3"; fail=1; }
36done
37[ $fail -eq 0 ] && echo "ARTIFACT EXPORT SHAPES PASS"
38exit $fail