Each request to the GPU is a round trip to the driver process, and
llama.cpp's Vulkan backend made about thirty per decoded token outside
the graph itself: every graph input was written with a blocking
set_tensor (a submission, a fence wait and a reset each, since no VRAM
is CPU-visible on Apple silicon), and ggml_vk_synchronize signalled its
fence with an empty submission, which RADV turns into eight syncobj
requests when it also waits for the transfer queue.
patches/llama.cpp/sched-staged-inputs.patch adds an optional backend
function that queues a write of host data after the backend's pending
work and copies the data before it returns; the scheduler uses it for
user inputs. Vulkan stages the data in host memory owned by the
backend context and copies it in the compute stream. The fence goes
with the last compute submission, transfer-only work is waited for on
the host, and small host copies stay in the compute stream. The new
test-backend-sched-inputs checks that inputs are taken when the graph
is queued and ordered against the device's queued work.
bootstrap.sh gains --reset-llama and removes the files patches add
when it resets a tree; verify-upstream.py accepts patches that add
files.
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.
third_party/mesa is Mesa at mesa-26.2.4, the latest stable release,
declared in patches/manifest.json as an optional upstream: a shallow,
partial, sparse submodule of what a RADV-only Meson build reads (about
60 MB), marked update = none so a recursive clone does not fetch it. Only
the Vulkan build needs it; scripts/bootstrap.sh --with-mesa fetches it
with the rest, --mesa-only alone, and once checked out it is kept at the
pin and patched like the Linux tree.
The patch set, 88 lines added and 9 removed in 8 files:
- radv-macos-build.patch: find libdrm through pkg-config on Darwin when
RADV is built, select addrlib's portable type definitions instead of
the Apple kernel driver's private header, and link RADV with
-undefined dynamic_lookup as KosmicKrisp does.
- drm-file-ops.patch: util/os_drm.h issues requests through drmIoctl and
wraps open, stat, mmap and munmap of DRM nodes and files in libdrm's
drmFile* functions when libdrm defines LIBDRM_FILE_OPS; RADV's six call
sites use the wrappers. Nothing changes for a kernel libdrm.
bootstrap.sh sets up any manifest upstream the same way now (pin fetched
by SHA, sparse before the first checkout, declared patches applied).
verify-upstream.py checks Mesa's pin, sparse set, patches and working tree
once it is checked out, and takes --only linux|mesa; lib-dext verifies the
Linux tree alone (make verify-linux), so local Mesa work cannot block a
driver build, while make verify-source checks every tree.
Add drivers/gpu/drm/display/ to the sparse checkout and compile the
display side of upstream amdgpu:
- mk/upstream_sources.mk gains the 498 objects of AMD_DISPLAY_FILES
(amd/display/Makefile and the Makefiles it includes, evaluated with
DRM_AMD_DC=y, DRM_AMD_DC_FP=y, DEBUG_FS=y), the drm_display_helper
module for the DRM_DISPLAY_* helpers amdgpu selects, the whole
drm_kms_helper module and the panel orientation/backlight quirk tables.
DCN 4.0.1 links the dcn10..dcn35 code it reuses, so every DCN is built.
- mk/kernel_config.mk and linux/autoconf.h enable DRM_AMD_DC, DC_FP and
the display helper configs; CEC, DP AUX chardev/CEC, DP tunnel, bridge
connector, SI DCE and secure display stay off.
- INCPATHS carries the subdir-ccflags-y include roots of the display
Makefiles in upstream order.
- CONFIG_DRM_AMD_DC_FP is declared in patches/manifest.json as a config
intervention: Kconfig drops it for clang+arm64 because of kernel FPU
rules that do not apply to userspace. scripts/verify-upstream.py checks
that each declared config intervention names a Kconfig symbol and is
set in autoconf.h.
- linux/kconfig.h provides IS_ENABLED/IS_REACHABLE as kbuild's forced
include does; autoconf.h pulls it in after the CONFIG table.
Display stays off at runtime by default; that gating follows separately.
Runs the unmodified upstream Linux amdgpu and amdkfd drivers on Apple
Silicon Macs inside a DriverKit system extension, for AMD GPUs attached
over Thunderbolt. The Linux sources come from a pinned submodule and are
compiled against linuxu, a userspace implementation of the Linux kernel
APIs they use. Includes the HSA runtime, the host installer app, the
setup and firmware fetch scripts, and the offline test suite.