Conversation
Contributor
|
Your PR no longer requires formatting changes. Thank you for your contribution! |
Import the IR and Build vocabularies next to LLVM.Interop, since `using LLVM` no longer exports the API, and use properties instead of the removed accessor functions (parameters, users, operands, value types, names, the module's functions and metadata, ...). Named metadata is no longer created by indexing, so the OpenCL and SPIR-V version nodes are looked up with `get!`. The users of the kernel state are collected before the heap is inserted, as the users view is live and would otherwise include the new insertvalue. The heap arena is inserted at the beginning of the entry block with an explicit insertion point.
Dispatch on the instruction types rather than on opcodes from the C API, and use the source_element_type, inbounds and indices properties and erase! instead of the corresponding C functions.
Pass the heap's alignment to alloca!, replace the kernel state in the operands of its users with replace!, and refer to the operands of loads, stores and GEPs by name. The bfloat lowering now uses a single builder (with @dispose) that is repositioned before every instruction it rewrites, instead of creating and disposing of one per instruction, and it skips declarations with isdeclaration. LLVM.jl 10 only supports LLVM 15 and later, which all have BFloatType, so drop that check.
GPUCompiler now hands the module that Julia's code generator produced to the caller of compile, so the IR of every kernel that compile_to_obj compiled was leaked, keeping its context alive (memcheck reports one undisposed module per compilation). compile_to_obj only needs the name of the entry point: read it and dispose of the IR inside the JuliaContext block. This also stops reading the entry function after the context has been exited, which only worked because the native code kept the context alive.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #656 +/- ##
==========================================
- Coverage 80.87% 79.35% -1.52%
==========================================
Files 57 57
Lines 4105 4084 -21
==========================================
- Hits 3320 3241 -79
- Misses 785 843 +58 ☔ 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.
Ports oneAPI.jl to LLVM.jl 10. LLVM.jl is only used in the compiler glue that reserves the device heap's private-memory arena and lowers
bfloattoi16on drivers withoutSPV_KHR_bfloat16.Main changes:
get!, the kernel state's users are collected before the heap is inserted (usersis a live view), and the arena goes in at an explicit insertion point.alloca!'salignkeyword, operand views, and a single builder for the bfloat lowering. TheBFloatTypecheck is gone, since it's always true on LLVM 15+.compile_to_objnever disposed of the IR that GPUCompiler returns, and read the entry point after leaving its context. Both now happen inside theJuliaContextblock.The heap and bfloat kernels generate the same instructions as before. Some pre-existing issues are not addressed here. The bfloat lowering drops alignment, volatility, ordering and metadata, and it swaps
bfloatvalues fori16ones withreplace_uses!, which LLVM builds with assertions reject. The version metadata is also emitted twice and accumulates when the runtime library is linked in.Tested on an Intel Iris Xe on Julia 1.10, 1.12 and 1.13. Results match main, plus GPUArrays' newer tests.
Requires GPUCompiler 2.11 (JuliaGPU/GPUCompiler.jl#974), GPUToolbox 3.3.3 (JuliaGPU/GPUToolbox.jl#28), UnsafeAtomics 0.3.3 (JuliaConcurrent/UnsafeAtomics.jl#31) and GPUArrays 11.5.16 (JuliaGPU/GPUArrays.jl#801), and SPIRVIntrinsics 1.2 (JuliaGPU/OpenCL.jl#525).
Disclaimer: this PR is AI-assisted and has not been reviewed in detail. Tests pass locally, so it should be a good starting point for a maintainer to complete the upgrade.