Repository navigation
pocl: define the device runtime as overlays so sysimages load - #930
Open
IanButterworth wants to merge 2 commits into
Open
IanButterworth wants to merge 2 commits into
IanButterworth wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #930 +/- ##
=======================================
Coverage 83.13% 83.13%
=======================================
Files 31 31
Lines 2568 2568
=======================================
Hits 2135 2135
Misses 433 433 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The POCL device runtime was defined as ordinary methods whose bodies declare device intrinsics such as `julia.gpu.state_getter`. Sysimage builds compile those methods for the host: Julia 1.12 and later compile every method with a compileable signature, and Julia 1.11 keeps the native code instances that inferring `initialize_rng_state` left behind. A sysimage is loaded with RTLD_NOW, so the undefined intrinsics stop it from loading. Define the device-only runtime functions with `@device_function`, so the host only sees a method that throws and the real body lives in the overlay table, as SPIRVIntrinsics does for its built-ins. `malloc` and `report_oom` use no intrinsics and stay host methods. Look up `initialize_rng_state` through the job's method tables and call it as a void function, instead of inferring its return type natively. Test that no method of the package reaches device code on the host, with GPUToolbox's `host_leaks`. This needs SPIRVIntrinsics 1.6, whose `@device_function` defines the body as a plain overlay, and GPUToolbox 3.5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On Julia 1.11, the launch in the precompile workload left GPUCompiler's runtime in the package image, and on Windows lld links package images eagerly. The device symbols that runtime referenced made the link fail, so the workload skipped the launch there. The POCL runtime no longer reaches device intrinsics on the host, and GPUCompiler 2.19 makes its boxing functions refer to type tags it can link, so drop the gate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
maleadt
force-pushed
the
ib/pocl-overlay-runtime
branch
from
October 28, 2026 07:41
de05727 to
f475f93
Compare
maleadt
marked this pull request as ready for review
October 28, 2026 07:41
This was referenced Oct 28, 2026
Member
|
Rebased and reworked.
The other back ends get the same fix in separate PRs. |
This branch has not been deployed
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.
A PackageCompiler sysimage that includes KernelAbstractions 0.10 builds, but doesn't load:
The POCL device runtime (
kernel_state,claim_output,signal_exception, the RNG helpers, ...) was defined as ordinary methods whose bodies reachllvmcalls that declare device intrinsics. Sysimage builds compile such methods for the host:initialize_rng_statewithCore.Compiler.return_typeinfinish_module!.A sysimage is loaded with
RTLD_NOW, so the undefined symbols stop it from loading. Package images load lazily, except on Windows, where lld links them eagerly: that is whysrc/precompile.jldidn't launch a kernel on Julia 1.11 on Windows. This is the same class of leak as JuliaGPU/GPUCompiler.jl#611.pocl: Define the device runtime as overlays so sysimages load
@device_functions: a host method that throws, with the real body in the overlay table.mallocandreport_oomuse no intrinsics and stay host methods.initialize_rng_statereturns nothing. It's looked up through the job's method tables and called as a void function, instead of inferring its return type with the native interpreter.GPUToolbox.Overlays.host_leaks(KernelAbstractions)is empty. It emulates the sysimage compile-all on typed IR and reports methods that reach device symbols.Precompile a kernel launch on Julia 1.11 on Windows again
With the runtime fixed, and GPUCompiler 2.19 (JuliaGPU/GPUCompiler.jl#1067) making its boxing functions linkable on the host, the Windows 1.11 gate on the precompile workload goes.
Requires GPUToolbox 3.5 (
host_leaks, registered), SPIRVIntrinsics 1.6 (JuliaGPU/OpenCL.jl#598, whose@device_functiondefines the body as a plain rather than a consistent overlay, so inference can't fold calls into the host error) and GPUCompiler 2.19 (being registered).Reproducer:
Then
julia -J ka.so -e 'println("loaded")'. On v0.10.3 this fails on Julia 1.11.9, 1.12.7 and 1.13.3; with this PR it loads on all three. On Windows, Julia 1.11 precompiles with the launch, loads, runs kernels and reports device exceptions.The other back ends get the same treatment in separate PRs.