Repository navigation
Keep the OpenCL queries of the POCL back-end concretely typed - #915
Merged
Merged
Conversation
`default_forwarders!` reduced over a value of unknown type, `split_branches` sliced one, and `default_sub_group_size` spliced the untyped result of the device's `getproperty` into an array literal. That compiled them with edges to generic Base methods that packages loaded before KernelAbstractions invalidate (e.g. ChainRulesCore's `mapreduce` and `promote_rule` methods), making Julia discard their precompiled code, and that of the POCL back-end's launch path, when loading KernelAbstractions.
The local helpers that query scalar properties took the property's type as a value, which Julia doesn't specialize on, and `getproperty` used the untyped result of querying other properties of the same object. The OpenCL API calls were then compiled with arguments of unknown type, and with edges to generic conversion methods (e.g. CEnum's `cconvert`, loaded through LLVM.jl), which packages invalidate. As these queries are made when launching a kernel on the CPU back-end, Julia recompiled that path when such a package was loaded before KernelAbstractions. Specialize the helpers on the type, and assert the types of nested property queries.
maleadt
force-pushed
the
tb/invalidations
branch
from
October 21, 2026 13:07
a1addbb to
4b72f59
Compare
maleadt
force-pushed
the
tb/invalidations-2
branch
from
October 21, 2026 13:07
fc5c4cd to
185d448
Compare
Contributor
Benchmark ResultsShow table
Benchmark PlotsA plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## tb/invalidations #915 +/- ##
=================================================
Coverage 82.73% 82.73%
=================================================
Files 28 28
Lines 2461 2461
=================================================
Hits 2036 2036
Misses 425 425 ☔ 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.
Follow-up to #914. The POCL back-end's OpenCL wrapper queried scalar device and kernel properties with local helpers that took the property's type as a value (
get_scalar(prop, cl_uint)), which Julia doesn't specialize on, soRef{typ}()and theccalls it was passed to were inferred with arguments of unknown type.getpropertyalso used the (untyped) result of querying other properties of the same object, e.g.p.num_devicesto size a buffer. Thoseccalls were then compiled with edges to generic conversion methods, like CEnum'scconvert(loaded through LLVM.jl), and as these queries run when launching a kernel on the CPU back-end, Julia recompiled that path for the first kernel whenever a package extending those methods (e.g. DataFrames' dependencies) was loaded first.This specializes the helpers on the property type, and asserts the types of the nested property queries.
Tested with the test suite. With JuliaLLVM/LLVM.jl#703 and JuliaGPU/GPUCompiler.jl#1053, the first CPU kernel with DataFrames loaded first goes from 4.16 s on main to 1.47 s (0.71 s with nothing loaded first).