Repository navigation
Compile with GPUCompiler's do-block compile - #631
Merged
Merged
Conversation
`compile_to_obj` now uses `GPUCompiler.compile(f, :obj, job)`, which creates the context, calls `f` with the code and metadata, and frees the IR afterwards. The entry name and RNG attribute are read inside the block. With GPUCompiler's llvmgpu toolchain, the IR can belong to libLLVMGPU, a newer LLVM than Julia's. Reading the entry's name from inside our own `JuliaContext` then called into Julia's libLLVM and segfaulted; the do-block form activates the IR's own context around `f`. Requires GPUCompiler 2.24.
This was referenced Nov 25, 2026
Merged
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.
compile_to_objnow usesGPUCompiler.compile(f, :obj, job)(JuliaGPU/GPUCompiler.jl#1124), which creates the context, callsfwith the SPIR-V and its metadata, and frees the IR afterwards. The entry name and thejulia.opencl.rngattribute are read inside the block; only plain data leaves it.With GPUCompiler's upcoming llvmgpu toolchain (JuliaGPU/GPUCompiler.jl#1122), the IR can belong to libLLVMGPU, a newer LLVM than Julia's. The current code then reads
meta.entry.namethrough Julia's libLLVM and segfaults; the do-block form activates the IR's own context aroundf. The GPUCompiler hooks (finish_module!,finish_linked_module!) run while the IR is still in Julia's LLVM, so they are unchanged. GPUCompiler compat is raised to 2.24.Validated on PoCL with Julia 1.12 and GPUCompiler 2.24.0 + #1122: the full suite passes with the default toolchain and with
toolchain = "llvmgpu"(53604 passed, 9 broken, 0 failed each). Under llvmgpu, a kernel launch segfaults inLLVMGetValueNamewith the old code and runs correctly with the new one.