CUSPARSE: in-place copy from CuSparseCSC to SparseCSC
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 1.4k
- Forks
- 281
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 30
Description
Hi guys,
i am trying to use copyto! from device -> host
P=ilu02(A_gpu);
the type 115788×115788 CuSparseMatrixCSC{ComplexF64, Int32} with 462440 stored entries
now I will create the host sparse matrix and initialize it :
m = 115788 # number of rows
n = 115788 # number of columns
T = ComplexF64 # element type
ii = Int32 # index type
a = sparse(Vector{ii}(), Vector{ii}(), Vector{T}(), m, n)
the type of a matrix :115788×115788 SparseMatrixCSC{ComplexF64, Int32} with 0 stored entries
copyto!(a,P)
ERROR: Scalar indexing is disallowed.
Invocation of getindex resulted in scalar indexing of a GPU array.
This is typically caused by calling an iterating implementation of a method.
Such implementations *do not* execute on the GPU, but very slowly on the CPU,
and therefore are only permitted from the REPL for prototyping purposes.
If you did intend to index this array, annotate the caller with @allowscalar.
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:35
[2] assertscalar(op::String)
@ GPUArraysCore C:\Users\ahmad\.julia\packages\GPUArraysCore\uOYfN\src\GPUArraysCore.jl:103
[3] getindex(xs::CuArray{Int32, 1, CUDA.Mem.DeviceBuffer}, I::Int64)
@ GPUArrays C:\Users\ahmad\.julia\packages\GPUArrays\t0LfC\src\host\indexing.jl:9
[4] getindex(A::CuSparseMatrixCSC{ComplexF64, Int32}, i0::Int64, i1::Int64)
@ CUDA.CUSPARSE C:\Users\ahmad\.julia\packages\CUDA\pCcGc\lib\cusparse\array.jl:310
[5] _getindex
@ .\abstractarray.jl:1344 [inlined]
[6] getindex
@ .\abstractarray.jl:1294 [inlined]
[7] copyto_unaliased!(deststyle::IndexCartesian, dest::SparseMatrixCSC{ComplexF64, Int32}, srcstyle::IndexCartesian, src::CuSparseMatrixCSC{ComplexF64, Int32})
@ Base .\abstractarray.jl:1105
[8] copyto!(dest::SparseMatrixCSC{ComplexF64, Int32}, src::CuSparseMatrixCSC{ComplexF64, Int32})
@ Base .\abstractarray.jl:1071
[9] top-level scope
@ Untitled-2:41
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the failing copyto! reproduction in the issue and inspect CUDA.CUSPARSE array.jl around the getindex implementation at line 310, along with the Base copyto! path shown in the stack trace. Confirm that copying a CuSparseMatrixCSC into a SparseMatrixCSC completes without scalar GPU indexing and preserves the sparse matrix contents.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100