From 124eafef194edc677e3dd7330ea3f181392ea33c Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Wed, 25 Nov 2026 10:05:41 +0100 Subject: [PATCH] POCL: compile with GPUCompiler's do-block compile 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. --- Project.toml | 2 +- src/pocl/compiler/compilation.jl | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Project.toml b/Project.toml index 33712e2a7..2b7339697 100644 --- a/Project.toml +++ b/Project.toml @@ -53,7 +53,7 @@ AMDGPU = "2" Adapt = "0.4, 1.0, 2.0, 3.0, 4" Atomix = "1.5" EnzymeCore = "0.8.25" -GPUCompiler = "2.23" +GPUCompiler = "2.24" GPUToolbox = "3.6" KernelInterface = "0.4.7" LLVM = "10" diff --git a/src/pocl/compiler/compilation.jl b/src/pocl/compiler/compilation.jl index a2b02775c..36bab0662 100644 --- a/src/pocl/compiler/compilation.jl +++ b/src/pocl/compiler/compilation.jl @@ -293,16 +293,12 @@ const compilations = Threads.Atomic{Int}(0) function compile_to_obj(@nospecialize(job::CompilerJob)) compilations[] += 1 - return JuliaContext() do ctx - obj, meta = invoke_frozen(GPUCompiler.compile, :obj, job) - - # we own the IR: inspect it, then dispose of it - @dispose ir = meta.ir begin - entry = meta.entry.name - device_rng = haskey(meta.entry.function_attributes, "julia.opencl.rng") - (; obj, entry, device_rng, meta.exception_sites) - end - end + # (runs in the context of the IR, which GPUCompiler frees afterwards) + inspect(obj, meta) = (; + obj, entry = meta.entry.name, meta.exception_sites, + device_rng = haskey(meta.entry.function_attributes, "julia.opencl.rng"), + ) + return invoke_frozen(GPUCompiler.compile, inspect, :obj, job) end # link the SPIR-V bytes into a session-local `cl.Kernel` on the active context.