JuliaGPU / JuliaGPU/KernelAbstractions.jl
Methods for GPU not properly invalidated upon redefinition
- Dominant language
- Julia
- Stars
- 523
- Forks
- 88
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 25
Description
It seems like methods aren't properly invalidated on GPU when redefined. Example (due to the async printing, it looks weird so you'll just have to take my comments as truth or try it out yourself):
```julia
julia> using CUDA, KernelAbstractions, CUDAKernels
julia> @kernel function test_kernel()
@print("hi")
end
test_kernel (generic function with 5 methods)
julia> k = test_kernel(CUDADevice(), 1, 1); wait(k()); # prints "hi" (✓)
julia> k = test_kernel(CPU(), 1, 1); wait(k()); # prints "hi" (✓)
julia> @kernel function test_kernel() # <= NOTE: does not return a method like above? Related to issue at hand maybe?
@print("bye")
end
julia> k = test_kernel(CUDADevice(), 1, 1); k(); # prints "hi" (×)
julia> k = test_kernel(CPU(), 1, 1); k(); # prints "bye" (✓)
```
This is with
- CUDA v3.2
- KernelAbstractions v0.6.2
Btw, this "caused" the issue of the if-statement that I mentioned on Slack: I first defined the method using `Δ isa CuArray` (always false), rather than `CuDeviceArray` (obtain desired behavior), then when I changed the if-statement and re-evaluated, I got the same behavior. When using a fresh session and `CuDeviceArray` in the first definition of the method, it worked just fine:)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the example with Julia, CUDA v3.2, and KernelAbstractions v0.6.2, comparing the CUDA and CPU results after redefining test_kernel. Investigate the method invalidation path used by the @kernel definition; done means the redefined CUDA method uses the new body rather than the previously compiled one.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- hpc
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100