Relocate cached CUDA kernels at load time - #3200
Open
maleadt wants to merge 1 commit into
Open
Conversation
maleadt
marked this pull request as draft
July 14, 2026 13:35
maleadt
marked this pull request as ready for review
July 15, 2026 20:34
Contributor
CUDA.jl BenchmarksDetails
This comment was automatically generated by workflow using github-action-benchmark. |
maleadt
marked this pull request as draft
July 27, 2026 08:18
maleadt
force-pushed
the
tb/relocations
branch
3 times, most recently
from
August 15, 2026 18:18
aef4a3d to
99bbc58
Compare
Compile host references into named writable cubin globals and retain their relocation manifest with the cached image. After loading a module, resolve each target for the current Julia session and patch it through cuModuleGetGlobal and cuMemcpyHtoD before retrieving the kernel. Keep module and function handles context-local while allowing relocatable images to survive package precompilation. Explicitly enroll the foreign GPU CodeInstance so supported Julia runtimes serialize the cached cubin. Cover runtime-library type tags, ordinary Julia values, and boxed interior relocations by executing patched kernels.
maleadt
marked this pull request as ready for review
August 17, 2026 19:30
maleadt
force-pushed
the
tb/relocations
branch
from
August 17, 2026 19:30
99bbc58 to
c67e8c0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adapts CUDA to JuliaGPU/GPUCompiler.jl#878 using the
:patchrelocation strategy.Compiled cubins retain a relocation manifest and expose each host reference as a named writable global. After
CuModuleloading, CUDA resolves the current-session value, finds the slot withcuModuleGetGlobal, and patches it withcuMemcpyHtoDbefore retrieving the kernel.Cubins, entry names, and relocation metadata can therefore survive package precompilation on supported Julia versions. Module and function handles remain context-local and are never serialized. The precompile workload explicitly enrolls its GPU CodeInstance so the cached cubin is present in a fresh session.
Tests execute kernels containing runtime-library type tags, ordinary Julia values, and boxed interior relocations.