Skip to content

Avoid boxing compiler jobs during kernel resolution - #3273

Merged
maleadt merged 1 commit into
mainfrom
tb/compiler-job-allocations
Sep 15, 2026
Merged

maleadt merged 1 commit into
mainfrom
tb/compiler-job-allocations

Conversation

@maleadt

@maleadt maleadt commented Sep 14, 2026

Copy link
Copy Markdown
Member

Kernel resolution constructs a CompilerJob immediately before passing it through an unspecialized compile_or_lookup boundary, which can force the job onto the heap. Allow specialization on the job's target and compiler-parameter types, and keep the method @noinline so its body is not duplicated into callers specialized per kernel. Kernel identity remains a field of the job, so this does not introduce per-kernel specialization or another cache.

Applies the approach from KernelAbstractions.jl#769.

On Julia 1.13 / GPUCompiler 2.7 with an RTX 5080, warm cufunction resolution dropped from 304 to 32 bytes per call. Kernel launch and six cache checks passed, covering cache reuse, compiler options, reflection, and kernel/callee redefinition. Two kernels produced one compile_or_lookup specialization.

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.
@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.65%. Comparing base (65f6ddd) to head (8a7eabe).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3273      +/-   ##
==========================================
+ Coverage   92.64%   92.65%   +0.01%     
==========================================
  Files         194      194              
  Lines       16988    16988              
==========================================
+ Hits        15738    15741       +3     
+ Misses       1250     1247       -3     

☔ 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.

@github-actions

Copy link
Copy Markdown
Contributor

CUDA.jl Benchmarks

Details
Benchmark suite Current: 8a7eabe Previous: 65f6ddd Ratio
array/accumulate/Float32/1d 99648 ns 99072 ns 1.01
array/accumulate/Float32/dims=1 72332 ns 71446 ns 1.01
array/accumulate/Float32/dims=1L 1588784 ns 1588291 ns 1.00
array/accumulate/Float32/dims=2 138257 ns 137838 ns 1.00
array/accumulate/Float32/dims=2L 662363 ns 662440 ns 1.00
array/accumulate/Int64/1d 119677 ns 119538 ns 1.00
array/accumulate/Int64/dims=1 75373 ns 75442 ns 1.00
array/accumulate/Int64/dims=1L 1699644 ns 1700551 ns 1.00
array/accumulate/Int64/dims=2 149449 ns 149989 ns 1.00
array/accumulate/Int64/dims=2L 988289 ns 988238 ns 1.00
array/broadcast 18156 ns 18134 ns 1.00
array/broadcast launch 9092 ns 9573 ns 0.95
array/construct 924.060606060606 ns 883.3035714285714 ns 1.05
array/copy 16341 ns 16308 ns 1.00
array/copyto!/cpu_to_gpu 206617 ns 206834 ns 1.00
array/copyto!/gpu_to_cpu 239917 ns 239908 ns 1.00
array/copyto!/gpu_to_gpu 10175 ns 8787 ns 1.16
array/iteration/findall/bool 133884 ns 134476 ns 1.00
array/iteration/findall/int 146521 ns 147563 ns 0.99
array/iteration/findfirst/bool 68884 ns 69589 ns 0.99
array/iteration/findfirst/int 70649 ns 71492 ns 0.99
array/iteration/findmin/1d 68314 ns 65074 ns 1.05
array/iteration/findmin/2d 100393 ns 99665 ns 1.01
array/iteration/logical 192493 ns 193914 ns 0.99
array/iteration/scalar 63034 ns 64850 ns 0.97
array/permutedims/2d 48865 ns 48559 ns 1.01
array/permutedims/3d 50091 ns 49871 ns 1.00
array/permutedims/4d 49834 ns 50293 ns 0.99
array/random/rand/Float32 11128 ns 10986 ns 1.01
array/random/rand/Int64 21105 ns 20771 ns 1.02
array/random/rand!/Float32 7642.75 ns 7657.5 ns 1.00
array/random/rand!/Int64 18730 ns 18743 ns 1.00
array/random/randn/Float32 33357 ns 33687 ns 0.99
array/random/randn!/Float32 23236 ns 23290 ns 1.00
array/reductions/mapreduce/Float32/1d 32233 ns 32510 ns 0.99
array/reductions/mapreduce/Float32/dims=1 37761 ns 37611 ns 1.00
array/reductions/mapreduce/Float32/dims=1L 50854 ns 51090 ns 1.00
array/reductions/mapreduce/Float32/dims=2 56330 ns 56419 ns 1.00
array/reductions/mapreduce/Float32/dims=2L 67178 ns 67348 ns 1.00
array/reductions/mapreduce/Int64/1d 39519 ns 39881 ns 0.99
array/reductions/mapreduce/Int64/dims=1 40578 ns 40406 ns 1.00
array/reductions/mapreduce/Int64/dims=1L 88500 ns 88686 ns 1.00
array/reductions/mapreduce/Int64/dims=2 57712 ns 58014 ns 0.99
array/reductions/mapreduce/Int64/dims=2L 83652 ns 83765 ns 1.00
array/reductions/reduce/Float32/1d 32347 ns 32834 ns 0.99
array/reductions/reduce/Float32/dims=1 37681 ns 37975 ns 0.99
array/reductions/reduce/Float32/dims=1L 50610 ns 50935 ns 0.99
array/reductions/reduce/Float32/dims=2 55112 ns 55515 ns 0.99
array/reductions/reduce/Float32/dims=2L 67373 ns 67712 ns 0.99
array/reductions/reduce/Int64/1d 39300 ns 40661 ns 0.97
array/reductions/reduce/Int64/dims=1 40485 ns 40565 ns 1.00
array/reductions/reduce/Int64/dims=1L 88478 ns 88618 ns 1.00
array/reductions/reduce/Int64/dims=2 57814 ns 57805 ns 1.00
array/reductions/reduce/Int64/dims=2L 83488 ns 83628 ns 1.00
array/reverse/1d 15748 ns 16887 ns 0.93
array/reverse/1dL 69618 ns 69686 ns 1.00
array/reverse/1dL_inplace 67283 ns 67634 ns 0.99
array/reverse/1d_inplace 8387.666666666666 ns 8774.333333333334 ns 0.96
array/reverse/2d 20172 ns 20484 ns 0.98
array/reverse/2dL 73669 ns 73815 ns 1.00
array/reverse/2dL_inplace 67521 ns 67476 ns 1.00
array/reverse/2d_inplace 12151 ns 10081 ns 1.21
array/sorting/1d 2643503 ns 2636501 ns 1.00
array/sorting/2d 1017532 ns 1018106 ns 1.00
array/sorting/by 3173019 ns 3173453 ns 1.00
cuda/synchronization/context/auto 1003.7 ns 1036.3 ns 0.97
cuda/synchronization/context/blocking 789.09375 ns 806.7 ns 0.98
cuda/synchronization/context/nonblocking 5811.666666666667 ns 5925.833333333333 ns 0.98
cuda/synchronization/stream/auto 868.0555555555555 ns 875.42 ns 0.99
cuda/synchronization/stream/blocking 677.7615894039735 ns 668.2352941176471 ns 1.01
cuda/synchronization/stream/nonblocking 5598 ns 5835.428571428572 ns 0.96
integration/byval/reference 147827 ns 148006 ns 1.00
integration/byval/slices=1 148997 ns 149001 ns 1.00
integration/byval/slices=2 291830 ns 292091 ns 1.00
integration/byval/slices=3 434515 ns 435187 ns 1.00
integration/cudadevrt 104953 ns 105008 ns 1.00
integration/volumerhs 9149895 ns 9143150 ns 1.00
kernel/indexing 12960 ns 13076 ns 0.99
kernel/indexing_checked 13461 ns 13739 ns 0.98
kernel/launch 2066.222222222222 ns 2367.8888888888887 ns 0.87
kernel/occupancy 752.6324786324786 ns 956.5652173913044 ns 0.79
kernel/rand 15739 ns 14149 ns 1.11
latency/import 4221177420 ns 4204215460 ns 1.00
latency/precompile 4976875259 ns 4989180514 ns 1.00
latency/ttfp 4680902562 ns 4686057154 ns 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@maleadt
maleadt merged commit 7c36840 into main Sep 15, 2026
1 check passed
@maleadt
maleadt deleted the tb/compiler-job-allocations branch September 15, 2026 05:29
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