Skip to content

Commit a101ecd

Browse files
committed
More work CUSPARSE tests
1 parent 43d88b0 commit a101ecd

File tree

8 files changed

+92
-238
lines changed

8 files changed

+92
-238
lines changed

lib/cusparse/CUSPARSE.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ include("generic.jl")
4747
# high-level integrations
4848
include("interfaces.jl")
4949

50-
# native functionality
51-
include("device.jl")
52-
5350
include("batched.jl")
5451

5552

lib/cusparse/array.jl

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export CuSparseMatrixCSC, CuSparseMatrixCSR, CuSparseMatrixBSR, CuSparseMatrixCO
99

1010
using LinearAlgebra: BlasFloat
1111
using SparseArrays
12-
using SparseArrays: nonzeroinds, nonzeros, rowvals, getcolptr
12+
using SparseArrays: nonzeroinds, nonzeros, rowvals, getcolptr, dimlub
1313
abstract type AbstractCuSparseVector{Tv, Ti} <: GPUArrays.AbstractGPUSparseArray{Tv, Ti, 1} end
1414
abstract type AbstractCuSparseMatrix{Tv, Ti} <: GPUArrays.AbstractGPUSparseArray{Tv, Ti, 2} end
1515

@@ -43,6 +43,7 @@ mutable struct CuSparseMatrixCSC{Tv, Ti} <: GPUArrays.AbstractGPUSparseMatrixCSC
4343
new{Tv, Ti}(colPtr, rowVal, nzVal, dims, length(nzVal))
4444
end
4545
end
46+
CuSparseMatrixCSC{Tv, Ti}(csc::CuSparseMatrixCSC{Tv, Ti}) where {Tv, Ti} = csc
4647

4748
SparseArrays.rowvals(g::T) where {T<:CuSparseVector} = nonzeroinds(g)
4849

@@ -84,6 +85,7 @@ mutable struct CuSparseMatrixCSR{Tv, Ti} <: GPUArrays.AbstractGPUSparseMatrixCSR
8485
end
8586
end
8687

88+
CuSparseMatrixCSR{Tv, Ti}(csr::CuSparseMatrixCSR{Tv, Ti}) where {Tv, Ti} = csr
8789
CuSparseMatrixCSR(A::CuSparseMatrixCSR) = A
8890

8991
function CUDA.unsafe_free!(xs::CuSparseMatrixCSR)
@@ -108,6 +110,10 @@ GPUArrays._dense_array_type(::Type{<:CuSparseMatrixCSR}) = CuArray
108110

109111
GPUArrays._csc_type(sa::CuSparseMatrixCSR) = CuSparseMatrixCSC
110112
GPUArrays._csr_type(sa::CuSparseMatrixCSC) = CuSparseMatrixCSR
113+
GPUArrays._coo_type(sa::Union{CuSparseMatrixCSR, Transpose{<:Any,<:CuSparseMatrixCSR}, Adjoint{<:Any,<:CuSparseMatrixCSR}}) = CuSparseMatrixCOO
114+
GPUArrays._coo_type(sa::Union{CuSparseMatrixCSC, Transpose{<:Any,<:CuSparseMatrixCSC}, Adjoint{<:Any,<:CuSparseMatrixCSC}}) = CuSparseMatrixCOO
115+
GPUArrays._coo_type(::Type{T}) where {T<:Union{CuSparseMatrixCSR, Transpose{<:Any,<:CuSparseMatrixCSR}, Adjoint{<:Any,<:CuSparseMatrixCSR}}} = CuSparseMatrixCOO
116+
GPUArrays._coo_type(::Type{T}) where {T<:Union{CuSparseMatrixCSC, Transpose{<:Any,<:CuSparseMatrixCSC}, Adjoint{<:Any,<:CuSparseMatrixCSC}}} = CuSparseMatrixCOO
111117

112118
"""
113119
Container to hold sparse matrices in block compressed sparse row (BSR) format on
@@ -326,21 +332,6 @@ end
326332

327333
## sparse array interface
328334

329-
function SparseArrays.findnz(S::MT) where {MT <: AbstractCuSparseMatrix}
330-
S2 = CuSparseMatrixCOO(S)
331-
I = S2.rowInd
332-
J = S2.colInd
333-
V = S2.nzVal
334-
335-
# To make it compatible with the SparseArrays.jl version
336-
idxs = sortperm(J)
337-
I = I[idxs]
338-
J = J[idxs]
339-
V = V[idxs]
340-
341-
return (I, J, V)
342-
end
343-
344335
function SparseArrays.sparsevec(I::CuArray{Ti}, V::CuArray{Tv}, n::Integer) where {Ti,Tv}
345336
CuSparseVector(I, V, n)
346337
end
@@ -396,16 +387,6 @@ function _cuda_spdiagm_internal(kv::Pair{T,<:CuVector}...) where {T<:Integer}
396387
return I, J, V, m, n
397388
end
398389

399-
LinearAlgebra.issymmetric(M::Union{CuSparseMatrixCSC,CuSparseMatrixCSR}) = size(M, 1) == size(M, 2) ? norm(M - transpose(M), Inf) == 0 : false
400-
LinearAlgebra.ishermitian(M::Union{CuSparseMatrixCSC,CuSparseMatrixCSR}) = size(M, 1) == size(M, 2) ? norm(M - adjoint(M), Inf) == 0 : false
401-
402-
LinearAlgebra.istriu(M::UpperTriangular{T,S}) where {T<:BlasFloat, S<:Union{<:AbstractCuSparseMatrix, Adjoint{<:Any, <:AbstractCuSparseMatrix}, Transpose{<:Any, <:AbstractCuSparseMatrix}}} = true
403-
LinearAlgebra.istril(M::UpperTriangular{T,S}) where {T<:BlasFloat, S<:Union{<:AbstractCuSparseMatrix, Adjoint{<:Any, <:AbstractCuSparseMatrix}, Transpose{<:Any, <:AbstractCuSparseMatrix}}} = false
404-
LinearAlgebra.istriu(M::LowerTriangular{T,S}) where {T<:BlasFloat, S<:Union{<:AbstractCuSparseMatrix, Adjoint{<:Any, <:AbstractCuSparseMatrix}, Transpose{<:Any, <:AbstractCuSparseMatrix}}} = false
405-
LinearAlgebra.istril(M::LowerTriangular{T,S}) where {T<:BlasFloat, S<:Union{<:AbstractCuSparseMatrix, Adjoint{<:Any, <:AbstractCuSparseMatrix}, Transpose{<:Any, <:AbstractCuSparseMatrix}}} = true
406-
407-
Hermitian{T}(Mat::CuSparseMatrix{T}) where {T} = Hermitian{eltype(Mat),typeof(Mat)}(Mat,'U')
408-
409390
SparseArrays.nnz(g::CuSparseMatrixBSR) = g.nnzb * g.blockDim * g.blockDim
410391

411392

@@ -550,6 +531,7 @@ CuSparseMatrixCSR{T}(Mat::Adjoint{Tv, <:SparseMatrixCSC}) where {T, Tv} =
550531
CuVector{T}(conj.(parent(Mat).nzval)), size(Mat))
551532
CuSparseMatrixCSC{T}(Mat::Union{Transpose{Tv, <:SparseMatrixCSC}, Adjoint{Tv, <:SparseMatrixCSC}}) where {T, Tv} = CuSparseMatrixCSC(CuSparseMatrixCSR{T}(Mat))
552533
CuSparseMatrixCSR{T}(Mat::SparseMatrixCSC) where {T} = CuSparseMatrixCSR(CuSparseMatrixCSC{T}(Mat))
534+
CuSparseMatrixCSR{Tv, Ti}(Mat::SparseMatrixCSC) where {Tv, Ti} = CuSparseMatrixCSR(CuSparseMatrixCSC{Tv}(Mat))
553535
CuSparseMatrixBSR{T}(Mat::SparseMatrixCSC, blockdim) where {T} = CuSparseMatrixBSR(CuSparseMatrixCSR{T}(Mat), blockdim)
554536
CuSparseMatrixCOO{T}(Mat::SparseMatrixCSC) where {T} = CuSparseMatrixCOO(CuSparseMatrixCSR{T}(Mat))
555537

@@ -571,12 +553,12 @@ CuSparseMatrixCSC(x::Adjoint{T}) where {T} = CuSparseMatrixCSC{T}(x)
571553
CuSparseMatrixCOO(x::Transpose{T}) where {T} = CuSparseMatrixCOO{T}(x)
572554
CuSparseMatrixCOO(x::Adjoint{T}) where {T} = CuSparseMatrixCOO{T}(x)
573555

574-
CuSparseMatrixCSR(x::Transpose{T,<:Union{CuSparseMatrixCSC, CuSparseMatrixCSR, CuSparseMatrixCOO}}) where {T} = CuSparseMatrixCSR(_sptranspose(parent(x)))
575-
CuSparseMatrixCSC(x::Transpose{T,<:Union{CuSparseMatrixCSC, CuSparseMatrixCSR, CuSparseMatrixCOO}}) where {T} = CuSparseMatrixCSC(_sptranspose(parent(x)))
576-
CuSparseMatrixCOO(x::Transpose{T,<:Union{CuSparseMatrixCSC, CuSparseMatrixCSR, CuSparseMatrixCOO}}) where {T} = CuSparseMatrixCOO(_sptranspose(parent(x)))
577-
CuSparseMatrixCSR(x::Adjoint{T,<:Union{CuSparseMatrixCSC, CuSparseMatrixCSR, CuSparseMatrixCOO}}) where {T} = CuSparseMatrixCSR(_spadjoint(parent(x)))
578-
CuSparseMatrixCSC(x::Adjoint{T,<:Union{CuSparseMatrixCSC, CuSparseMatrixCSR, CuSparseMatrixCOO}}) where {T} = CuSparseMatrixCSC(_spadjoint(parent(x)))
579-
CuSparseMatrixCOO(x::Adjoint{T,<:Union{CuSparseMatrixCSC, CuSparseMatrixCSR, CuSparseMatrixCOO}}) where {T} = CuSparseMatrixCOO(_spadjoint(parent(x)))
556+
CuSparseMatrixCSR(x::Transpose{T,<:Union{CuSparseMatrixCSC, CuSparseMatrixCSR, CuSparseMatrixCOO}}) where {T} = CuSparseMatrixCSR(GPUArrays._sptranspose(parent(x)))
557+
CuSparseMatrixCSC(x::Transpose{T,<:Union{CuSparseMatrixCSC, CuSparseMatrixCSR, CuSparseMatrixCOO}}) where {T} = CuSparseMatrixCSC(GPUArrays._sptranspose(parent(x)))
558+
CuSparseMatrixCOO(x::Transpose{T,<:Union{CuSparseMatrixCSC, CuSparseMatrixCSR, CuSparseMatrixCOO}}) where {T} = CuSparseMatrixCOO(GPUArrays._sptranspose(parent(x)))
559+
CuSparseMatrixCSR(x::Adjoint{T,<:Union{CuSparseMatrixCSC, CuSparseMatrixCSR, CuSparseMatrixCOO}}) where {T} = CuSparseMatrixCSR(GPUArrays._spadjoint(parent(x)))
560+
CuSparseMatrixCSC(x::Adjoint{T,<:Union{CuSparseMatrixCSC, CuSparseMatrixCSR, CuSparseMatrixCOO}}) where {T} = CuSparseMatrixCSC(GPUArrays._spadjoint(parent(x)))
561+
CuSparseMatrixCOO(x::Adjoint{T,<:Union{CuSparseMatrixCSC, CuSparseMatrixCSR, CuSparseMatrixCOO}}) where {T} = CuSparseMatrixCOO(GPUArrays._spadjoint(parent(x)))
580562

581563
# gpu to cpu
582564
SparseArrays.SparseVector(x::CuSparseVector) = SparseVector(length(x), Array(SparseArrays.nonzeroinds(x)), Array(SparseArrays.nonzeros(x)))
@@ -592,6 +574,12 @@ Base.collect(x::CuSparseMatrixCSR) = collect(SparseMatrixCSC(x))
592574
Base.collect(x::CuSparseMatrixBSR) = collect(SparseMatrixCSC(x))
593575
Base.collect(x::CuSparseMatrixCOO) = collect(SparseMatrixCSC(x))
594576

577+
Base.Array(x::CuSparseVector) = collect(SparseVector(x))
578+
Base.Array(x::CuSparseMatrixCSC) = collect(SparseMatrixCSC(x))
579+
Base.Array(x::CuSparseMatrixCSR) = collect(SparseMatrixCSC(x))
580+
Base.Array(x::CuSparseMatrixBSR) = collect(SparseMatrixCSC(x))
581+
Base.Array(x::CuSparseMatrixCOO) = collect(SparseMatrixCSC(x))
582+
595583
Adapt.adapt_storage(::Type{CuArray}, xs::SparseVector) = CuSparseVector(xs)
596584
Adapt.adapt_storage(::Type{CuArray}, xs::SparseMatrixCSC) = CuSparseMatrixCSC(xs)
597585
Adapt.adapt_storage(::Type{CuArray{T}}, xs::SparseVector) where {T} = CuSparseVector{T}(xs)
@@ -787,6 +775,16 @@ function Adapt.adapt_structure(to::CUDA.KernelAdaptor, x::CuSparseMatrixCSC)
787775
)
788776
end
789777

778+
function GPUArrays.GPUSparseDeviceMatrixBSR(rowPtr::CuDeviceVector{Ti, A},
779+
colVal::CuDeviceVector{Ti, A},
780+
nzVal::CuDeviceVector{Tv, A},
781+
dims::NTuple{2, Int},
782+
blockDim::Ti,
783+
dir::Char,
784+
nnz::Ti) where {Ti, Tv, A}
785+
GPUArrays.GPUSparseDeviceMatrixBSR{Tv, Ti, CuDeviceVector{Ti, A}, CuDeviceVector{Tv, A}, A}(rowPtr, colVal, nzVal, dims, blockDim, dir, nnz)
786+
end
787+
790788
function Adapt.adapt_structure(to::CUDA.KernelAdaptor, x::CuSparseMatrixBSR)
791789
return GPUArrays.GPUSparseDeviceMatrixBSR(
792790
adapt(to, x.rowPtr),
@@ -797,6 +795,14 @@ function Adapt.adapt_structure(to::CUDA.KernelAdaptor, x::CuSparseMatrixBSR)
797795
)
798796
end
799797

798+
function GPUArrays.GPUSparseDeviceMatrixCOO(rowInd::CuDeviceVector{Ti, A},
799+
colInd::CuDeviceVector{Ti, A},
800+
nzVal::CuDeviceVector{Tv, A},
801+
dims::NTuple{2, Int},
802+
nnz::Ti) where {Ti, Tv, A}
803+
GPUArrays.GPUSparseDeviceMatrixCOO{Tv, Ti, CuDeviceVector{Ti, A}, CuDeviceVector{Tv, A}, A}(rowInd, colInd, nzVal, dims, nnz)
804+
end
805+
800806
function Adapt.adapt_structure(to::CUDA.KernelAdaptor, x::CuSparseMatrixCOO)
801807
return GPUArrays.GPUSparseDeviceMatrixCOO(
802808
adapt(to, x.rowInd),

lib/cusparse/conversions.jl

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export sort_csc, sort_csr, sort_coo
22

33
adjtrans_wrappers = ((identity, identity),
4-
(M -> :(Transpose{T, <:$M}), M -> :(_sptranspose(parent($M)))),
5-
(M -> :(Adjoint{T, <:$M}), M -> :(_spadjoint(parent($M)))))
4+
(M -> :(Transpose{T, <:$M}), M -> :(GPUArrays._sptranspose(parent($M)))),
5+
(M -> :(Adjoint{T, <:$M}), M -> :(GPUArrays._spadjoint(parent($M)))))
66

77
# conversion routines between different sparse and dense storage formats
88

@@ -330,7 +330,7 @@ end
330330
# by flipping rows and columns, we can use that to get CSC to CSR too
331331
for elty in (:Float32, :Float64, :ComplexF32, :ComplexF64)
332332
@eval begin
333-
function CuSparseMatrixCSC{$elty}(csr::CuSparseMatrixCSR{$elty}; index::SparseChar='O', action::cusparseAction_t=CUSPARSE_ACTION_NUMERIC, algo::cusparseCsr2CscAlg_t=CUSPARSE_CSR2CSC_ALG1)
333+
function CuSparseMatrixCSC{$elty, Cint}(csr::CuSparseMatrixCSR{$elty, Cint}; index::SparseChar='O', action::cusparseAction_t=CUSPARSE_ACTION_NUMERIC, algo::cusparseCsr2CscAlg_t=CUSPARSE_CSR2CSC_ALG1)
334334
m,n = size(csr)
335335
colPtr = CUDA.zeros(Cint, n+1)
336336
rowVal = CUDA.zeros(Cint, nnz(csr))
@@ -349,8 +349,9 @@ for elty in (:Float32, :Float64, :ComplexF32, :ComplexF64)
349349
end
350350
CuSparseMatrixCSC(colPtr,rowVal,nzVal,size(csr))
351351
end
352-
353-
function CuSparseMatrixCSR{$elty}(csc::CuSparseMatrixCSC{$elty}; index::SparseChar='O', action::cusparseAction_t=CUSPARSE_ACTION_NUMERIC, algo::cusparseCsr2CscAlg_t=CUSPARSE_CSR2CSC_ALG1)
352+
CuSparseMatrixCSC{$elty}(csr::CuSparseMatrixCSR{$elty, Cint}; index::SparseChar='O', action::cusparseAction_t=CUSPARSE_ACTION_NUMERIC, algo::cusparseCsr2CscAlg_t=CUSPARSE_CSR2CSC_ALG1) =
353+
CuSparseMatrixCSC{$elty, Cint}(csr; index=index, action=action, algo=algo)
354+
function CuSparseMatrixCSR{$elty, Cint}(csc::CuSparseMatrixCSC{$elty, Cint}; index::SparseChar='O', action::cusparseAction_t=CUSPARSE_ACTION_NUMERIC, algo::cusparseCsr2CscAlg_t=CUSPARSE_CSR2CSC_ALG1)
354355
m,n = size(csc)
355356
rowPtr = CUDA.zeros(Cint,m+1)
356357
colVal = CUDA.zeros(Cint,nnz(csc))
@@ -369,6 +370,8 @@ for elty in (:Float32, :Float64, :ComplexF32, :ComplexF64)
369370
end
370371
CuSparseMatrixCSR(rowPtr,colVal,nzVal,size(csc))
371372
end
373+
CuSparseMatrixCSR{$elty}(csc::CuSparseMatrixCSC{$elty, Cint}; index::SparseChar='O', action::cusparseAction_t=CUSPARSE_ACTION_NUMERIC, algo::cusparseCsr2CscAlg_t=CUSPARSE_CSR2CSC_ALG1) =
374+
CuSparseMatrixCSR{$elty, Cint}(csc; index=index, action=action, algo=algo)
372375
end
373376
end
374377

@@ -585,42 +588,46 @@ end
585588

586589
## CSR to COO and vice-versa
587590

588-
function CuSparseMatrixCSR{Tv}(coo::CuSparseMatrixCOO{Tv}; index::SparseChar='O') where {Tv}
591+
function CuSparseMatrixCSR{Tv,Cint}(coo::CuSparseMatrixCOO{Tv}; index::SparseChar='O') where {Tv}
589592
m,n = size(coo)
590-
nnz(coo) == 0 && return CuSparseMatrixCSR{Tv}(CUDA.ones(Cint, m+1), coo.colInd, nonzeros(coo), size(coo))
593+
nnz(coo) == 0 && return CuSparseMatrixCSR{Tv,Cint}(CUDA.ones(Cint, m+1), coo.colInd, nonzeros(coo), size(coo))
591594
coo = sort_coo(coo, 'R')
592595
csrRowPtr = CuVector{Cint}(undef, m+1)
593596
cusparseXcoo2csr(handle(), coo.rowInd, nnz(coo), m, csrRowPtr, index)
594-
CuSparseMatrixCSR{Tv}(csrRowPtr, coo.colInd, nonzeros(coo), size(coo))
597+
CuSparseMatrixCSR{Tv,Cint}(csrRowPtr, coo.colInd, nonzeros(coo), size(coo))
595598
end
599+
CuSparseMatrixCSR{Tv}(coo::CuSparseMatrixCOO{Tv}; index::SparseChar='O') where {Tv} = CuSparseMatrixCSR{Tv, Cint}(coo)
596600

597-
function CuSparseMatrixCOO{Tv}(csr::CuSparseMatrixCSR{Tv}; index::SparseChar='O') where {Tv}
601+
function CuSparseMatrixCOO{Tv,Cint}(csr::CuSparseMatrixCSR{Tv}; index::SparseChar='O') where {Tv}
598602
m,n = size(csr)
599-
nnz(csr) == 0 && return CuSparseMatrixCOO{Tv}(CUDA.zeros(Cint, 0), CUDA.zeros(Cint, 0), nonzeros(csr), size(csr))
603+
nnz(csr) == 0 && return CuSparseMatrixCOO{Tv,Cint}(CUDA.zeros(Cint, 0), CUDA.zeros(Cint, 0), nonzeros(csr), size(csr))
600604
cooRowInd = CuVector{Cint}(undef, nnz(csr))
601605
cusparseXcsr2coo(handle(), csr.rowPtr, nnz(csr), m, cooRowInd, index)
602-
CuSparseMatrixCOO{Tv}(cooRowInd, csr.colVal, nonzeros(csr), size(csr))
606+
CuSparseMatrixCOO{Tv,Cint}(cooRowInd, csr.colVal, nonzeros(csr), size(csr))
603607
end
608+
CuSparseMatrixCOO{Tv}(csr::CuSparseMatrixCSR{Tv}; index::SparseChar='O') where {Tv} = CuSparseMatrixCOO{Tv, Cint}(csr)
604609

605610
### CSC to COO and viceversa
606611

607-
function CuSparseMatrixCSC{Tv}(coo::CuSparseMatrixCOO{Tv}; index::SparseChar='O') where {Tv}
612+
function CuSparseMatrixCSC{Tv,Cint}(coo::CuSparseMatrixCOO{Tv}; index::SparseChar='O') where {Tv}
608613
m,n = size(coo)
609614
nnz(coo) == 0 && return CuSparseMatrixCSC{Tv}(CUDA.ones(Cint, n+1), coo.rowInd, nonzeros(coo), size(coo))
610615
coo = sort_coo(coo, 'C')
611616
cscColPtr = CuVector{Cint}(undef, n+1)
612617
cusparseXcoo2csr(handle(), coo.colInd, nnz(coo), n, cscColPtr, index)
613-
CuSparseMatrixCSC{Tv}(cscColPtr, coo.rowInd, nonzeros(coo), size(coo))
618+
CuSparseMatrixCSC{Tv,Cint}(cscColPtr, coo.rowInd, nonzeros(coo), size(coo))
614619
end
620+
CuSparseMatrixCSC{Tv}(coo::CuSparseMatrixCOO{Tv}; index::SparseChar='O') where {Tv} = CuSparseMatrixCSC{Tv, Cint}(coo)
615621

616-
function CuSparseMatrixCOO{Tv}(csc::CuSparseMatrixCSC{Tv}; index::SparseChar='O') where {Tv}
622+
function CuSparseMatrixCOO{Tv,Cint}(csc::CuSparseMatrixCSC{Tv}; index::SparseChar='O') where {Tv}
617623
m,n = size(csc)
618-
nnz(csc) == 0 && return CuSparseMatrixCOO{Tv}(CUDA.zeros(Cint, 0), CUDA.zeros(Cint, 0), nonzeros(csc), size(csc))
624+
nnz(csc) == 0 && return CuSparseMatrixCOO{Tv,Cint}(CUDA.zeros(Cint, 0), CUDA.zeros(Cint, 0), nonzeros(csc), size(csc))
619625
cooColInd = CuVector{Cint}(undef, nnz(csc))
620626
cusparseXcsr2coo(handle(), csc.colPtr, nnz(csc), n, cooColInd, index)
621-
coo = CuSparseMatrixCOO{Tv}(csc.rowVal, cooColInd, nonzeros(csc), size(csc))
627+
coo = CuSparseMatrixCOO{Tv,Cint}(csc.rowVal, cooColInd, nonzeros(csc), size(csc))
622628
coo = sort_coo(coo, 'R')
623629
end
630+
CuSparseMatrixCOO{Tv}(csc::CuSparseMatrixCSC{Tv}; index::SparseChar='O') where {Tv} = CuSparseMatrixCOO{Tv, Cint}(csc)
624631

625632
### BSR to COO and vice-versa
626633

lib/cusparse/device.jl

Lines changed: 0 additions & 29 deletions
This file was deleted.

lib/cusparse/interfaces.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,29 @@
22

33
using LinearAlgebra
44
using LinearAlgebra: BlasComplex, BlasFloat, BlasReal, MulAddMul, AdjOrTrans
5-
export _spadjoint, _sptranspose
5+
using GPUArrays: _spadjoint, _sptranspose
66

7-
function _spadjoint(A::CuSparseMatrixCSR)
7+
function GPUArrays._spadjoint(A::CuSparseMatrixCSR)
88
Aᴴ = CuSparseMatrixCSC(A.rowPtr, A.colVal, conj(A.nzVal), reverse(size(A)))
99
CuSparseMatrixCSR(Aᴴ)
1010
end
11-
function _sptranspose(A::CuSparseMatrixCSR)
11+
function GPUArrays._sptranspose(A::CuSparseMatrixCSR)
1212
Aᵀ = CuSparseMatrixCSC(A.rowPtr, A.colVal, A.nzVal, reverse(size(A)))
1313
CuSparseMatrixCSR(Aᵀ)
1414
end
15-
function _spadjoint(A::CuSparseMatrixCSC)
15+
function GPUArrays._spadjoint(A::CuSparseMatrixCSC)
1616
Aᴴ = CuSparseMatrixCSR(A.colPtr, A.rowVal, conj(A.nzVal), reverse(size(A)))
1717
CuSparseMatrixCSC(Aᴴ)
1818
end
19-
function _sptranspose(A::CuSparseMatrixCSC)
19+
function GPUArrays._sptranspose(A::CuSparseMatrixCSC)
2020
Aᵀ = CuSparseMatrixCSR(A.colPtr, A.rowVal, A.nzVal, reverse(size(A)))
2121
CuSparseMatrixCSC(Aᵀ)
2222
end
23-
function _spadjoint(A::CuSparseMatrixCOO)
23+
function GPUArrays._spadjoint(A::CuSparseMatrixCOO)
2424
# we use sparse instead of CuSparseMatrixCOO because we want to sort the matrix.
2525
sparse(A.colInd, A.rowInd, conj(A.nzVal), reverse(size(A))..., fmt = :coo)
2626
end
27-
function _sptranspose(A::CuSparseMatrixCOO)
27+
function GPUArrays._sptranspose(A::CuSparseMatrixCOO)
2828
# we use sparse instead of CuSparseMatrixCOO because we want to sort the matrix.
2929
sparse(A.colInd, A.rowInd, A.nzVal, reverse(size(A))..., fmt = :coo)
3030
end

0 commit comments

Comments
 (0)