Skip to content

Cache and relocate Metal kernels - #916

Draft
maleadt wants to merge 1 commit into
mainfrom
relocations
Draft

Cache and relocate Metal kernels#916
maleadt wants to merge 1 commit into
mainfrom
relocations

Conversation

@maleadt

@maleadt maleadt commented Aug 15, 2026

Copy link
Copy Markdown
Member

Adapts Metal to JuliaGPU/GPUCompiler.jl#878 using the :table relocation strategy.

Metal cannot look up writable data symbols after loading a library, so GPUCompiler rewrites host references through a relocation table. Metal materializes that table in a per-device buffer and passes its address through KernelState on every dispatch. Pipelines and buffers remain device-local while relocatable metallibs can survive package precompilation.

This also adds an opt-in MTLBinaryArchive cache for final machine code and descriptor-based pipeline construction. Archive use remains disabled by default while the cross-process byte-stability constraints are evaluated.

Tests cover Julia values, runtime globals, boxed interior relocations, device isolation, cross-session precompilation, and archive behavior. The corresponding writable-global implementation is JuliaGPU/CUDA.jl#3200.

@maleadt
maleadt force-pushed the relocations branch 2 times, most recently from 0ac8879 to 1b009b9 Compare August 15, 2026 16:19
Deliver GPUCompiler relocation words through a table referenced by KernelState, avoiding unsupported post-load symbol patching. Keep relocation buffers and pipelines device-local while allowing relocatable Metal libraries to survive package precompilation.

Add an opt-in MTLBinaryArchive cache for final machine code, descriptor-based pipeline construction, boxed-argument identity handling, and cross-session tests for compilation artifacts, table delivery, and archive behavior.
@maleadt maleadt changed the title Use relocatable IR, cached in package images Cache and relocate Metal kernels Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant