Open
Description
When KA is used with CUDABackend, it throws an error when the array is empty. MWE here:
using KernelAbstractions, CUDA
@kernel function add1(I)
i = @index(Global)
I[i] += 1
end
a = zeros(0)
add1(CPU())(a; ndrange = length(a)) # ok
a = CUDA.zeros(0)
add1(CUDABackend())(a; ndrange = length(a)) # throws an error
This is the stack trace:
ERROR: DivideError: integer division error
Stacktrace:
[1] div
@ ./int.jl:295 [inlined]
[2] div
@ ./div.jl:310 [inlined]
[3] div
@ ./div.jl:355 [inlined]
[4] fld
@ ./div.jl:321 [inlined]
[5] mod
@ ./int.jl:287 [inlined]
[6] JuliaGPU/KernelAbstractions.jl#4
@ ~/.julia/packages/KernelAbstractions/zPAn3/src/nditeration.jl:121 [inlined]
[7] ntuple
@ ./ntuple.jl:48 [inlined]
[8] partition
@ ~/.julia/packages/KernelAbstractions/zPAn3/src/nditeration.jl:119 [inlined]
[9] partition
@ ~/.julia/packages/KernelAbstractions/zPAn3/src/KernelAbstractions.jl:628 [inlined]
[10] launch_config
@ ~/git/CUDA.jl/src/CUDAKernels.jl:88 [inlined]
[11] (::KernelAbstractions.Kernel{…})(args::CuArray{…}; ndrange::Int64, workgroupsize::Nothing)
@ CUDA.CUDAKernels ~/git/CUDA.jl/src/CUDAKernels.jl:108
[12] top-level scope
@ REPL[10]:12
[13] top-level scope
@ ~/git/CUDA.jl/src/initialization.jl:206
Some type information was truncated. Use `show(err)` to see complete types.
Currently, I'm on julia v1.10.2
and
[052768ef] CUDA v5.1.2
[63c18a36] KernelAbstractions v0.9.18