Repository navigation
Compile with GPUCompiler's do-block compile - #780
Merged
Merged
Conversation
GPUCompiler 2.24 can run a callback with the IR of a compilation and dispose of it afterwards. With GPUCompiler's llvmgpu toolchain, the IR can belong to libLLVMGPU, a newer LLVM than Julia's; the do-block activates the IR's context before the callback reads the entry point's name, which crashes from a `JuliaContext` of our own. For the same reason, `add_heap!` (run from `finish_ir!`, after optimization) can no longer use Julia's code generator to lower `KernelState` and its heap field to LLVM types. Take them from the kernel's state parameter instead, and only on optimized kernels, as optimization is what adds that parameter.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #780 +/- ##
==========================================
+ Coverage 86.71% 86.86% +0.14%
==========================================
Files 55 55
Lines 5143 5093 -50
==========================================
- Hits 4460 4424 -36
+ Misses 683 669 -14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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 uses the do-block form ofGPUCompiler.compilefrom JuliaGPU/GPUCompiler.jl#1124, which compiles in a context of its own, runs the block with the IR and disposes of it afterwards. With the upcoming llvmgpu toolchain (JuliaGPU/GPUCompiler.jl#1122), the IR can belong to libLLVMGPU, a newer LLVM than Julia's, and readingmeta.entry.namefrom our ownJuliaContextthen calls Julia's libLLVM on a libLLVMGPU value and segfaults. The do-block activates the IR's context around the block, so this works with either toolchain.add_heap!, which runs fromfinish_ir!after optimization, usedconvert(LLVMType, ...)to lowerKernelState,Csize_tand the heap pointer. Under llvmgpu that errors, because Julia's code generator can only create types in Julia's LLVM. It now takes the state and heap pointer types from the kernel's state parameter (which GPUCompiler adds to every kernel during optimization), and only runs on optimized kernels, since unoptimized IR has no state parameter. The GPUCompiler compat is raised to 2.24.Validated on an Iris Xe with GPUCompiler #1122 plus the do-block form, Julia 1.12: the full test suite passes with the default toolchain (25313 passed, 37 broken, 0 failed). Without a device, SPIR-V compilation of plain,
Ref-allocating andAny-boxing kernels (with both the LLVM and Khronos back-ends, optimized and unoptimized) also works under llvmgpu, where the old code fails or crashes, and with the default toolchain on 1.10 (typed pointers). The full suite under llvmgpu still has wrong integerdimsreductions and some driver segfaults, also in kernels that don't allocate, so those come from the toolchain and not from this change.