You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The lack of specialized getindex methods for GPUSparseDeviceMatrixCSC makes it so that we cannot index into it (the previous CuSparseDeviceMatrixCSC could). As a consequence, we also cannot index into GPUSparseDeviceColumnView. I understand that it is not the most efficient as we need to perform a binary search, but in my use case, it is the only option.
MWE in terms of GPUSparseDeviceColumnView
using CUDA, SparseArrays
A =sprand(10, 10, 0.4)
A_gpu =cu(A)
a_gpu =@view A_gpu[:, 1]
functionkernel(out, a)
acc =0.0
i =1while i <=length(a)
acc += a[i]
i +=1end
out[1] = acc
returnnothingend
out = CUDA.zeros(1)
@cudakernel(out, a_gpu)
The kernel can equivalently be written as the following (subarray.jl:313).
functionkernel(out, a)
acc =0.0
i =1while i <=length(a)
index = Base.reindex(a.indices, (i,))
v = a.parent[index...]
acc += v
i +=1end
out[1] = acc
returnnothingend
In this case, it succeeds with reindexing, i.e. to find the index within the parent (A_gpu), but since GPUSparseDeviceMatrixCSC lacks appropriate indexing methods, it fails with the error message (under julia with option -g2).
index: (1, 1)
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] kernel at ./REPL[7]:6
Duplicate of #694: the device-side sparse matrices have no getindex, and the column view only fails because indexing its CSC parent does. #699 implements it.
Activity
kshyatt commentedon Aug 16, 2026
Can repro, I'll try to fix
kshyatt commentedon Aug 16, 2026
Looks like this was missing on the old CUDA versions too, shouldn't be too hard to add though
maleadt commentedon Oct 19, 2026
Duplicate of #694: the device-side sparse matrices have no
getindex, and the column view only fails because indexing its CSC parent does. #699 implements it.