Skip to content

Assert that the CUDA compiler tools return commands - #3440

Merged
maleadt merged 2 commits into
mainfrom
tb/invalidations
Oct 22, 2026
Merged

maleadt merged 2 commits into
mainfrom
tb/invalidations

Conversation

@maleadt

@maleadt maleadt commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

CUDA_Compiler.ptxas(), nvlink() and nvdisasm() aren't inferred, so interpolating them into command literals was compiled with an edge to Base.arg_gen(::Any). FilePathsBase extends arg_gen, so with a package depending on it loaded before CUDA.jl, Julia discarded the precompiled code that queries the compiler version when loading CUDA.jl, and with it a large part of CUDACore's precompiled compilation and launch code (about 1500 method instances with a set of common packages, including DataFrames, CairoMakie and Dagger, loaded first). These functions return Cmds for both the JLL and the local toolkit, so this asserts that.

This is part of a series addressing JuliaGPU/GPUCompiler.jl#1048 (with JuliaGPU/GPUCompiler.jl#1052, JuliaLLVM/LLVM.jl#702 and maleadt/CompilerCaching.jl#33). With all of them, the first @cuda kernel (plus a broadcast and sum) with ChainRulesCore loaded first goes from 4.25 s to 2.76 s (2.52 s without it), and with DataFrames from 7.12 s to 5.72 s, on Julia 1.13 and an RTX 5080. Tested with the core codegen, execution, exceptions, KernelAbstractions, broadcast and array tests.

`CUDA_Compiler.ptxas()` and friends aren't inferred, so interpolating them into a
command literal was compiled with an edge to `Base.arg_gen(::Any)`, which
FilePathsBase extends. With such a package loaded first, Julia discarded the
precompiled code that queries the compiler version, and through it much of
CUDACore's compilation and launch path, when loading CUDA.jl.
@maleadt maleadt added the latency Compile time, load time, time-to-first-execution, invalidations. label Oct 21, 2026
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

CUDA.jl Benchmarks

Details
Benchmark suite Current: 337cfd2 Previous: a9e28c0 Ratio
array/accumulate/Float32/1d 55120 ns 53368 ns 1.03
array/accumulate/Float32/dims=1 39901 ns 39146 ns 1.02
array/accumulate/Float32/dims=1L 82731 ns 82278 ns 1.01
array/accumulate/Float32/dims=2 50151 ns 49464 ns 1.01
array/accumulate/Float32/dims=2L 399975 ns 399782 ns 1.00
array/accumulate/Int64/1d 89063 ns 87737 ns 1.02
array/accumulate/Int64/dims=1 60450 ns 59754 ns 1.01
array/accumulate/Int64/dims=1L 140443 ns 139769 ns 1.00
array/accumulate/Int64/dims=2 69095 ns 68524 ns 1.01
array/accumulate/Int64/dims=2L 796007 ns 797529 ns 1.00
array/broadcast 10394 ns 10132 ns 1.03
array/broadcast launch 6742.4 ns 6591 ns 1.02
array/construct 906.55 ns 934.15 ns 0.97
array/copy 17239 ns 16973 ns 1.02
array/copyto!/cpu_to_gpu 208686 ns 206527 ns 1.01
array/copyto!/gpu_to_cpu 241308 ns 240008 ns 1.01
array/copyto!/gpu_to_gpu 8785 ns 8794 ns 1.00
array/iteration/findall/bool 48834 ns 47090 ns 1.04
array/iteration/findall/int 65488 ns 65086 ns 1.01
array/iteration/findfirst/bool 35545 ns 35389 ns 1.00
array/iteration/findfirst/int 36050 ns 34804 ns 1.04
array/iteration/findmin/1d 51026 ns 50387 ns 1.01
array/iteration/findmin/2d 52887 ns 51323 ns 1.03
array/iteration/logical 50616 ns 49399 ns 1.02
array/iteration/scalar 59599 ns 60128 ns 0.99
array/permutedims/2d 47205 ns 46699 ns 1.01
array/permutedims/3d 44741 ns 44729 ns 1.00
array/permutedims/4d 47711 ns 47477 ns 1.00
array/random/rand/Float32 10997 ns 10864 ns 1.01
array/random/rand/Int64 17785 ns 17540 ns 1.01
array/random/rand!/Float32 8257.666666666666 ns 8222.333333333334 ns 1.00
array/random/rand!/Int64 15484 ns 15438 ns 1.00
array/random/randn/Float32 34078 ns 33917 ns 1.00
array/random/randn!/Float32 25264 ns 24950 ns 1.01
array/reductions/mapreduce/Float32/1d 35880 ns 35344 ns 1.02
array/reductions/mapreduce/Float32/dims=1 20340 ns 19440 ns 1.05
array/reductions/mapreduce/Float32/dims=1L 57901 ns 57177 ns 1.01
array/reductions/mapreduce/Float32/dims=2 28606 ns 26865 ns 1.06
array/reductions/mapreduce/Float32/dims=2L 57968 ns 57426 ns 1.01
array/reductions/mapreduce/Int64/1d 36284 ns 35963 ns 1.01
array/reductions/mapreduce/Int64/dims=1 23212 ns 22076 ns 1.05
array/reductions/mapreduce/Int64/dims=1L 97277 ns 96669 ns 1.01
array/reductions/mapreduce/Int64/dims=2 29844 ns 28562 ns 1.04
array/reductions/mapreduce/Int64/dims=2L 84044 ns 82641 ns 1.02
array/reductions/reduce/Float32/1d 35472 ns 35477 ns 1.00
array/reductions/reduce/Float32/dims=1 20638 ns 19590 ns 1.05
array/reductions/reduce/Float32/dims=1L 58237 ns 56900 ns 1.02
array/reductions/reduce/Float32/dims=2 28890 ns 27235 ns 1.06
array/reductions/reduce/Float32/dims=2L 58503 ns 57560 ns 1.02
array/reductions/reduce/Int64/1d 36122 ns 36458 ns 0.99
array/reductions/reduce/Int64/dims=1 23131 ns 21785 ns 1.06
array/reductions/reduce/Int64/dims=1L 97923 ns 96838 ns 1.01
array/reductions/reduce/Int64/dims=2 29733 ns 28069 ns 1.06
array/reductions/reduce/Int64/dims=2L 84525 ns 82996 ns 1.02
array/reverse/1d 19685 ns 19163 ns 1.03
array/reverse/1dL 73557 ns 73140 ns 1.01
array/reverse/1dL_inplace 70143 ns 70001 ns 1.00
array/reverse/1d_inplace 12070 ns 11808 ns 1.02
array/reverse/2d 22795 ns 21957 ns 1.04
array/reverse/2dL 81178 ns 80616 ns 1.01
array/reverse/2dL_inplace 70927 ns 70530 ns 1.01
array/reverse/2d_inplace 14854 ns 14461 ns 1.03
array/sorting/1d 751038 ns 749551 ns 1.00
array/sorting/2d 194450 ns 193577 ns 1.00
array/sorting/by 927915 ns 925685 ns 1.00
cuda/graph/capture 38086 ns 35335 ns 1.08
cuda/graph/eager 33886 ns 33696 ns 1.01
cuda/graph/launch 14053 ns 13916 ns 1.01
cuda/synchronization/context/auto 2456.4444444444443 ns 2327.1111111111113 ns 1.06
cuda/synchronization/context/blocking 908.421052631579 ns 896.9761904761905 ns 1.01
cuda/synchronization/context/nonblocking 8919 ns 10394 ns 0.86
cuda/synchronization/stream/auto 857.9117647058823 ns 869.9464285714286 ns 0.99
cuda/synchronization/stream/blocking 789.2857142857143 ns 774.0733944954128 ns 1.02
cuda/synchronization/stream/nonblocking 8494.666666666666 ns 8489 ns 1.00
integration/byval/reference 147589 ns 147636 ns 1.00
integration/byval/slices=1 148703 ns 148857 ns 1.00
integration/byval/slices=2 290104 ns 290245 ns 1.00
integration/byval/slices=3 432309 ns 432133 ns 1.00
integration/cudadevrt 104994 ns 104872 ns 1.00
integration/volumerhs 9609632 ns 9610189 ns 1.00
kernel/indexing 11486 ns 11356 ns 1.01
kernel/indexing_checked 12048 ns 11875 ns 1.01
kernel/launch 2400.6666666666665 ns 2348.3333333333335 ns 1.02
kernel/occupancy 726.6969696969697 ns 704.8057553956835 ns 1.03
kernel/rand 14867 ns 14971 ns 0.99
latency/import 4087712198 ns 4087629357 ns 1.00
latency/precompile 5044437374 ns 5041187065 ns 1.00
latency/ttfp 4976136576 ns 4978622722 ns 1.00

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

@codecov

codecov Bot commented Oct 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.58%. Comparing base (44ac4eb) to head (337cfd2).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
CUDACore/lib/cudadrv/version.jl 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3440      +/-   ##
==========================================
- Coverage   87.46%   85.58%   -1.89%     
==========================================
  Files         191      191              
  Lines       19646    19469     -177     
==========================================
- Hits        17184    16663     -521     
- Misses       2462     2806     +344     

☔ 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 6c972aa into main Oct 22, 2026
18 checks passed
@maleadt
maleadt deleted the tb/invalidations branch October 22, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

latency Compile time, load time, time-to-first-execution, invalidations.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant