From a6a0fcd1a5be066d0aa89c575563a2a2c203cd19 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Mon, 14 Sep 2026 12:38:09 +0200 Subject: [PATCH] Avoid boxing compiler jobs during kernel resolution Specialize compile_or_lookup on the backend target and parameter types. Keep it out of line to avoid duplicating the body in callers specialized per kernel, while preserving the existing GPUCompiler cache path. --- src/compiler/codegen.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/codegen.jl b/src/compiler/codegen.jl index df944d660..cb1b8e08f 100644 --- a/src/compiler/codegen.jl +++ b/src/compiler/codegen.jl @@ -275,7 +275,9 @@ end # on 1.10. `obj === nothing` identifies a freshly-created `HIPResults` that hasn't been # compiled yet; the `compile_hook` check additionally forces the compile path so that # reflection consumers (`@device_code_*`) observe the compilation even on a cache hit. -function compile_or_lookup(@nospecialize(job::CompilerJob))::HIPResults +# Specialize on the target/parameter types so callers can avoid boxing CompilerJob. +# Keep the body out of callers that specialize per kernel. +@noinline function compile_or_lookup(job::CompilerJob)::HIPResults res = GPUCompiler.cached_results(HIPResults, job) if res === nothing || res.obj === nothing || GPUCompiler.compile_hook[] !== nothing compiled = hipcompile(job)