JuliaGPU / JuliaGPU/KernelAbstractions.jl
Unnecessary recompilations using CUDAKernels
- Dominant language
- Julia
- Stars
- 523
- Forks
- 88
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 25
Description
After updating to KernelAbstractions.jl v0.8, I'm seeing a strange repetitive recompilation:
```julia
using CUDA, KernelAbstractions, CUDAKernels
f(x) = x[1]
function test()
v = CuArray(zeros(10))
w = CuArray(zeros(10))
@kernel k(a) = a[@index(Global)] = f(w)
@time wait(k(CUDADevice())(v, ndrange=size(v)) )
end
for _=1:4; test(); end
```
```
1.098917 seconds (3.53 M allocations: 186.034 MiB, 5.01% gc time, 89.45% compilation time)
0.111417 seconds (26.57 k allocations: 2.239 MiB, 31.85% compilation time)
0.119753 seconds (26.62 k allocations: 2.240 MiB, 32.69% compilation time)
0.106870 seconds (26.46 k allocations: 2.238 MiB, 34.30% compilation time)
```
The issue is due to the capture of the `w` local variable that is not passed as a parameter (unlike v).
This is a regression from KernelAbstractions.jl v0.7.2 where this used to work without recompiling:
```
17.077481 seconds (35.42 M allocations: 1.871 GiB, 3.35% gc time, 39.56% compilation time)
0.001077 seconds (91 allocations: 3.609 KiB)
0.001319 seconds (91 allocations: 3.609 KiB)
0.001527 seconds (91 allocations: 3.609 KiB)
```
This issue arose when using Tullio.jl, but there is a way to work around it (https://github.com/mcabbott/Tullio.jl/issues/138), so it is not a big deal (at least for my use case).
I'm totally ok with closing this issue by deeming this as something that just shouldn't be expected to work well.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the provided Julia reproducer with the current KernelAbstractions.jl version and compare it with v0.7.2, focusing on repeated compilation when the kernel captures w rather than receiving it as a parameter. Done means determining whether this regression should be fixed or explicitly documented as unsupported, with the observed recompilation behavior verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100