Files
geramyloveless cdb75b6ff4 Pin llama.cpp b11379 and build its Vulkan backend for RADV
llama.cpp is the first application of the Vulkan path. third_party/llama.cpp
pins b11379 as an optional, unpatched upstream (sparse, update = none);
scripts/bootstrap.sh --llama-only fetches it and verify-upstream.py checks
it once checked out.

scripts/build-llama-vulkan.sh (make llama-vulkan) builds it with
GGML_VULKAN against the Vulkan loader (Homebrew's or the LunarG SDK's),
Metal, BLAS and libcurl off, into build/llama.cpp/bin: llama-bench,
llama-completion and test-backend-ops. Its shaders need shaderc's glslc.
scripts/llama-radv.sh runs any program with the loader pointed at the RADV
ICD alone, so a MoltenVK installation is not used.

test-llama-offline brings the CS fixture device up inside llama.cpp's own
test-backend-ops (vulkan/tests/fixture_preload.c, inserted through
MLG_PRELOAD) so its Vulkan backend runs on RADV on the software GPU:
llama.cpp lists the R9700, and in performance mode ADD and the Q4_0/Q4_K
matrix multiplications of a feed-forward layer (matrix-vector and
matrix-matrix pipelines) are compiled by ACO, allocated, submitted and
fenced. It skips unless RADV and llama.cpp are built.
2026-10-03 11:19:41 -07:00

34 lines
1.3 KiB
C

/* The CS fixture device inside any Vulkan program: a library that, loaded
* with DYLD_INSERT_LIBRARIES, brings up the fixture device (unmodified
* upstream DRM/amdgpu over a software GPU, linuxu/tests/cs_fixture.c) and
* installs the loopback transport before the program starts, so RADV in
* that program reaches the fixture instead of the DriverKit extension.
*
* MLG_PRELOAD=libmlg_fixture.dylib scripts/llama-radv.sh test-backend-ops perf -b Vulkan0
*
* (scripts/llama-radv.sh sets DYLD_INSERT_LIBRARIES for the tool alone).
*
* Built by scripts/test-llama-offline.sh. The software GPU executes no
* shaders: programs see devices, memory, pipelines and fences, not
* results. */
#include <stdio.h>
#include <stdlib.h>
#include "mlg_drm.h"
#include "cs_fixture.h"
#include "lx_loopback.h"
__attribute__((constructor)) static void fixture_preload(void)
{
struct mlg_transport transport;
struct pci_dev *pdev = cs_fixture_init();
cs_fixture_model_driver_streams(1);
if (lx_loopback_transport(pdev, &transport) || mlg_drm_set_transport(&transport)) {
fprintf(stderr, "mlg fixture: no loopback transport\n");
abort();
}
lx_loopback_set_bar_memory(cs_fixture_bar_memory);
fprintf(stderr, "mlg fixture: software GPU ready (render node through the loopback)\n");
}