Skip to content

Methods for GPU not properly invalidated upon redefinition #250

Open
@torfjelde

Description

@torfjelde

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> 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:)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions