Skip to content

Commit b770429

Browse files
Merge branch 'master' into csr-dispatch
2 parents 2224e4b + 4d748fb commit b770429

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

Diff for: lib/cusparse/device.jl

+8
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ end
3434
Base.length(g::CuSparseDeviceMatrixCSC) = prod(g.dims)
3535
Base.size(g::CuSparseDeviceMatrixCSC) = g.dims
3636
SparseArrays.nnz(g::CuSparseDeviceMatrixCSC) = g.nnz
37+
SparseArrays.rowvals(g::CuSparseDeviceMatrixCSC) = g.rowVal
38+
SparseArrays.getcolptr(g::CuSparseDeviceMatrixCSC) = g.colPtr
39+
SparseArrays.getnzval(g::CuSparseDeviceMatrixCSC) = g.nzVal
40+
SparseArrays.nzrange(g::CuSparseDeviceMatrixCSC, col::Integer) = SparseArrays.getcolptr(g)[col]:(SparseArrays.getcolptr(g)[col+1]-1)
3741

3842
struct CuSparseDeviceMatrixCSR{Tv,Ti,A} <: AbstractSparseMatrix{Tv,Ti}
3943
rowPtr::CuDeviceVector{Ti, A}
@@ -46,6 +50,7 @@ end
4650
Base.length(g::CuSparseDeviceMatrixCSR) = prod(g.dims)
4751
Base.size(g::CuSparseDeviceMatrixCSR) = g.dims
4852
SparseArrays.nnz(g::CuSparseDeviceMatrixCSR) = g.nnz
53+
SparseArrays.getnzval(g::CuSparseDeviceMatrixCSR) = g.nzVal
4954

5055
struct CuSparseDeviceMatrixBSR{Tv,Ti,A} <: AbstractSparseMatrix{Tv,Ti}
5156
rowPtr::CuDeviceVector{Ti, A}
@@ -60,6 +65,7 @@ end
6065
Base.length(g::CuSparseDeviceMatrixBSR) = prod(g.dims)
6166
Base.size(g::CuSparseDeviceMatrixBSR) = g.dims
6267
SparseArrays.nnz(g::CuSparseDeviceMatrixBSR) = g.nnz
68+
SparseArrays.getnzval(g::CuSparseDeviceMatrixBSR) = g.nzVal
6369

6470
struct CuSparseDeviceMatrixCOO{Tv,Ti,A} <: AbstractSparseMatrix{Tv,Ti}
6571
rowInd::CuDeviceVector{Ti, A}
@@ -72,6 +78,7 @@ end
7278
Base.length(g::CuSparseDeviceMatrixCOO) = prod(g.dims)
7379
Base.size(g::CuSparseDeviceMatrixCOO) = g.dims
7480
SparseArrays.nnz(g::CuSparseDeviceMatrixCOO) = g.nnz
81+
SparseArrays.getnzval(g::CuSparseDeviceMatrixCOO) = g.nzVal
7582

7683
struct CuSparseDeviceArrayCSR{Tv, Ti, N, M, A} <: AbstractSparseArray{Tv, Ti, N}
7784
rowPtr::CuDeviceArray{Ti, M, A}
@@ -89,6 +96,7 @@ end
8996
Base.length(g::CuSparseDeviceArrayCSR) = prod(g.dims)
9097
Base.size(g::CuSparseDeviceArrayCSR) = g.dims
9198
SparseArrays.nnz(g::CuSparseDeviceArrayCSR) = g.nnz
99+
SparseArrays.getnzval(g::CuSparseDeviceArrayCSR) = g.nzVal
92100

93101
# input/output
94102

Diff for: test/libraries/cusparse/device.jl

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@ using CUDA.CUSPARSE: CuSparseDeviceVector, CuSparseDeviceMatrixCSC, CuSparseDevi
44
CuSparseDeviceMatrixBSR, CuSparseDeviceMatrixCOO
55

66
@testset "cudaconvert" begin
7-
@test isbitstype(CuSparseDeviceVector{Float32, Cint, CUDA.AS.Global})
8-
@test isbitstype(CuSparseDeviceMatrixCSC{Float32, Cint, CUDA.AS.Global})
9-
@test isbitstype(CuSparseDeviceMatrixCSR{Float32, Cint, CUDA.AS.Global})
10-
@test isbitstype(CuSparseDeviceMatrixBSR{Float32, Cint, CUDA.AS.Global})
11-
@test isbitstype(CuSparseDeviceMatrixCOO{Float32, Cint, CUDA.AS.Global})
7+
@test isbitstype(CuSparseDeviceVector{Float32, Cint, AS.Global})
8+
@test isbitstype(CuSparseDeviceMatrixCSC{Float32, Cint, AS.Global})
9+
@test isbitstype(CuSparseDeviceMatrixCSR{Float32, Cint, AS.Global})
10+
@test isbitstype(CuSparseDeviceMatrixBSR{Float32, Cint, AS.Global})
11+
@test isbitstype(CuSparseDeviceMatrixCOO{Float32, Cint, AS.Global})
1212

1313
V = sprand(10, 0.5)
1414
cuV = CuSparseVector(V)
15-
@test cudaconvert(cuV) isa CuSparseDeviceVector{Float64, Cint, 1}
15+
@test cudaconvert(cuV) isa CuSparseDeviceVector{Float64, Cint, AS.Global}
1616

1717
A = sprand(10, 10, 0.5)
1818
cuA = CuSparseMatrixCSC(A)
19-
@test cudaconvert(cuA) isa CuSparseDeviceMatrixCSC{Float64, Cint, 1}
19+
@test cudaconvert(cuA) isa CuSparseDeviceMatrixCSC{Float64, Cint, AS.Global}
2020

2121
cuA = CuSparseMatrixCSR(A)
22-
@test cudaconvert(cuA) isa CuSparseDeviceMatrixCSR{Float64, Cint, 1}
22+
@test cudaconvert(cuA) isa CuSparseDeviceMatrixCSR{Float64, Cint, AS.Global}
2323

2424
cuA = CuSparseMatrixCOO(A)
25-
@test cudaconvert(cuA) isa CuSparseDeviceMatrixCOO{Float64, Cint, 1}
25+
@test cudaconvert(cuA) isa CuSparseDeviceMatrixCOO{Float64, Cint, AS.Global}
2626

2727
cuA = CuSparseMatrixBSR(A, 2)
28-
@test cudaconvert(cuA) isa CuSparseDeviceMatrixBSR
28+
@test cudaconvert(cuA) isa CuSparseDeviceMatrixBSR{Float64, Cint, AS.Global}
2929
end

0 commit comments

Comments
 (0)