JuliaGPU / JuliaGPU/GPUArrays.jl
(Direct) Constructors for sparse CSC, CSR and BSR arrays
- Dominant language
- Julia
- Stars
- 450
- Forks
- 104
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 10
Description
Hello, I think it would be very helpful to add constructors to the generic GPU sparse arrays interface for building sparse matrices directly from index/value GPU vectors, bypassing the COO path used by `sparse`. This would enable packages to precompute the structure and values and construct sparse matrices efficiently across backends.
I was imaging something like:
```julia
# in GPUArrays.jl
export GPUSparseMatrixCSC, ...
function GPUSparseMatrixCSC end
# same for other formats
# in JLArrays.jl
GPUSparseMatrix{Tv, Ti}(rowPtr::JLArray, colVal::JLArray, nzVal::JLArray, dims) = JLSparseMatrixCSC{Tv, Ti}(rowPtr, colVal, nzVal, dims)
# in CUDA.jl
GPUSparseMatrix{Tv, Ti}(rowPtr::CuArray, colVal::CuArray, nzVal::CuArray, dims) = CuSparseMatrixCSC{Tv, Ti}(rowPtr, colVal, nzVal, dims)
# and so on in the other backends
```
One issue is that the arguments might differ between backends or have different requirements on their values(see #648). I think in this case, the formats are so specific though, that the implementations will likely just differ in the types of their vectors.
An example use case can [be seen here](https://github.com/JuliaMath/NFFT.jl/blob/8734f90d894d7875a996776523adb68d710c87fc/ext/NFFTGPUArraysExt/precomputation.jl#L46), where in initial tests the overhead of the COO format negates performance gains over the CPU implementation.
I'm not sure if I fully understand the relationship between `AbstractGPUSparseMatrices` and `GPUSparseDeviceVector` yet and if it would make sense to provide a default implementation for the constructor which defaults to reference to the corresponding default vector.
If this or another version of such a constructor seems sensible, I'd be happy to make PRs
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.