Archived
tests: g4k_emu -- gemma4k's kernel source on the host, every GPU thread a fiber
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>
This commit is contained in:
1 parent
833173cc04
commit
846e52148a
7 files changed
+840
No files matched your search
@@ -181,6 +181,53 @@ if(TARGET libavx AND TARGET rad-avx-check)
|
||||
set_tests_properties(avx_check PROPERTIES TIMEOUT 600)
|
||||
endif()
|
||||
|
||||
# ================================================================== gemma4k's kernels, on the host
|
||||
#
|
||||
# gemma4k builds for gfx12 only, and two of its ops (the sandwich-norm joins) have no libref oracle
|
||||
# by design (docs/OPS.md), so neither rad-kbench nor a no-card machine would ever run its kernels.
|
||||
# g4k_emu runs their SOURCE on the host instead: emu/hip/hip_runtime.h supplies the HIP names, every
|
||||
# GPU thread is a fiber, __syncthreads and every cross-lane op a barrier (one not reached uniformly
|
||||
# is reported as a deadlock), and the kernels' launch macro is pointed at the emulator. Checked
|
||||
# against a port of libref's ref_attn_paged, against the host rows, and -- for the joins -- against
|
||||
# the unfused chain, bit for bit.
|
||||
#
|
||||
# CLANG AND x86-64: the kernels use clang's ext_vector_type, and the fiber switch is x86-64 SysV
|
||||
# inline assembly. Under a clang C++ compiler they are ordinary targets here, the .hip files
|
||||
# compiled as C++ (`-x c++`, which is what makes them host code; the property is per directory, so
|
||||
# gemma4k's own HIP build is untouched). Under g++ -- the docker image's -- a build with a card
|
||||
# still has a clang: its HIP compiler, ROCm's own clang++, and g4k_emu/run.sh builds and runs the
|
||||
# same tests with that. So wherever gemma4k is built, this runs.
|
||||
set(G4K_DIR ${CMAKE_SOURCE_DIR}/gemma4k)
|
||||
set(G4K_EMU ${CMAKE_CURRENT_SOURCE_DIR}/g4k_emu)
|
||||
if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64)$")
|
||||
# no fiber switch for this ISA: nothing to register
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(G4K_HIP ${G4K_DIR}/g4k_attn.hip ${G4K_DIR}/g4k_pick.hip ${G4K_DIR}/g4k_norm.hip)
|
||||
set_source_files_properties(${G4K_HIP} PROPERTIES LANGUAGE CXX COMPILE_OPTIONS "-x;c++")
|
||||
add_library(g4k_emu_kernels OBJECT ${G4K_HIP} ${G4K_DIR}/g4k_rows.cpp ${G4K_EMU}/emu/emu.cpp)
|
||||
target_include_directories(g4k_emu_kernels PUBLIC ${G4K_EMU}/emu ${G4K_DIR})
|
||||
target_link_libraries(g4k_emu_kernels PUBLIC rad_abi)
|
||||
# As libr4d compiles every unit: the joins are held to the chain bit for bit, and a contracted
|
||||
# multiply-add is a different rounding.
|
||||
target_compile_options(g4k_emu_kernels PRIVATE -ffp-contract=off -Wno-psabi)
|
||||
foreach(t attn pick norm)
|
||||
add_executable(g4k_emu_${t} ${G4K_EMU}/test_${t}.cpp)
|
||||
target_link_libraries(g4k_emu_${t} PRIVATE g4k_emu_kernels)
|
||||
target_compile_options(g4k_emu_${t} PRIVATE -ffp-contract=off -Wno-psabi)
|
||||
set_target_properties(g4k_emu_${t} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests)
|
||||
add_test(NAME g4k_emu_${t} COMMAND g4k_emu_${t})
|
||||
endforeach()
|
||||
# The random sweep at a size the inner loop can afford; `g4k_emu_attn sweep 200` is the long one.
|
||||
add_test(NAME g4k_emu_attn_sweep COMMAND g4k_emu_attn sweep 40)
|
||||
set_tests_properties(g4k_emu_attn g4k_emu_pick g4k_emu_norm g4k_emu_attn_sweep
|
||||
PROPERTIES LABELS "g4k_emu" TIMEOUT 600)
|
||||
elseif(RAD_HIP_FOUND AND CMAKE_HIP_COMPILER_ID MATCHES "Clang")
|
||||
add_test(NAME g4k_emu
|
||||
COMMAND sh ${G4K_EMU}/run.sh ${CMAKE_HIP_COMPILER} ${CMAKE_SOURCE_DIR}/abi ${G4K_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/g4k_emu 40)
|
||||
set_tests_properties(g4k_emu PROPERTIES LABELS "g4k_emu" TIMEOUT 900)
|
||||
endif()
|
||||
|
||||
# ================================================================== the document as a test
|
||||
#
|
||||
# docs/OPS.md calls its resolved table "THE AUTHORITY FOR THE OPS IN IT" and says of itself that
|
||||
|
||||
Reference in new issue
Block a user