Skip to content

Avoid boxing compiler jobs during kernel resolution - #1073

Merged
luraess merged 1 commit into
mainfrom
tb/compiler-job-allocations
Sep 23, 2026
Merged

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

Syntax and whitespace checks passed, and the package loaded on Julia 1.13. Device execution and allocation measurements were unavailable because the local HIP runtime was not functional.

@github-actions github-actions Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AMDGPU.jl Benchmarks

Details
Benchmark suite Current: a6a0fcd Previous: 4f0ab1a Ratio
amdgpu/synchronization/context/device 537.5 ns 562.5 ns 0.96
amdgpu/synchronization/stream/blocking 230 ns 235 ns 0.98
amdgpu/synchronization/stream/nonblocking 307.5 ns 320 ns 0.96
applications/bitonic_sort 1127262.5 ns 1098082.75 ns 1.03
applications/convolution 104821.25 ns 104229 ns 1.01
applications/floyd_warshall 8884519 ns 8878742.25 ns 1.00
applications/histogram 800743 ns 815134 ns 0.98
applications/prefix_sum 231368.25 ns 231900.75 ns 1.00
array/accumulate/Float32/1d 77921 ns 80493.75 ns 0.97
array/accumulate/Float32/dims=1 267816 ns 272491.25 ns 0.98
array/accumulate/Float32/dims=1L 79101.25 ns 88573.75 ns 0.89
array/accumulate/Float32/dims=2 69926 ns 81833.75 ns 0.85
array/accumulate/Float32/dims=2L 2753660.75 ns 2754656.25 ns 1.00
array/accumulate/Int64/1d 76753.25 ns 79688.75 ns 0.96
array/accumulate/Int64/dims=1 244033.25 ns 244706 ns 1.00
array/accumulate/Int64/dims=1L 84083.5 ns 84231.25 ns 1.00
array/accumulate/Int64/dims=2 70743.5 ns 86993.75 ns 0.81
array/accumulate/Int64/dims=2L 2887844.75 ns 3133859.25 ns 0.92
array/broadcast 71943.5 ns 71851 ns 1.00
array/construct 2237.5 ns 2385 ns 0.94
array/copy 36790.5 ns 38018 ns 0.97
array/copyto!/cpu_to_gpu 110953.75 ns 110996.5 ns 1.00
array/copyto!/gpu_to_cpu 119741.5 ns 111031.5 ns 1.08
array/copyto!/gpu_to_gpu 57063.25 ns 59370.75 ns 0.96
array/iteration/findall/bool 131339.25 ns 135379.5 ns 0.97
array/iteration/findall/int 147364.5 ns 150062.25 ns 0.98
array/iteration/findfirst/bool 182167.75 ns 152017.25 ns 1.20
array/iteration/findfirst/int 159684.75 ns 142527 ns 1.12
array/iteration/findmin/1d 104736.25 ns 106111.5 ns 0.99
array/iteration/findmin/2d 104871.25 ns 108821.5 ns 0.96
array/iteration/logical 231935.5 ns 243736 ns 0.95
array/iteration/scalar 289053.75 ns 300659.25 ns 0.96
array/permutedims/2d 70308.5 ns 71656 ns 0.98
array/permutedims/3d 69635.75 ns 71226 ns 0.98
array/permutedims/4d 72506 ns 73858.75 ns 0.98
array/random/rand/Float32 43323 ns 45950.75 ns 0.94
array/random/rand/Int64 52760.75 ns 54290.75 ns 0.97
array/random/rand!/Float32 64183.25 ns 65176 ns 0.98
array/random/rand!/Int64 72025.75 ns 66563.5 ns 1.08
array/random/randn/Float32 67536 ns 81206.25 ns 0.83
array/random/randn!/Float32 76238.5 ns 80368.5 ns 0.95
array/reductions/mapreduce/Float32/1d 82611 ns 95054 ns 0.87
array/reductions/mapreduce/Float32/dims=1 78423.5 ns 86063.75 ns 0.91
array/reductions/mapreduce/Float32/dims=1L 840728.25 ns 843989.5 ns 1.00
array/reductions/mapreduce/Float32/dims=2 79633.5 ns 75981 ns 1.05
array/reductions/mapreduce/Float32/dims=2L 138146.75 ns 138774.5 ns 1.00
array/reductions/mapreduce/Int64/1d 89593.75 ns 94306.5 ns 0.95
array/reductions/mapreduce/Int64/dims=1 78978.5 ns 86678.75 ns 0.91
array/reductions/mapreduce/Int64/dims=1L 837450.75 ns 846329.5 ns 0.99
array/reductions/mapreduce/Int64/dims=2 79311 ns 81706.25 ns 0.97
array/reductions/mapreduce/Int64/dims=2L 138606.75 ns 140432 ns 0.99
array/reductions/reduce/Float32/1d 82126 ns 94821.25 ns 0.87
array/reductions/reduce/Float32/dims=1 83401 ns 87331.25 ns 0.95
array/reductions/reduce/Float32/dims=1L 843373.25 ns 834664.5 ns 1.01
array/reductions/reduce/Float32/dims=2 79583.5 ns 76153.5 ns 1.05
array/reductions/reduce/Float32/dims=2L 137839.25 ns 139254.5 ns 0.99
array/reductions/reduce/Int64/1d 88673.75 ns 94776.5 ns 0.94
array/reductions/reduce/Int64/dims=1 78433.5 ns 86181 ns 0.91
array/reductions/reduce/Int64/dims=1L 835640.5 ns 839047 ns 1.00
array/reductions/reduce/Int64/dims=2 79873.5 ns 83326 ns 0.96
array/reductions/reduce/Int64/dims=2L 138314.25 ns 140177 ns 0.99
array/reverse/1d 42375.5 ns 42600.5 ns 0.99
array/reverse/1dL 55495.75 ns 72488.5 ns 0.77
array/reverse/1dL_inplace 60021 ns 78666 ns 0.76
array/reverse/1d_inplace 59068.25 ns 56155.75 ns 1.05
array/reverse/2d 48863.25 ns 49858.25 ns 0.98
array/reverse/2dL 79788.75 ns 82311.25 ns 0.97
array/reverse/2dL_inplace 88821.25 ns 89706.25 ns 0.99
array/reverse/2d_inplace 61018.5 ns 61980.75 ns 0.98
array/sorting/1d 333584.25 ns 332449.75 ns 1.00
gemm/tiled 1907885 ns 1904269.25 ns 1.00
gemm/tiled_unbounded 1885519.5 ns 1909711.75 ns 0.99
integration/byval/reference 37950 ns 39271 ns 0.97
integration/byval/slices=1 39971 ns 41411 ns 0.97
integration/byval/slices=2 153022 ns 132252 ns 1.16
integration/byval/slices=3 236793 ns 238713 ns 0.99
integration/volumerhs 4903154 ns 4997480 ns 0.98
kernel/indexing 34050.5 ns 28585.25 ns 1.19
kernel/indexing_checked 56363.25 ns 57423.5 ns 0.98
kernel/launch 1190 ns 1255 ns 0.95
kernel/rand 96551.25 ns 98873.75 ns 0.98
latency/import 1707561473 ns 1700382856 ns 1.00
latency/precompile 39971572760 ns 40071892794 ns 1.00
latency/ttfp 2309535677 ns 2305806765 ns 1.00
stencil/diffusion3d 1620565 ns 1623510.75 ns 1.00
stencil/diffusion3d_checked 1663115.75 ns 1662718.75 ns 1.00

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

@luraess

luraess commented Sep 14, 2026

Copy link
Copy Markdown
Member

Again Int128 failing test, on 1.12 only

@test Array(test_kernel.(ROCArray(M), Int128(10))) == test_kernel.(M, Int128(10))

@luraess

luraess commented Sep 22, 2026

Copy link
Copy Markdown
Member

Can you rebase on main to see CI passes then we could merge

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.
@maleadt
maleadt force-pushed the tb/compiler-job-allocations branch from 52023c9 to a6a0fcd Compare September 22, 2026 14:59
@luraess
luraess merged commit 8a66547 into main Sep 23, 2026
5 of 6 checks passed
@luraess
luraess deleted the tb/compiler-job-allocations branch September 23, 2026 19:04
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.

2 participants