Skip to content

Precompile common operations in the CUDA extension - #196

Open
maleadt wants to merge 1 commit into
mainfrom
tb/cuda-workload
Open

maleadt wants to merge 1 commit into
mainfrom
tb/cuda-workload

Conversation

@maleadt

@maleadt maleadt commented Oct 28, 2026

Copy link
Copy Markdown
Member

CUDACore's precompilation workload doesn't use the GPU, so the first reduction, scan or predicate of a session compiles AcceleratedKernels' host code and kernels. CUDACore couldn't cache them for the tunings this extension sets anyway, since the extension isn't loaded while CUDACore precompiles.

This runs them in a workload of the extension when CUDA is functional while precompiling, on arrays just large enough to select the kernels that a vector of 10^6 elements and a 1000×1000 matrix do (checked by recording the kernels compiled at both sizes). Like CUDACore's own workload it needs Julia 1.12; without a GPU it is skipped, and a failure while running it fails precompilation rather than being hidden.

On an RTX 5080 with Julia 1.13, together with JuliaGPU/CUDA.jl#3493, the first sum of 10^6 elements takes 6 ms instead of 1.1 s, cumsum 0.18 instead of 1.6 s, any and all 55 ms instead of 1.2 s, and sum along either dimension of a 1000×1000 matrix 0.52 instead of 1.6 s. Without #3493, loading CUDACore's KernelAbstractions extension invalidates part of this code and these still take 0.6 to 1 s, so this should go in after it. The extension's image grows from 0.03 to 11 MB and its precompilation from 1.6 to 5 s; load time doesn't change measurably. What the dims reductions and cumsum still compile is code that is only inferred, without native code, in upstream package images (JuliaLang/julia#58465).

CUDACore's workload doesn't use the GPU, so the first reduction, scan or
predicate of a session compiles AcceleratedKernels' host code and
kernels. CUDACore couldn't cache them for the tunings set here anyway,
as this extension isn't loaded while CUDACore precompiles.

Run them in a workload of this extension when CUDA is functional while
precompiling, on arrays just large enough to select the kernels that a
vector of 10^6 elements and a 1000×1000 matrix do. Like CUDACore's own
workload, it needs Julia 1.12.

On an RTX 5080 with Julia 1.13, and CUDA.jl's KernelAbstractions methods
moved into CUDACore (JuliaGPU/CUDA.jl#3493), the first `sum` of 10^6
elements takes 6 ms instead of 1.1 s, `cumsum` 0.18 s instead of 1.6 s,
`any` and `all` 55 ms instead of 1.2 s, and `sum` along either dimension
of a 1000×1000 matrix 0.52 s instead of 1.6 s. Without that change,
loading CUDACore's KernelAbstractions extension invalidates part of this
code, and these take 0.6 to 1 s. The extension's image grows from 0.03
to 11 MB, and its precompilation from 1.6 to 5 s.

This branch has not been deployed

No deployments
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