Skip to content

Calling a launch=false kernel with host arrays fails #398

Backlog

Description

@maleadt

CUDACore documents that a kernel returned by @cuda launch=false "should be launched by calling it and passing arguments again. That later call converts the supplied host arguments independently", and CUDA.jl's own kernels do. A cuTile kernel doesn't convert them:

using CUDA, cuTile
import cuTile as ct
function copy_tiles(dst, src)
    i = ct.bid(1)
    ct.store(dst, i, ct.load(src, i, (256,)))
    return
end
a = CUDA.rand(Float32, 1024); b = CUDA.zeros(Float32, 1024)
k = @cuda backend=cuTile launch=false copy_tiles(b, a)
k(b, a; blocks=4)
# ERROR: ArgumentError: type does not have a definite number of fields

(::TileKernel)(args...) takes its arguments as already converted (k(ct.cuTileconvert(b), ct.cuTileconvert(a); blocks=4) works), and flattening a CuArray as a kernel parameter fails with the error above.

A fix should convert host arguments as @cuda does, including recording their memory so that the launch is ordered on its stream (#396), while kernel_launch(kernel, call) keeps reusing a KernelCall's converted arguments. A related gap: arrays captured by the kernel function are converted when the launch=false kernel is made, so a later call neither acquires their memory on its stream nor keeps them alive.

Found on main (c40493e), Julia 1.13.4, CUDACore 6.5.1.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions