Skip to content

Commit d9d9cb0

Browse files
yuehhuamaleadt
authored andcommitted
fix bug of conversion of CSR to COO
1 parent 606343e commit d9d9cb0

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

lib/cusparse/extra.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ for (bname,gname,elty) in ((:cusparseScsrgeam2_bufferSizeExt, :cusparseScsrgeam2
3232
return out[]
3333
end
3434

35-
local C
36-
with_workspace(bufferSize) do buffer
37-
function get_nnzC()
35+
C = with_workspace(bufferSize) do buffer
36+
function get_nnzC(buffer)
3837
nnzTotalDevHostPtr = Ref{Cint}(1)
3938
cusparseXcsrgeam2Nnz(handle(), m, n,
4039
descrA, nnz(A), A.rowPtr, A.colVal,
@@ -44,7 +43,7 @@ for (bname,gname,elty) in ((:cusparseScsrgeam2_bufferSizeExt, :cusparseScsrgeam2
4443
return nnzTotalDevHostPtr[]
4544
end
4645

47-
nnzC = get_nnzC()
46+
nnzC = get_nnzC(buffer)
4847
colValC = CuArray{Int32,1}(undef, Int(nnzC))
4948
nzValC = CuArray{$elty,1}(undef, Int(nnzC))
5049

@@ -53,7 +52,7 @@ for (bname,gname,elty) in ((:cusparseScsrgeam2_bufferSizeExt, :cusparseScsrgeam2
5352
beta, descrB, nnz(B), nonzeros(B), B.rowPtr, B.colVal,
5453
descrC, nzValC, rowPtrC, colValC,
5554
buffer)
56-
C = CuSparseMatrixCSR(rowPtrC, colValC, nzValC, (m, n))
55+
return CuSparseMatrixCSR(rowPtrC, colValC, nzValC, (m, n))
5756
end
5857
C
5958
end

test/cusparse/interfaces.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ using LinearAlgebra, SparseArrays
2525
end
2626

2727
@testset "$f(B) $elty" for elty in [Float32, Float64, ComplexF32, ComplexF64],
28-
f in (CuSparseMatrixCSR, CuSparseMatrixCSC, CuSparseMatrixCOO, x->CuSparseMatrixBSR(x,1))
28+
f in (CuSparseMatrixCSR, CuSparseMatrixCSC, x->CuSparseMatrixBSR(x,1))
2929
n = 10
30-
alpha = rand()
31-
beta = rand()
3230
A = sprand(elty, n, n, rand())
3331
B = sprand(elty, n, n, rand())
3432

0 commit comments

Comments
 (0)