Skip to content

Cache the kernel lookup of cufunction with GPUCompiler's cached_lookup - #3482

Merged
maleadt merged 1 commit into
mainfrom
tb/cached-lookup
Oct 26, 2026
Merged

maleadt merged 1 commit into
mainfrom
tb/cached-lookup

Conversation

@maleadt

@maleadt maleadt commented Oct 26, 2026

Copy link
Copy Markdown
Member

Every launch resolves the method instance, builds the compiler configuration and job, takes a global lock and queries GPUCompiler's cache: about 5500 instructions, a third of an asynchronous @cuda. This wraps that lookup in GPUCompiler.cached_lookup (JuliaGPU/GPUCompiler.jl#1061), keyed on the context and the compiler options.

RTX 5080, Julia 1.12:

before after
cufunction (hit) 0.20 µs, 5476 insns 0.011 µs, 273 insns
@cuda (async) 1.63–1.71 µs, 16965 insns 1.35–1.42 µs, 11810 insns

…okup`

Every launch resolved the method instance, built the compiler configuration and
job, took a global lock and queried GPUCompiler's cache: about 5500 instructions,
a third of an asynchronous `@cuda`. Wrap that in `GPUCompiler.cached_lookup`,
keyed on the context and the compiler options. A hit now takes about 270
instructions, and `@cuda` goes from 1.67 to 1.38 µs.
@maleadt maleadt added the performance Runtime performance. label Oct 26, 2026
@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.63%. Comparing base (a3dfbfb) to head (35a8e24).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3482      +/-   ##
==========================================
- Coverage   87.75%   85.63%   -2.12%     
==========================================
  Files         193      192       -1     
  Lines       20275    19992     -283     
==========================================
- Hits        17792    17121     -671     
- Misses       2483     2871     +388     

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

@maleadt
maleadt merged commit 897711b into main Oct 26, 2026
18 checks passed
@maleadt
maleadt deleted the tb/cached-lookup branch October 26, 2026 12:50
@github-actions

Copy link
Copy Markdown
Contributor

CUDA.jl Benchmarks

Details
Benchmark suite Current: 35a8e24 Previous: a3dfbfb Ratio
array/accumulate/Float32/1d 42886 ns 43170 ns 0.99
array/accumulate/Float32/dims=1 27701 ns 28020 ns 0.99
array/accumulate/Float32/dims=1L 82480 ns 82829 ns 1.00
array/accumulate/Float32/dims=2 50679 ns 50386 ns 1.01
array/accumulate/Float32/dims=2L 374251 ns 373912 ns 1.00
array/accumulate/Int64/1d 72746 ns 72779 ns 1.00
array/accumulate/Int64/dims=1 45162 ns 45411 ns 0.99
array/accumulate/Int64/dims=1L 140435 ns 140892 ns 1.00
array/accumulate/Int64/dims=2 69799 ns 69499 ns 1.00
array/accumulate/Int64/dims=2L 768023 ns 765169 ns 1.00
array/broadcast 10311 ns 10581 ns 0.97
array/broadcast launch 6514.6 ns 7015.5 ns 0.93
array/construct 923.9459459459459 ns 908.8285714285714 ns 1.02
array/copy 17396 ns 17431 ns 1.00
array/copyto!/cpu_to_gpu 209862 ns 208849 ns 1.00
array/copyto!/gpu_to_cpu 242766 ns 241782 ns 1.00
array/copyto!/gpu_to_gpu 9060 ns 9026 ns 1.00
array/iteration/findall/bool 47765 ns 48091 ns 0.99
array/iteration/findall/int 62597 ns 62463 ns 1.00
array/iteration/findfirst/bool 32929 ns 36113 ns 0.91
array/iteration/findfirst/int 33660 ns 36206 ns 0.93
array/iteration/findmin/1d 50407 ns 51439 ns 0.98
array/iteration/findmin/2d 51315 ns 53794 ns 0.95
array/iteration/logical 48119 ns 48853 ns 0.98
array/iteration/scalar 61325 ns 61985 ns 0.99
array/permutedims/2d 47237 ns 47251 ns 1.00
array/permutedims/3d 44711 ns 44716 ns 1.00
array/permutedims/4d 37356 ns 48107 ns 0.78
array/random/rand/Float32 11545 ns 11443 ns 1.01
array/random/rand/Int64 17580 ns 17963 ns 0.98
array/random/rand!/Float32 8297.333333333334 ns 8423.666666666666 ns 0.99
array/random/rand!/Int64 15450 ns 15714 ns 0.98
array/random/randn/Float32 34484 ns 34085 ns 1.01
array/random/randn!/Float32 25364 ns 25383 ns 1.00
array/reductions/mapreduce/Float32/1d 34192 ns 36650 ns 0.93
array/reductions/mapreduce/Float32/dims=1 19634 ns 20606 ns 0.95
array/reductions/mapreduce/Float32/dims=1L 57137 ns 58262 ns 0.98
array/reductions/mapreduce/Float32/dims=2 26621 ns 28542 ns 0.93
array/reductions/mapreduce/Float32/dims=2L 57519 ns 58546 ns 0.98
array/reductions/mapreduce/Int64/1d 34279 ns 36832 ns 0.93
array/reductions/mapreduce/Int64/dims=1 21624 ns 23076 ns 0.94
array/reductions/mapreduce/Int64/dims=1L 96345 ns 97631 ns 0.99
array/reductions/mapreduce/Int64/dims=2 27486 ns 29611 ns 0.93
array/reductions/mapreduce/Int64/dims=2L 83320 ns 83824 ns 0.99
array/reductions/reduce/Float32/1d 34181 ns 36237 ns 0.94
array/reductions/reduce/Float32/dims=1 19332 ns 20754 ns 0.93
array/reductions/reduce/Float32/dims=1L 57113 ns 58298 ns 0.98
array/reductions/reduce/Float32/dims=2 26635 ns 28206 ns 0.94
array/reductions/reduce/Float32/dims=2L 57466 ns 58233 ns 0.99
array/reductions/reduce/Int64/1d 34569 ns 36907 ns 0.94
array/reductions/reduce/Int64/dims=1 22365 ns 22929 ns 0.98
array/reductions/reduce/Int64/dims=1L 97165 ns 97585 ns 1.00
array/reductions/reduce/Int64/dims=2 27688 ns 29990 ns 0.92
array/reductions/reduce/Int64/dims=2L 83594 ns 83516 ns 1.00
array/reverse/1d 19778 ns 19819 ns 1.00
array/reverse/1dL 73678 ns 73701 ns 1.00
array/reverse/1dL_inplace 69862 ns 70634 ns 0.99
array/reverse/1d_inplace 11779 ns 12449 ns 0.95
array/reverse/2d 22290 ns 22700 ns 0.98
array/reverse/2dL 80879 ns 81153 ns 1.00
array/reverse/2dL_inplace 70648 ns 71145 ns 0.99
array/reverse/2d_inplace 14380 ns 15174 ns 0.95
array/sorting/1d 748790 ns 750060 ns 1.00
array/sorting/2d 193447 ns 194579 ns 0.99
array/sorting/by 926358 ns 927982 ns 1.00
cuda/graph/capture 33777 ns 36378 ns 0.93
cuda/graph/eager 31905 ns 35636 ns 0.90
cuda/graph/launch 14026 ns 13878 ns 1.01
cuda/synchronization/context/auto 2355 ns 2377.777777777778 ns 0.99
cuda/synchronization/context/blocking 900.8205128205128 ns 908.2162162162163 ns 0.99
cuda/synchronization/context/nonblocking 10992 ns 10870 ns 1.01
cuda/synchronization/stream/auto 901.7096774193549 ns 866.7241379310345 ns 1.04
cuda/synchronization/stream/blocking 794.9387755102041 ns 790.26 ns 1.01
cuda/synchronization/stream/nonblocking 8640.333333333334 ns 8471 ns 1.02
integration/byval/reference 146702 ns 147937 ns 0.99
integration/byval/slices=1 147412 ns 148832 ns 0.99
integration/byval/slices=2 288987 ns 290301 ns 1.00
integration/byval/slices=3 430798 ns 432515 ns 1.00
integration/cudadevrt 104013 ns 105148 ns 0.99
integration/volumerhs 9610232 ns 9607952 ns 1.00
kernel/indexing 10384 ns 11654 ns 0.89
kernel/indexing_checked 10990 ns 12225 ns 0.90
kernel/launch 1347.6 ns 2436.3333333333335 ns 0.55
kernel/occupancy 34.18932527693857 ns 683.6513157894736 ns 0.05000988733190264
kernel/rand 13853 ns 15333 ns 0.90
latency/import 4058786002 ns 4047989887 ns 1.00
latency/precompile 4996941479 ns 5006008511 ns 1.00
latency/ttfp 5029410425 ns 4974010072 ns 1.01

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

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

Labels

performance Runtime performance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant