Skip to content

Commit 760c2bd

Browse files
committed
Remove old version checks.
1 parent 1870218 commit 760c2bd

File tree

25 files changed

+68
-420
lines changed

25 files changed

+68
-420
lines changed

lib/cudnn/test/runtests.jl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
using Test
22

3-
# work around JuliaLang/Pkg.jl#2500
4-
if VERSION < v"1.8"
5-
test_project = first(Base.load_path())
6-
preferences_file = joinpath(dirname(@__DIR__), "LocalPreferences.toml")
7-
test_preferences_file = joinpath(dirname(test_project), "LocalPreferences.toml")
8-
if isfile(preferences_file) && !isfile(test_preferences_file)
9-
cp(preferences_file, test_preferences_file)
10-
end
11-
end
12-
133
using CUDA
144
@info "CUDA information:\n" * sprint(io->CUDA.versioninfo(io))
155

lib/cusolver/dense.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ for (bname, fname,elty) in ((:cusolverDnSpotrf_bufferSize, :cusolverDnSpotrf, :F
2222
@eval begin
2323
function potrf!(uplo::Char,
2424
A::StridedCuMatrix{$elty})
25-
VERSION >= v"1.8" && LinearAlgebra.BLAS.chkuplo(uplo)
25+
LinearAlgebra.BLAS.chkuplo(uplo)
2626
n = checksquare(A)
2727
lda = max(1, stride(A, 2))
2828

@@ -55,7 +55,7 @@ for (fname,elty) in ((:cusolverDnSpotrs, :Float32),
5555
function potrs!(uplo::Char,
5656
A::StridedCuMatrix{$elty},
5757
B::StridedCuVecOrMat{$elty})
58-
VERSION >= v"1.8" && LinearAlgebra.BLAS.chkuplo(uplo)
58+
LinearAlgebra.BLAS.chkuplo(uplo)
5959
n = checksquare(A)
6060
if size(B, 1) != n
6161
throw(DimensionMismatch("first dimension of B, $(size(B,1)), must match second dimension of A, $n"))
@@ -83,7 +83,7 @@ for (bname, fname,elty) in ((:cusolverDnSpotri_bufferSize, :cusolverDnSpotri, :F
8383
@eval begin
8484
function potri!(uplo::Char,
8585
A::StridedCuMatrix{$elty})
86-
VERSION >= v"1.8" && LinearAlgebra.BLAS.chkuplo(uplo)
86+
LinearAlgebra.BLAS.chkuplo(uplo)
8787
n = checksquare(A)
8888
lda = max(1, stride(A, 2))
8989

@@ -177,7 +177,7 @@ for (bname, fname,elty) in ((:cusolverDnSsytrf_bufferSize, :cusolverDnSsytrf, :F
177177
@eval begin
178178
function sytrf!(uplo::Char,
179179
A::StridedCuMatrix{$elty})
180-
VERSION >= v"1.8" && LinearAlgebra.BLAS.chkuplo(uplo)
180+
LinearAlgebra.BLAS.chkuplo(uplo)
181181
n = checksquare(A)
182182
lda = max(1, stride(A, 2))
183183

@@ -502,7 +502,7 @@ for (jname, bname, fname, elty, relty) in ((:syevd!, :cusolverDnSsyevd_bufferSiz
502502
function $jname(jobz::Char,
503503
uplo::Char,
504504
A::StridedCuMatrix{$elty})
505-
VERSION >= v"1.8" && LinearAlgebra.BLAS.chkuplo(uplo)
505+
LinearAlgebra.BLAS.chkuplo(uplo)
506506
n = checksquare(A)
507507
lda = max(1, stride(A, 2))
508508
W = CuArray{$relty}(undef, n)
@@ -542,7 +542,7 @@ for (jname, bname, fname, elty, relty) in ((:sygvd!, :cusolverDnSsygvd_bufferSiz
542542
uplo::Char,
543543
A::StridedCuMatrix{$elty},
544544
B::StridedCuMatrix{$elty})
545-
VERSION >= v"1.8" && LinearAlgebra.BLAS.chkuplo(uplo)
545+
LinearAlgebra.BLAS.chkuplo(uplo)
546546
nA, nB = checksquare(A, B)
547547
if nB != nA
548548
throw(DimensionMismatch("Dimensions of A ($nA, $nA) and B ($nB, $nB) must match!"))
@@ -589,7 +589,7 @@ for (jname, bname, fname, elty, relty) in ((:sygvj!, :cusolverDnSsygvj_bufferSiz
589589
B::StridedCuMatrix{$elty};
590590
tol::$relty=eps($relty),
591591
max_sweeps::Int=100)
592-
VERSION >= v"1.8" && LinearAlgebra.BLAS.chkuplo(uplo)
592+
LinearAlgebra.BLAS.chkuplo(uplo)
593593
nA, nB = checksquare(A, B)
594594
if nB != nA
595595
throw(DimensionMismatch("Dimensions of A ($nA, $nA) and B ($nB, $nB) must match!"))
@@ -643,7 +643,7 @@ for (jname, bname, fname, elty, relty) in ((:syevjBatched!, :cusolverDnSsyevjBat
643643
max_sweeps::Int=100)
644644

645645
# Set up information for the solver arguments
646-
VERSION >= v"1.8" && LinearAlgebra.BLAS.chkuplo(uplo)
646+
LinearAlgebra.BLAS.chkuplo(uplo)
647647
n = checksquare(A)
648648
lda = max(1, stride(A, 2))
649649
batchSize = size(A,3)
@@ -702,7 +702,7 @@ for (fname, elty) in ((:cusolverDnSpotrsBatched, :Float32),
702702
throw(DimensionMismatch(""))
703703
end
704704
# Set up information for the solver arguments
705-
VERSION >= v"1.8" && LinearAlgebra.BLAS.chkuplo(uplo)
705+
LinearAlgebra.BLAS.chkuplo(uplo)
706706
n = checksquare(A[1])
707707
if size(B[1], 1) != n
708708
throw(DimensionMismatch("first dimension of B[i], $(size(B[1],1)), must match second dimension of A, $n"))
@@ -741,7 +741,7 @@ for (fname, elty) in ((:cusolverDnSpotrfBatched, :Float32),
741741
function potrfBatched!(uplo::Char, A::Vector{<:StridedCuMatrix{$elty}})
742742

743743
# Set up information for the solver arguments
744-
VERSION >= v"1.8" && LinearAlgebra.BLAS.chkuplo(uplo)
744+
LinearAlgebra.BLAS.chkuplo(uplo)
745745
n = checksquare(A[1])
746746
lda = max(1, stride(A[1], 2))
747747
batchSize = length(A)

lib/cusolver/linalg.jl

Lines changed: 9 additions & 189 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ end
6767

6868
# patch JuliaLang/julia#40899 to create a CuArray
6969
# (see https://github.com/JuliaLang/julia/pull/41331#issuecomment-868374522)
70-
if VERSION >= v"1.7-"
7170
_zeros(::Type{T}, b::AbstractVector, n::Integer) where {T} = CUDA.zeros(T, max(length(b), n))
7271
_zeros(::Type{T}, B::AbstractMatrix, n::Integer) where {T} = CUDA.zeros(T, max(size(B, 1), n), size(B, 2))
7372
function Base.:\(F::Union{LinearAlgebra.LAPACKFactorizations{<:Any,<:CuArray},
@@ -99,7 +98,6 @@ function Base.:\(F::Union{LinearAlgebra.LAPACKFactorizations{<:Any,<:CuArray},
9998
# the complete rhs
10099
return LinearAlgebra._cut_B(BB, 1:n)
101100
end
102-
end
103101

104102
# eigenvalues
105103

@@ -131,8 +129,6 @@ using LinearAlgebra: Factorization, AbstractQ, QRCompactWY, QRCompactWYQ, QRPack
131129

132130
## QR
133131

134-
if VERSION >= v"1.8-"
135-
136132
LinearAlgebra.qr!(A::CuMatrix{T}) where T = QR(geqrf!(A::CuMatrix{T})...)
137133

138134
# conversions
@@ -229,144 +225,13 @@ LinearAlgebra.rmul!(A::CuVecOrMat{T},
229225
trA::Transpose{<:Any,<:QRPackedQ{T,<:CuArray,<:CuArray}}) where {T<:BlasFloat} =
230226
ormqr!('R', 'T', parent(trA).factors, parent(adjB).τ, A)
231227

232-
else
233-
234-
struct CuQR{T} <: Factorization{T}
235-
factors::CuMatrix
236-
τ::CuVector{T}
237-
CuQR{T}(factors::CuMatrix{T}, τ::CuVector{T}) where {T} = new(factors, τ)
238-
end
239-
240-
struct CuQRPackedQ{T} <: AbstractQ{T}
241-
factors::CuMatrix{T}
242-
τ::CuVector{T}
243-
CuQRPackedQ{T}(factors::CuMatrix{T}, τ::CuVector{T}) where {T} = new(factors, τ)
244-
end
245-
246-
CuQR(factors::CuMatrix{T}, τ::CuVector{T}) where {T} =
247-
CuQR{T}(factors, τ)
248-
CuQRPackedQ(factors::CuMatrix{T}, τ::CuVector{T}) where {T} =
249-
CuQRPackedQ{T}(factors, τ)
250-
251-
# AbstractQ's `size` is the size of the full matrix,
252-
# while `Matrix(Q)` only gives the compact Q.
253-
# See JuliaLang/julia#26591 and JuliaGPU/CUDA.jl#969.
254-
CuMatrix{T}(Q::AbstractQ{S}) where {T,S} = convert(CuArray{T}, Matrix(Q))
255-
CuMatrix{T, B}(Q::AbstractQ{S}) where {T, B, S} = CuMatrix{T}(Q)
256-
CuMatrix(Q::AbstractQ{T}) where {T} = CuMatrix{T}(Q)
257-
CuArray{T}(Q::AbstractQ) where {T} = CuMatrix{T}(Q)
258-
CuArray(Q::AbstractQ) = CuMatrix(Q)
259-
260-
# extracting the full matrix can be done with `collect` (which defaults to `Array`)
261-
function Base.collect(src::CuQRPackedQ)
262-
dest = similar(src)
263-
copyto!(dest, I)
264-
lmul!(src, dest)
265-
collect(dest)
266-
end
267-
268-
# avoid the generic similar fallback that returns a CPU array
269-
Base.similar(Q::CuQRPackedQ, ::Type{T}, dims::Dims{N}) where {T,N} =
270-
CuArray{T,N}(undef, dims)
271-
272-
LinearAlgebra.qr!(A::CuMatrix{T}) where T = CuQR(geqrf!(A::CuMatrix{T})...)
273-
Base.size(A::CuQR) = size(A.factors)
274-
Base.size(A::CuQRPackedQ, dim::Integer) = 0 < dim ? (dim <= 2 ? size(A.factors, 1) : 1) : throw(BoundsError())
275-
CUDA.CuMatrix(A::CuQRPackedQ) = orgqr!(copy(A.factors), A.τ)
276-
CUDA.CuArray(A::CuQRPackedQ) = CuMatrix(A)
277-
Base.Matrix(A::CuQRPackedQ) = Matrix(CuMatrix(A))
278-
279-
function Base.getproperty(A::CuQR, d::Symbol)
280-
m, n = size(getfield(A, :factors))
281-
if d == :R
282-
return triu!(A.factors[1:min(m, n), 1:n])
283-
elseif d == :Q
284-
return CuQRPackedQ(A.factors, A.τ)
285-
else
286-
getfield(A, d)
287-
end
288-
end
289-
290-
# iteration for destructuring into components
291-
Base.iterate(S::CuQR) = (S.Q, Val(:R))
292-
Base.iterate(S::CuQR, ::Val{:R}) = (S.R, Val(:done))
293-
Base.iterate(S::CuQR, ::Val{:done}) = nothing
294-
295-
# Apply changes Q from the left
296-
LinearAlgebra.lmul!(A::CuQRPackedQ{T}, B::CuVecOrMat{T}) where {T<:BlasFloat} =
297-
ormqr!('L', 'N', A.factors, A.τ, B)
298-
LinearAlgebra.lmul!(adjA::Adjoint{T,<:CuQRPackedQ{T}}, B::CuVecOrMat{T}) where {T<:BlasReal} =
299-
ormqr!('L', 'T', parent(adjA).factors, parent(adjA).τ, B)
300-
LinearAlgebra.lmul!(adjA::Adjoint{T,<:CuQRPackedQ{T}}, B::CuVecOrMat{T}) where {T<:BlasComplex} =
301-
ormqr!('L', 'C', parent(adjA).factors, parent(adjA).τ, B)
302-
LinearAlgebra.lmul!(trA::Transpose{T,<:CuQRPackedQ{T}}, B::CuVecOrMat{T}) where {T<:BlasFloat} =
303-
ormqr!('L', 'T', parent(trA).factors, parent(trA).τ, B)
304-
305-
# Apply changes Q from the right
306-
LinearAlgebra.rmul!(A::CuVecOrMat{T}, B::CuQRPackedQ{T}) where {T<:BlasFloat} =
307-
ormqr!('R', 'N', B.factors, B.τ, A)
308-
LinearAlgebra.rmul!(A::CuVecOrMat{T},
309-
adjB::Adjoint{<:Any,<:CuQRPackedQ{T}}) where {T<:BlasReal} =
310-
ormqr!('R', 'T', parent(adjB).factors, parent(adjB).τ, A)
311-
LinearAlgebra.rmul!(A::CuVecOrMat{T},
312-
adjB::Adjoint{<:Any,<:CuQRPackedQ{T}}) where {T<:BlasComplex} =
313-
ormqr!('R', 'C', parent(adjB).factors, parent(adjB).τ, A)
314-
LinearAlgebra.rmul!(A::CuVecOrMat{T},
315-
trA::Transpose{<:Any,<:CuQRPackedQ{T}}) where {T<:BlasFloat} =
316-
ormqr!('R', 'T', parent(trA).factors, parent(adjB).τ, A)
317-
318-
function Base.getindex(A::CuQRPackedQ{T}, i::Int, j::Int) where {T}
319-
assertscalar("CuQRPackedQ getindex")
320-
x = CUDA.zeros(T, size(A, 2))
321-
x[j] = 1
322-
lmul!(A, x)
323-
return x[i]
324-
end
325-
326-
function Base.show(io::IO, F::CuQR)
327-
println(io, "$(typeof(F)) with factors Q and R:")
328-
show(io, F.Q)
329-
println(io)
330-
show(io, F.R)
331-
end
332-
333-
# https://github.com/JuliaLang/julia/pull/32887
334-
LinearAlgebra.det(Q::CuQRPackedQ{<:Real}) = isodd(count(!iszero, Q.τ)) ? -1 : 1
335-
LinearAlgebra.det(Q::CuQRPackedQ) = prod-> iszero(τ) ? one(τ) : -sign(τ)^2, Q.τ)
336-
337-
function LinearAlgebra.ldiv!(_qr::CuQR, b::CuVector)
338-
m,n = size(_qr)
339-
_x = UpperTriangular(_qr.R[1:min(m,n), 1:n]) \ ((_qr.Q' * b)[1:n])
340-
b[1:n] .= _x
341-
unsafe_free!(_x)
342-
return b[1:n]
343-
end
344-
345-
function LinearAlgebra.ldiv!(_qr::CuQR, B::CuMatrix)
346-
m,n = size(_qr)
347-
_x = UpperTriangular(_qr.R[1:min(m,n), 1:n]) \ ((_qr.Q' * B)[1:n, 1:size(B, 2)])
348-
B[1:n, 1:size(B, 2)] .= _x
349-
unsafe_free!(_x)
350-
return B[1:n, 1:size(B, 2)]
351-
end
352-
353-
function LinearAlgebra.ldiv!(x::CuArray,_qr::CuQR, b::CuArray)
354-
_x = ldiv!(_qr, b)
355-
x .= vec(_x)
356-
unsafe_free!(_x)
357-
return x
358-
end
359-
360-
end
361228

362229
## SVD
363230

364231
abstract type SVDAlgorithm end
365232
struct QRAlgorithm <: SVDAlgorithm end
366233
struct JacobiAlgorithm <: SVDAlgorithm end
367234

368-
if VERSION >= v"1.8-"
369-
370235
LinearAlgebra.svd!(A::CuMatrix{T}; full::Bool=false,
371236
alg::SVDAlgorithm=JacobiAlgorithm()) where {T} =
372237
_svd!(A, full, alg)
@@ -384,47 +249,6 @@ function _svd!(A::CuMatrix{T}, full::Bool, alg::JacobiAlgorithm) where T
384249
return SVD(U, S, V')
385250
end
386251

387-
else
388-
389-
390-
struct CuSVD{T,Tr,A<:AbstractMatrix{T}} <: LinearAlgebra.Factorization{T}
391-
U::CuMatrix{T}
392-
S::CuVector{Tr}
393-
V::A
394-
end
395-
396-
# iteration for destructuring into components
397-
Base.iterate(S::CuSVD) = (S.U, Val(:S))
398-
Base.iterate(S::CuSVD, ::Val{:S}) = (S.S, Val(:V))
399-
Base.iterate(S::CuSVD, ::Val{:V}) = (S.V, Val(:done))
400-
Base.iterate(S::CuSVD, ::Val{:done}) = nothing
401-
402-
@inline function Base.getproperty(S::CuSVD, s::Symbol)
403-
if s === :Vt
404-
return getfield(S, :V)'
405-
else
406-
return getfield(S, s)
407-
end
408-
end
409-
410-
LinearAlgebra.svd!(A::CuMatrix{T}; full::Bool=false,
411-
alg::SVDAlgorithm=JacobiAlgorithm()) where {T} =
412-
_svd!(A, full, alg)
413-
LinearAlgebra.svd(A::CuMatrix; full=false, alg::SVDAlgorithm=JacobiAlgorithm()) =
414-
_svd!(copy_cublasfloat(A), full, alg)
415-
416-
_svd!(A::CuMatrix{T}, full::Bool, alg::SVDAlgorithm) where T =
417-
throw(ArgumentError("Unsupported value for `alg` keyword."))
418-
function _svd!(A::CuMatrix{T}, full::Bool, alg::QRAlgorithm) where T
419-
U, s, Vt = gesvd!(full ? 'A' : 'S', full ? 'A' : 'S', A::CuMatrix{T})
420-
return CuSVD(U, s, Vt')
421-
end
422-
function _svd!(A::CuMatrix{T}, full::Bool, alg::JacobiAlgorithm) where T
423-
return CuSVD(gesvdj!('V', Int(!full), A::CuMatrix{T})...)
424-
end
425-
426-
end
427-
428252
LinearAlgebra.svdvals!(A::CuMatrix{T}; alg::SVDAlgorithm=JacobiAlgorithm()) where {T} =
429253
_svdvals!(A, alg)
430254
LinearAlgebra.svdvals(A::CuMatrix; alg::SVDAlgorithm=JacobiAlgorithm()) =
@@ -443,9 +267,8 @@ function LinearAlgebra.opnorm2(A::CuMatrix{T}) where {T}
443267
return @allowscalar invoke(LinearAlgebra.opnorm2, Tuple{AbstractMatrix{T}}, A)
444268
end
445269

446-
## LU
447270

448-
if VERSION >= v"1.8-"
271+
## LU
449272

450273
function LinearAlgebra.lu!(A::StridedCuMatrix{T}, ::RowMaximum; check::Bool = true) where {T}
451274
lpt = getrf!(A)
@@ -472,8 +295,6 @@ end
472295
LinearAlgebra.ipiv2perm(v::CuVector{T}, maxi::Integer) where T =
473296
LinearAlgebra.ipiv2perm(Array(v), maxi)
474297

475-
end
476-
477298
function LinearAlgebra.ldiv!(F::LU{T,<:StridedCuMatrix{T}}, B::CuVecOrMat{T}) where {T}
478299
return getrs!('N', F.factors, F.ipiv, B)
479300
end
@@ -484,15 +305,14 @@ function LinearAlgebra.ldiv!(F::LU{T,<:StridedCuMatrix{T}}, B::CuVecOrMat{T}) wh
484305
return getrs!('N', F.factors, F.ipiv, B)
485306
end
486307

487-
## cholesky
488308

489-
if VERSION >= v"1.8-"
490-
function LinearAlgebra.cholesky(A::LinearAlgebra.RealHermSymComplexHerm{<:Real,<:CuMatrix},
491-
::Val{false}=Val(false); check::Bool = true)
492-
C, info = LinearAlgebra._chol!(copy(parent(A)), A.uplo == 'U' ? UpperTriangular : LowerTriangular)
493-
return Cholesky(C.data, A.uplo, info)
494-
end
309+
## cholesky
495310

496-
LinearAlgebra.cholcopy(A::LinearAlgebra.RealHermSymComplexHerm{<:Any,<:CuArray}) =
497-
copyto!(similar(A, LinearAlgebra.choltype(A)), A)
311+
function LinearAlgebra.cholesky(A::LinearAlgebra.RealHermSymComplexHerm{<:Real,<:CuMatrix},
312+
::Val{false}=Val(false); check::Bool = true)
313+
C, info = LinearAlgebra._chol!(copy(parent(A)), A.uplo == 'U' ? UpperTriangular : LowerTriangular)
314+
return Cholesky(C.data, A.uplo, info)
498315
end
316+
317+
LinearAlgebra.cholcopy(A::LinearAlgebra.RealHermSymComplexHerm{<:Any,<:CuArray}) =
318+
copyto!(similar(A, LinearAlgebra.choltype(A)), A)

lib/cusparse/broadcast.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,6 @@ function sparse_to_dense_broadcast_kernel(::Type{<:CuSparseMatrixCSC}, f,
460460
end
461461

462462
function Broadcast.copy(bc::Broadcasted{<:Union{CuSparseVecStyle,CuSparseMatStyle}})
463-
# on 1.6, ntuple closures often fail to infer
464-
VERSION < v"1.7" && @warn "Sparse broadcast is only supported on Julia 1.7 or higher" maxlog=1
465-
466463
# find the sparse inputs
467464
bc = Broadcast.flatten(bc)
468465
sparse_args = findall(bc.args) do arg

0 commit comments

Comments
 (0)