JuliaGPU / JuliaGPU/GPUArrays.jl
Indexing (Cartesian or Linear) isn't defined for sparse device arrays
- Dominant language
- Julia
- Stars
- 450
- Forks
- 104
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 10
Description
Indexing a CUDA.CUSPARSE with brackets inside a CUDA.jl kernel triggers a `error_if_canonical_getindex` Error. The following reproduces the bug:
```julia
using CUDA, SparseArrays
src_mwe = cu(ones(Float32, 2, 5))
dst_mwe = cu([1, 2, 3, 4, 5])
function mwe_kernel!(dst, src)
index = threadIdx().x + (blockIdx().x - 1) * blockDim().x
dst[index] = src[1, index]
return nothing
end
kernel = @cuda launch=false mwe_kernel!(dst_mwe, sparse(src_mwe, fmt=:csc))
kernel(dst_mwe, sparse(src_mwe, fmt=:csc); threads=length(dst_mwe), blocks=1)
julia> ERROR: a exception was thrown during kernel execution on thread (1, 1, 1) in block (1, 1, 1).
Stacktrace:
[1] error_if_canonical_getindex at ./abstractarray.jl:1357
[2] getindex at ./abstractarray.jl:1341
[3] _getindex at ./abstractarray.jl:1383
[4] getindex at ./abstractarray.jl:1342
[5] mwe_kernel! at ./REPL[11]:3
```
The fix is to implement indexing functionality for the given array types in `src/device/sparse.jl`
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.