Archived
gemma4k builds for gfx12 only and its two joins have no libref oracle, so nothing on a machine without the card, and nothing in rad-kbench, would ever run its kernels. g4k_emu compiles the .hip sources as host C++ against a HIP shim: every GPU thread a fiber, __syncthreads and every cross-lane op a barrier (one not reached uniformly is reported as a deadlock), the WMMA operand layouts gfx12's. Checked against a port of libref's ref_attn_paged (attention, fixed cases and a random sweep over every compiled geometry), against the host rows (pair_argmax), and against the unfused chain bit for bit (the joins). Registered in CTest under the label g4k_emu, on x86-64 with a clang: the kernels use ext_vector_type and the fiber switch is SysV inline assembly. Under a clang C++ compiler they are ordinary targets. The docker image compiles host C++ with g++, so there g4k_emu/run.sh builds the same tests with the HIP compiler, ROCm's own clang++, and runs them as one test -- so wherever gemma4k is built, this runs, the image's host-test stage included. About 40 s at the default 40-case sweep (50 s through run.sh, which compiles too); `g4k_emu_attn sweep 200` is the long run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
26 lines
1.1 KiB
Bash
26 lines
1.1 KiB
Bash
#!/bin/sh
|
|
# tests/g4k_emu/run.sh -- build and run g4k_emu with a clang that is not the build's C++ compiler.
|
|
#
|
|
# A build whose C++ compiler is clang builds these as ordinary targets (tests/CMakeLists.txt). The
|
|
# docker image compiles host C++ with g++, which has no ext_vector_type; its HIP compiler is ROCm's
|
|
# own clang++, and with `-x c++` that compiles the kernel sources as the host code this test needs.
|
|
#
|
|
# run.sh <clang++> <abi dir> <gemma4k dir> <work dir> [sweep cases]
|
|
set -e
|
|
CXX=${1:?usage: run.sh <clang++> <abi dir> <gemma4k dir> <work dir> [sweep cases]}
|
|
ABI=$2; G=$3; B=$4; N=${5:-40}
|
|
HERE=$(cd "$(dirname "$0")" && pwd)
|
|
mkdir -p "$B"
|
|
F="-std=c++20 -O2 -ffp-contract=off -Wno-psabi -I$HERE/emu -I$ABI -I$G"
|
|
for u in attn pick norm; do $CXX $F -x c++ -c "$G/g4k_$u.hip" -o "$B/k_$u.o"; done
|
|
$CXX $F -c "$G/g4k_rows.cpp" -o "$B/rows.o"
|
|
$CXX $F -c "$HERE/emu/emu.cpp" -o "$B/emu.o"
|
|
for t in attn pick norm; do
|
|
$CXX $F -c "$HERE/test_$t.cpp" -o "$B/test_$t.o"
|
|
$CXX "$B/test_$t.o" "$B/k_attn.o" "$B/k_pick.o" "$B/k_norm.o" "$B/rows.o" "$B/emu.o" -o "$B/test_$t"
|
|
done
|
|
"$B/test_attn"
|
|
"$B/test_attn" sweep "$N"
|
|
"$B/test_pick"
|
|
"$B/test_norm"
|