Skip to content

Compile with GPUCompiler's do-block compile - #995

Merged
maleadt merged 1 commit into
mainfrom
tb/compile-do-block
Nov 25, 2026
Merged

maleadt merged 1 commit into
mainfrom
tb/compile-do-block

Conversation

@maleadt

@maleadt maleadt commented Nov 25, 2026

Copy link
Copy Markdown
Member

The POCL back-end now compiles with GPUCompiler's do-block form of compile (JuliaGPU/GPUCompiler.jl#1124), which runs the inspection of the IR (entry name, the julia.opencl.rng attribute, exception sites) in the IR's own context and frees the IR afterwards. With GPUCompiler's upcoming llvmgpu toolchain (JuliaGPU/GPUCompiler.jl#1122), the IR can belong to libLLVMGPU, a newer LLVM than Julia's; reading it through Julia's LLVM, as compile_to_obj did, segfaults in llvm::Value::getName while precompiling KernelAbstractions, which breaks every downstream llvmgpu CI job. The do-block form is new in GPUCompiler 2.24, so the compat is raised to that. finish_module! and finish_linked_module! run before the IR moves to libLLVMGPU and need no changes.

Validated on Julia 1.12 with GPUCompiler from #1122 plus #1124: the test suite passes with the default toolchain (13028 passed, 0 failed) and with toolchain = "llvmgpu" (same counts, precompiled launch included), while main segfaults during precompilation under llvmgpu. Two checks were left out locally, unrelated to this change: Aqua's persistent-tasks check (it can't resolve a dev'd GPUCompiler checkout) and the "POCL session" subprocess, which segfaults in "null pointer arguments" on that machine with main and with registered KA 0.10.8 + GPUCompiler 2.23.4 as well, but passes on CI.

It runs the inspection in the context of the IR, which can belong to
libLLVMGPU with GPUCompiler's llvmgpu toolchain. Reading it through
Julia's LLVM instead crashed or hung, e.g. in the precompile workload.
The do-block form is new in GPUCompiler 2.24, so require that.
@github-actions

Copy link
Copy Markdown
Contributor

Benchmark results

Compared with 2b0e90c0e, the merge base.
The environment differs from the baseline's: CompilerCaching 0.5.3 → 0.5.4, GPUCompiler 2.23.4 → 2.24.0, LLVM 10.6.0 → 10.7.0, LLVMExtra_jll 0.0.59+0 → 0.0.60+0, XML2_jll 2.15.4+0 → 2.15.5.

Times are the minimum time of every benchmark. A change is unusual when it exceeds both three times the benchmark's typical change between consecutive runs on the default branch and a minimum per category (performance 3%, latency 5%, applications 3%, other 3%). A benchmark that starts or stops allocating is listed however few the allocations. A single run can still be a fluke, so rerun before drawing conclusions.

Geometric mean Unusual: slower Unusual: faster Compared
Performance −0.6% 1 0 32
Latency +0.1% 1 0 13
Applications −1.5% 0 1 5
Benchmark Baseline This PR Change
Performance
pocl/serial/math/exp-f64 114 µs 124 µs +8.1% 🔴 slower
Latency
host/import/ka 710 ms 765 ms +7.6% 🔴 slower
Applications
pocl/serial/stencil/timestep 10.8 ms 9.92 ms −8.4% 🟢 faster
All benchmarks
Benchmark Baseline This PR Change
Performance
julia/serial/arithmetic/muladd-reference 655 µs 655 µs −0.0%
julia/serial/math/exp-f64-reference 284 µs 284 µs −0.0%
julia/serial/narrow/masked-reference 720 µs 708 µs −1.7%
pocl/parallel/atomics/histogram 5.25 ms 5.20 ms −0.8%
pocl/parallel/groupreduce/add-f64 1.09 ms 1.09 ms −0.2%
pocl/parallel/groupreduce/fallback 4.38 ms 4.38 ms −0.0%
pocl/parallel/groupscan/add-i32 393 µs 392 µs −0.3%
pocl/parallel/indexing/cartesian3d 38.9 µs 38.8 µs −0.3%
pocl/parallel/indexing/linear3d 41.1 µs 38.8 µs −5.5%
pocl/parallel/indexing/ntuple3d 41.0 µs 39.3 µs −4.1%
pocl/parallel/indexing/ntuple4d 129 µs 128 µs −0.6%
pocl/parallel/localmem/transpose-naive 429 µs 425 µs −1.1%
pocl/parallel/localmem/transpose-tiled 67.8 µs 60.6 µs −10.6%
pocl/parallel/private/across-barrier 42.4 µs 42.3 µs −0.1%
pocl/parallel/scheduling/default 117 µs 117 µs −0.0%
pocl/parallel/scheduling/explicit 117 µs 117 µs +0.0%
pocl/parallel/stream/copy/cache 769 ns 637 ns −17.2%
pocl/parallel/stream/copy/dram 6.55 ms 6.33 ms −3.3%
pocl/parallel/stream/triad/cache 1.21 µs 1.40 µs +15.6%
pocl/parallel/stream/triad/dram 9.60 ms 9.62 ms +0.2%
pocl/parallel/util/copyto-small 25.0 ns 26.0 ns +4.0%
pocl/parallel/util/zeros-large 928 µs 914 µs −1.6%
pocl/parallel/util/zeros-small 628 ns 653 ns +4.0%
pocl/serial/arithmetic/contract 1.85 ms 1.85 ms +0.0%
pocl/serial/arithmetic/muladd 705 µs 705 µs +0.0%
pocl/serial/const/marked 668 µs 668 µs +0.0%
pocl/serial/const/unmarked 860 µs 859 µs −0.0%
pocl/serial/math/exp-f64 114 µs 124 µs +8.1% 🔴 slower
pocl/serial/math/sin-f64 170 µs 171 µs +0.5%
pocl/serial/narrow/masked 634 µs 633 µs −0.1%
pocl/serial/narrow/unmasked 630 µs 627 µs −0.4%
pocl/serial/stream/triad/dram 8.55 ms 8.58 ms +0.4%
Latency
host/import/ka 710 ms 765 ms +7.6% 🔴 slower
host/precompile/ka 27.1 s 27.3 s +0.6%
host/startup 129 ms 131 ms +1.7%
pocl/parallel/launch/dynamic-default 166 ns 165 ns −0.6%
pocl/parallel/launch/groupreduce-f64 773 ns 773 ns +0.0%
pocl/parallel/launch/many-args 659 ns 673 ns +2.1%
pocl/parallel/launch/partial-workgroup 235 ns 236 ns +0.4%
pocl/serial/compile/groupreduce 1.51 s 1.49 s −1.5%
pocl/serial/compile/localmem-barrier 682 ms 673 ms −1.3%
pocl/serial/compile/new-kernel 127 ms 127 ms −0.1%
pocl/serial/compile/new-workgroupsize 8.84 ms 8.74 ms −1.2%
pocl/serial/first-kernel/cold-cache 404 ms 393 ms −2.7%
pocl/serial/first-kernel/warm-cache 327 ms 317 ms −3.2%
Applications
pocl/parallel/dgsem/fluxdiff-node 248 µs 246 µs −1.0%
pocl/parallel/dgsem/weak-element 91.2 µs 95.2 µs +4.4%
pocl/parallel/dgsem/weak-node-localmem 93.7 µs 93.1 µs −0.6%
pocl/parallel/stencil/timestep 7.54 ms 7.44 ms −1.3%
pocl/serial/stencil/timestep 10.8 ms 9.92 ms −8.4% 🟢 faster

History: https://juliagpu.org/perf/?pkg=kernelabstractions

@maleadt
maleadt merged commit a1685e3 into main Nov 25, 2026
29 of 30 checks passed
@maleadt
maleadt deleted the tb/compile-do-block branch November 25, 2026 13:07
@codecov

codecov Bot commented Nov 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.24%. Comparing base (2b0e90c) to head (124eafe).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #995      +/-   ##
==========================================
- Coverage   89.99%   89.24%   -0.75%     
==========================================
  Files          33       33              
  Lines        3059     3004      -55     
==========================================
- Hits         2753     2681      -72     
- Misses        306      323      +17     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant