From 760c2bd399a6db7df1e3dfc718514da96de51b38 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Mon, 28 Aug 2023 13:04:22 +0200 Subject: [PATCH] Remove old version checks. --- lib/cudnn/test/runtests.jl | 10 -- lib/cusolver/dense.jl | 20 +-- lib/cusolver/linalg.jl | 198 ++----------------------- lib/cusparse/broadcast.jl | 3 - lib/custatevec/test/runtests.jl | 12 +- lib/cutensor/test/runtests.jl | 10 -- lib/cutensornet/test/runtests.jl | 12 +- src/compiler/reflection.jl | 8 +- src/device/intrinsics/atomics.jl | 4 - src/device/quirks.jl | 80 +++------- src/device/random.jl | 2 - src/pool.jl | 6 +- test/base/aqua.jl | 7 +- test/base/linalg.jl | 13 -- test/core/device/intrinsics/atomics.jl | 10 +- test/core/device/random.jl | 6 - test/libraries/cublas.jl | 16 +- test/libraries/cusolver/dense.jl | 12 +- test/libraries/cusolver/multigpu.jl | 3 +- test/libraries/cusparse.jl | 8 +- test/libraries/cusparse/broadcast.jl | 4 - test/libraries/cusparse/interfaces.jl | 2 +- test/libraries/cusparse/reduce.jl | 2 +- test/runtests.jl | 22 +-- test/setup.jl | 18 --- 25 files changed, 68 insertions(+), 420 deletions(-) diff --git a/lib/cudnn/test/runtests.jl b/lib/cudnn/test/runtests.jl index cd9ee6a5b8..cffd0ae61c 100644 --- a/lib/cudnn/test/runtests.jl +++ b/lib/cudnn/test/runtests.jl @@ -1,15 +1,5 @@ using Test -# work around JuliaLang/Pkg.jl#2500 -if VERSION < v"1.8" - test_project = first(Base.load_path()) - preferences_file = joinpath(dirname(@__DIR__), "LocalPreferences.toml") - test_preferences_file = joinpath(dirname(test_project), "LocalPreferences.toml") - if isfile(preferences_file) && !isfile(test_preferences_file) - cp(preferences_file, test_preferences_file) - end -end - using CUDA @info "CUDA information:\n" * sprint(io->CUDA.versioninfo(io)) diff --git a/lib/cusolver/dense.jl b/lib/cusolver/dense.jl index 45cd75f799..3ba99edb87 100644 --- a/lib/cusolver/dense.jl +++ b/lib/cusolver/dense.jl @@ -22,7 +22,7 @@ for (bname, fname,elty) in ((:cusolverDnSpotrf_bufferSize, :cusolverDnSpotrf, :F @eval begin function potrf!(uplo::Char, A::StridedCuMatrix{$elty}) - VERSION >= v"1.8" && LinearAlgebra.BLAS.chkuplo(uplo) + LinearAlgebra.BLAS.chkuplo(uplo) n = checksquare(A) lda = max(1, stride(A, 2)) @@ -55,7 +55,7 @@ for (fname,elty) in ((:cusolverDnSpotrs, :Float32), function potrs!(uplo::Char, A::StridedCuMatrix{$elty}, B::StridedCuVecOrMat{$elty}) - VERSION >= v"1.8" && LinearAlgebra.BLAS.chkuplo(uplo) + LinearAlgebra.BLAS.chkuplo(uplo) n = checksquare(A) if size(B, 1) != n 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 @eval begin function potri!(uplo::Char, A::StridedCuMatrix{$elty}) - VERSION >= v"1.8" && LinearAlgebra.BLAS.chkuplo(uplo) + LinearAlgebra.BLAS.chkuplo(uplo) n = checksquare(A) lda = max(1, stride(A, 2)) @@ -177,7 +177,7 @@ for (bname, fname,elty) in ((:cusolverDnSsytrf_bufferSize, :cusolverDnSsytrf, :F @eval begin function sytrf!(uplo::Char, A::StridedCuMatrix{$elty}) - VERSION >= v"1.8" && LinearAlgebra.BLAS.chkuplo(uplo) + LinearAlgebra.BLAS.chkuplo(uplo) n = checksquare(A) lda = max(1, stride(A, 2)) @@ -502,7 +502,7 @@ for (jname, bname, fname, elty, relty) in ((:syevd!, :cusolverDnSsyevd_bufferSiz function $jname(jobz::Char, uplo::Char, A::StridedCuMatrix{$elty}) - VERSION >= v"1.8" && LinearAlgebra.BLAS.chkuplo(uplo) + LinearAlgebra.BLAS.chkuplo(uplo) n = checksquare(A) lda = max(1, stride(A, 2)) W = CuArray{$relty}(undef, n) @@ -542,7 +542,7 @@ for (jname, bname, fname, elty, relty) in ((:sygvd!, :cusolverDnSsygvd_bufferSiz uplo::Char, A::StridedCuMatrix{$elty}, B::StridedCuMatrix{$elty}) - VERSION >= v"1.8" && LinearAlgebra.BLAS.chkuplo(uplo) + LinearAlgebra.BLAS.chkuplo(uplo) nA, nB = checksquare(A, B) if nB != nA 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 B::StridedCuMatrix{$elty}; tol::$relty=eps($relty), max_sweeps::Int=100) - VERSION >= v"1.8" && LinearAlgebra.BLAS.chkuplo(uplo) + LinearAlgebra.BLAS.chkuplo(uplo) nA, nB = checksquare(A, B) if nB != nA 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 max_sweeps::Int=100) # Set up information for the solver arguments - VERSION >= v"1.8" && LinearAlgebra.BLAS.chkuplo(uplo) + LinearAlgebra.BLAS.chkuplo(uplo) n = checksquare(A) lda = max(1, stride(A, 2)) batchSize = size(A,3) @@ -702,7 +702,7 @@ for (fname, elty) in ((:cusolverDnSpotrsBatched, :Float32), throw(DimensionMismatch("")) end # Set up information for the solver arguments - VERSION >= v"1.8" && LinearAlgebra.BLAS.chkuplo(uplo) + LinearAlgebra.BLAS.chkuplo(uplo) n = checksquare(A[1]) if size(B[1], 1) != n 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), function potrfBatched!(uplo::Char, A::Vector{<:StridedCuMatrix{$elty}}) # Set up information for the solver arguments - VERSION >= v"1.8" && LinearAlgebra.BLAS.chkuplo(uplo) + LinearAlgebra.BLAS.chkuplo(uplo) n = checksquare(A[1]) lda = max(1, stride(A[1], 2)) batchSize = length(A) diff --git a/lib/cusolver/linalg.jl b/lib/cusolver/linalg.jl index 397f8a4407..2084734d5f 100644 --- a/lib/cusolver/linalg.jl +++ b/lib/cusolver/linalg.jl @@ -67,7 +67,6 @@ end # patch JuliaLang/julia#40899 to create a CuArray # (see https://github.com/JuliaLang/julia/pull/41331#issuecomment-868374522) -if VERSION >= v"1.7-" _zeros(::Type{T}, b::AbstractVector, n::Integer) where {T} = CUDA.zeros(T, max(length(b), n)) _zeros(::Type{T}, B::AbstractMatrix, n::Integer) where {T} = CUDA.zeros(T, max(size(B, 1), n), size(B, 2)) function Base.:\(F::Union{LinearAlgebra.LAPACKFactorizations{<:Any,<:CuArray}, @@ -99,7 +98,6 @@ function Base.:\(F::Union{LinearAlgebra.LAPACKFactorizations{<:Any,<:CuArray}, # the complete rhs return LinearAlgebra._cut_B(BB, 1:n) end -end # eigenvalues @@ -131,8 +129,6 @@ using LinearAlgebra: Factorization, AbstractQ, QRCompactWY, QRCompactWYQ, QRPack ## QR -if VERSION >= v"1.8-" - LinearAlgebra.qr!(A::CuMatrix{T}) where T = QR(geqrf!(A::CuMatrix{T})...) # conversions @@ -229,135 +225,6 @@ LinearAlgebra.rmul!(A::CuVecOrMat{T}, trA::Transpose{<:Any,<:QRPackedQ{T,<:CuArray,<:CuArray}}) where {T<:BlasFloat} = ormqr!('R', 'T', parent(trA).factors, parent(adjB).τ, A) -else - -struct CuQR{T} <: Factorization{T} - factors::CuMatrix - τ::CuVector{T} - CuQR{T}(factors::CuMatrix{T}, τ::CuVector{T}) where {T} = new(factors, τ) -end - -struct CuQRPackedQ{T} <: AbstractQ{T} - factors::CuMatrix{T} - τ::CuVector{T} - CuQRPackedQ{T}(factors::CuMatrix{T}, τ::CuVector{T}) where {T} = new(factors, τ) -end - -CuQR(factors::CuMatrix{T}, τ::CuVector{T}) where {T} = - CuQR{T}(factors, τ) -CuQRPackedQ(factors::CuMatrix{T}, τ::CuVector{T}) where {T} = - CuQRPackedQ{T}(factors, τ) - -# AbstractQ's `size` is the size of the full matrix, -# while `Matrix(Q)` only gives the compact Q. -# See JuliaLang/julia#26591 and JuliaGPU/CUDA.jl#969. -CuMatrix{T}(Q::AbstractQ{S}) where {T,S} = convert(CuArray{T}, Matrix(Q)) -CuMatrix{T, B}(Q::AbstractQ{S}) where {T, B, S} = CuMatrix{T}(Q) -CuMatrix(Q::AbstractQ{T}) where {T} = CuMatrix{T}(Q) -CuArray{T}(Q::AbstractQ) where {T} = CuMatrix{T}(Q) -CuArray(Q::AbstractQ) = CuMatrix(Q) - -# extracting the full matrix can be done with `collect` (which defaults to `Array`) -function Base.collect(src::CuQRPackedQ) - dest = similar(src) - copyto!(dest, I) - lmul!(src, dest) - collect(dest) -end - -# avoid the generic similar fallback that returns a CPU array -Base.similar(Q::CuQRPackedQ, ::Type{T}, dims::Dims{N}) where {T,N} = - CuArray{T,N}(undef, dims) - -LinearAlgebra.qr!(A::CuMatrix{T}) where T = CuQR(geqrf!(A::CuMatrix{T})...) -Base.size(A::CuQR) = size(A.factors) -Base.size(A::CuQRPackedQ, dim::Integer) = 0 < dim ? (dim <= 2 ? size(A.factors, 1) : 1) : throw(BoundsError()) -CUDA.CuMatrix(A::CuQRPackedQ) = orgqr!(copy(A.factors), A.τ) -CUDA.CuArray(A::CuQRPackedQ) = CuMatrix(A) -Base.Matrix(A::CuQRPackedQ) = Matrix(CuMatrix(A)) - -function Base.getproperty(A::CuQR, d::Symbol) - m, n = size(getfield(A, :factors)) - if d == :R - return triu!(A.factors[1:min(m, n), 1:n]) - elseif d == :Q - return CuQRPackedQ(A.factors, A.τ) - else - getfield(A, d) - end -end - -# iteration for destructuring into components -Base.iterate(S::CuQR) = (S.Q, Val(:R)) -Base.iterate(S::CuQR, ::Val{:R}) = (S.R, Val(:done)) -Base.iterate(S::CuQR, ::Val{:done}) = nothing - -# Apply changes Q from the left -LinearAlgebra.lmul!(A::CuQRPackedQ{T}, B::CuVecOrMat{T}) where {T<:BlasFloat} = - ormqr!('L', 'N', A.factors, A.τ, B) -LinearAlgebra.lmul!(adjA::Adjoint{T,<:CuQRPackedQ{T}}, B::CuVecOrMat{T}) where {T<:BlasReal} = - ormqr!('L', 'T', parent(adjA).factors, parent(adjA).τ, B) -LinearAlgebra.lmul!(adjA::Adjoint{T,<:CuQRPackedQ{T}}, B::CuVecOrMat{T}) where {T<:BlasComplex} = - ormqr!('L', 'C', parent(adjA).factors, parent(adjA).τ, B) -LinearAlgebra.lmul!(trA::Transpose{T,<:CuQRPackedQ{T}}, B::CuVecOrMat{T}) where {T<:BlasFloat} = - ormqr!('L', 'T', parent(trA).factors, parent(trA).τ, B) - -# Apply changes Q from the right -LinearAlgebra.rmul!(A::CuVecOrMat{T}, B::CuQRPackedQ{T}) where {T<:BlasFloat} = - ormqr!('R', 'N', B.factors, B.τ, A) -LinearAlgebra.rmul!(A::CuVecOrMat{T}, - adjB::Adjoint{<:Any,<:CuQRPackedQ{T}}) where {T<:BlasReal} = - ormqr!('R', 'T', parent(adjB).factors, parent(adjB).τ, A) -LinearAlgebra.rmul!(A::CuVecOrMat{T}, - adjB::Adjoint{<:Any,<:CuQRPackedQ{T}}) where {T<:BlasComplex} = - ormqr!('R', 'C', parent(adjB).factors, parent(adjB).τ, A) -LinearAlgebra.rmul!(A::CuVecOrMat{T}, - trA::Transpose{<:Any,<:CuQRPackedQ{T}}) where {T<:BlasFloat} = - ormqr!('R', 'T', parent(trA).factors, parent(adjB).τ, A) - -function Base.getindex(A::CuQRPackedQ{T}, i::Int, j::Int) where {T} - assertscalar("CuQRPackedQ getindex") - x = CUDA.zeros(T, size(A, 2)) - x[j] = 1 - lmul!(A, x) - return x[i] -end - -function Base.show(io::IO, F::CuQR) - println(io, "$(typeof(F)) with factors Q and R:") - show(io, F.Q) - println(io) - show(io, F.R) -end - -# https://github.com/JuliaLang/julia/pull/32887 -LinearAlgebra.det(Q::CuQRPackedQ{<:Real}) = isodd(count(!iszero, Q.τ)) ? -1 : 1 -LinearAlgebra.det(Q::CuQRPackedQ) = prod(τ -> iszero(τ) ? one(τ) : -sign(τ)^2, Q.τ) - -function LinearAlgebra.ldiv!(_qr::CuQR, b::CuVector) - m,n = size(_qr) - _x = UpperTriangular(_qr.R[1:min(m,n), 1:n]) \ ((_qr.Q' * b)[1:n]) - b[1:n] .= _x - unsafe_free!(_x) - return b[1:n] -end - -function LinearAlgebra.ldiv!(_qr::CuQR, B::CuMatrix) - m,n = size(_qr) - _x = UpperTriangular(_qr.R[1:min(m,n), 1:n]) \ ((_qr.Q' * B)[1:n, 1:size(B, 2)]) - B[1:n, 1:size(B, 2)] .= _x - unsafe_free!(_x) - return B[1:n, 1:size(B, 2)] -end - -function LinearAlgebra.ldiv!(x::CuArray,_qr::CuQR, b::CuArray) - _x = ldiv!(_qr, b) - x .= vec(_x) - unsafe_free!(_x) - return x -end - -end ## SVD @@ -365,8 +232,6 @@ abstract type SVDAlgorithm end struct QRAlgorithm <: SVDAlgorithm end struct JacobiAlgorithm <: SVDAlgorithm end -if VERSION >= v"1.8-" - LinearAlgebra.svd!(A::CuMatrix{T}; full::Bool=false, alg::SVDAlgorithm=JacobiAlgorithm()) where {T} = _svd!(A, full, alg) @@ -384,47 +249,6 @@ function _svd!(A::CuMatrix{T}, full::Bool, alg::JacobiAlgorithm) where T return SVD(U, S, V') end -else - - -struct CuSVD{T,Tr,A<:AbstractMatrix{T}} <: LinearAlgebra.Factorization{T} - U::CuMatrix{T} - S::CuVector{Tr} - V::A -end - -# iteration for destructuring into components -Base.iterate(S::CuSVD) = (S.U, Val(:S)) -Base.iterate(S::CuSVD, ::Val{:S}) = (S.S, Val(:V)) -Base.iterate(S::CuSVD, ::Val{:V}) = (S.V, Val(:done)) -Base.iterate(S::CuSVD, ::Val{:done}) = nothing - -@inline function Base.getproperty(S::CuSVD, s::Symbol) - if s === :Vt - return getfield(S, :V)' - else - return getfield(S, s) - end -end - -LinearAlgebra.svd!(A::CuMatrix{T}; full::Bool=false, - alg::SVDAlgorithm=JacobiAlgorithm()) where {T} = - _svd!(A, full, alg) -LinearAlgebra.svd(A::CuMatrix; full=false, alg::SVDAlgorithm=JacobiAlgorithm()) = - _svd!(copy_cublasfloat(A), full, alg) - -_svd!(A::CuMatrix{T}, full::Bool, alg::SVDAlgorithm) where T = - throw(ArgumentError("Unsupported value for `alg` keyword.")) -function _svd!(A::CuMatrix{T}, full::Bool, alg::QRAlgorithm) where T - U, s, Vt = gesvd!(full ? 'A' : 'S', full ? 'A' : 'S', A::CuMatrix{T}) - return CuSVD(U, s, Vt') -end -function _svd!(A::CuMatrix{T}, full::Bool, alg::JacobiAlgorithm) where T - return CuSVD(gesvdj!('V', Int(!full), A::CuMatrix{T})...) -end - -end - LinearAlgebra.svdvals!(A::CuMatrix{T}; alg::SVDAlgorithm=JacobiAlgorithm()) where {T} = _svdvals!(A, alg) LinearAlgebra.svdvals(A::CuMatrix; alg::SVDAlgorithm=JacobiAlgorithm()) = @@ -443,9 +267,8 @@ function LinearAlgebra.opnorm2(A::CuMatrix{T}) where {T} return @allowscalar invoke(LinearAlgebra.opnorm2, Tuple{AbstractMatrix{T}}, A) end -## LU -if VERSION >= v"1.8-" +## LU function LinearAlgebra.lu!(A::StridedCuMatrix{T}, ::RowMaximum; check::Bool = true) where {T} lpt = getrf!(A) @@ -472,8 +295,6 @@ end LinearAlgebra.ipiv2perm(v::CuVector{T}, maxi::Integer) where T = LinearAlgebra.ipiv2perm(Array(v), maxi) -end - function LinearAlgebra.ldiv!(F::LU{T,<:StridedCuMatrix{T}}, B::CuVecOrMat{T}) where {T} return getrs!('N', F.factors, F.ipiv, B) end @@ -484,15 +305,14 @@ function LinearAlgebra.ldiv!(F::LU{T,<:StridedCuMatrix{T}}, B::CuVecOrMat{T}) wh return getrs!('N', F.factors, F.ipiv, B) end -## cholesky -if VERSION >= v"1.8-" - function LinearAlgebra.cholesky(A::LinearAlgebra.RealHermSymComplexHerm{<:Real,<:CuMatrix}, - ::Val{false}=Val(false); check::Bool = true) - C, info = LinearAlgebra._chol!(copy(parent(A)), A.uplo == 'U' ? UpperTriangular : LowerTriangular) - return Cholesky(C.data, A.uplo, info) - end +## cholesky - LinearAlgebra.cholcopy(A::LinearAlgebra.RealHermSymComplexHerm{<:Any,<:CuArray}) = - copyto!(similar(A, LinearAlgebra.choltype(A)), A) +function LinearAlgebra.cholesky(A::LinearAlgebra.RealHermSymComplexHerm{<:Real,<:CuMatrix}, + ::Val{false}=Val(false); check::Bool = true) + C, info = LinearAlgebra._chol!(copy(parent(A)), A.uplo == 'U' ? UpperTriangular : LowerTriangular) + return Cholesky(C.data, A.uplo, info) end + +LinearAlgebra.cholcopy(A::LinearAlgebra.RealHermSymComplexHerm{<:Any,<:CuArray}) = + copyto!(similar(A, LinearAlgebra.choltype(A)), A) diff --git a/lib/cusparse/broadcast.jl b/lib/cusparse/broadcast.jl index 95ad079049..745961e7d4 100644 --- a/lib/cusparse/broadcast.jl +++ b/lib/cusparse/broadcast.jl @@ -460,9 +460,6 @@ function sparse_to_dense_broadcast_kernel(::Type{<:CuSparseMatrixCSC}, f, end function Broadcast.copy(bc::Broadcasted{<:Union{CuSparseVecStyle,CuSparseMatStyle}}) - # on 1.6, ntuple closures often fail to infer - VERSION < v"1.7" && @warn "Sparse broadcast is only supported on Julia 1.7 or higher" maxlog=1 - # find the sparse inputs bc = Broadcast.flatten(bc) sparse_args = findall(bc.args) do arg diff --git a/lib/custatevec/test/runtests.jl b/lib/custatevec/test/runtests.jl index 94eb741094..663e7f4154 100644 --- a/lib/custatevec/test/runtests.jl +++ b/lib/custatevec/test/runtests.jl @@ -1,15 +1,5 @@ using Test, LinearAlgebra -# work around JuliaLang/Pkg.jl#2500 -if VERSION < v"1.8" - test_project = first(Base.load_path()) - preferences_file = joinpath(dirname(@__DIR__), "LocalPreferences.toml") - test_preferences_file = joinpath(dirname(test_project), "LocalPreferences.toml") - if isfile(preferences_file) && !isfile(test_preferences_file) - cp(preferences_file, test_preferences_file) - end -end - using CUDA @info "CUDA information:\n" * sprint(io->CUDA.versioninfo(io)) @@ -51,7 +41,7 @@ using cuStateVec end @testset "applyMatrix! and sample" begin # build a simple state and compute samples - n_q = 10 + n_q = 10 @testset for elty in [ComplexF32, ComplexF64] H = convert(Matrix{elty}, (1/√2).*[1 1; 1 -1]) sv = CuStateVec(elty, n_q) diff --git a/lib/cutensor/test/runtests.jl b/lib/cutensor/test/runtests.jl index 6d01b6c726..41b59840d4 100644 --- a/lib/cutensor/test/runtests.jl +++ b/lib/cutensor/test/runtests.jl @@ -1,15 +1,5 @@ using Test -# work around JuliaLang/Pkg.jl#2500 -if VERSION < v"1.8" - test_project = first(Base.load_path()) - preferences_file = joinpath(dirname(@__DIR__), "LocalPreferences.toml") - test_preferences_file = joinpath(dirname(test_project), "LocalPreferences.toml") - if isfile(preferences_file) && !isfile(test_preferences_file) - cp(preferences_file, test_preferences_file) - end -end - using CUDA @info "CUDA information:\n" * sprint(io->CUDA.versioninfo(io)) diff --git a/lib/cutensornet/test/runtests.jl b/lib/cutensornet/test/runtests.jl index bc818ce1b2..c5f96ece51 100644 --- a/lib/cutensornet/test/runtests.jl +++ b/lib/cutensornet/test/runtests.jl @@ -1,15 +1,5 @@ using Test -# work around JuliaLang/Pkg.jl#2500 -if VERSION < v"1.8" - test_project = first(Base.load_path()) - preferences_file = joinpath(dirname(@__DIR__), "LocalPreferences.toml") - test_preferences_file = joinpath(dirname(test_project), "LocalPreferences.toml") - if isfile(preferences_file) && !isfile(test_preferences_file) - cp(preferences_file, test_preferences_file) - end -end - using CUDA @info "CUDA information:\n" * sprint(io->CUDA.versioninfo(io)) @@ -80,7 +70,7 @@ using TensorOperations Q = CUDA.zeros(elty, n, n) R = CUDA.zeros(elty, n, m) Q, R = qr!(CuTensor(A, modesA), CuTensor(Q, ['n', 'o']), CuTensor(R, ['o', 'm'])) - @test collect(Q*R) ≈ collect(A) + @test collect(Q*R) ≈ collect(A) end @testset "SVD" begin A = CUDA.rand(elty, n, n) diff --git a/src/compiler/reflection.jl b/src/compiler/reflection.jl index 32c66d9597..41d8bfd5e3 100644 --- a/src/compiler/reflection.jl +++ b/src/compiler/reflection.jl @@ -162,12 +162,8 @@ function return_type(@nospecialize(func), @nospecialize(tt)) config = compiler_config(device()) job = CompilerJob(source, config) interp = GPUCompiler.get_interpreter(job) - if VERSION >= v"1.8-" - sig = Base.signature_type(func, tt) - Core.Compiler.return_type(interp, sig) - else - Core.Compiler.return_type(interp, func, tt) - end + sig = Base.signature_type(func, tt) + Core.Compiler.return_type(interp, sig) end diff --git a/src/device/intrinsics/atomics.jl b/src/device/intrinsics/atomics.jl index ca3d268907..c81aa48421 100644 --- a/src/device/intrinsics/atomics.jl +++ b/src/device/intrinsics/atomics.jl @@ -369,10 +369,6 @@ atomic_dec! # well as acquire/release operations to implement the fallback functionality where any # operation can be applied atomically. -if VERSION <= v"1.7-" -export @atomic -end - const inplace_ops = Dict( :(+=) => :(+), :(-=) => :(-), diff --git a/src/device/quirks.jl b/src/device/quirks.jl index e20f655056..df2bc41d7e 100644 --- a/src/device/quirks.jl +++ b/src/device/quirks.jl @@ -44,75 +44,31 @@ end @device_override @noinline Base.Math.sincos_domain_error(x) = @print_and_throw "sincos(x) is only defined for finite x." -# multidimensional.jl -@static if VERSION >= v"1.7-" - # XXX: the boundscheck change in JuliaLang/julia#42119 has exposed additional issues - # with bad code generation by ptxas on = v"1.7-" - @eval begin - @device_override function Base.StepRangeLen{T,R,S,L}(ref::R, step::S, len::Integer, - offset::Integer=1) where {T,R,S,L} - if T <: Integer && !isinteger(ref + step) - @print_and_throw("StepRangeLen{<:Integer} cannot have non-integer step") - end - len = convert(L, len) - len >= zero(len) || @print_and_throw("StepRangeLen length cannot be negative") - offset = convert(L, offset) - L1 = oneunit(typeof(len)) - L1 <= offset <= max(L1, len) || @print_and_throw("StepRangeLen: offset must be in [1,...]") - $( - Expr(:new, :(StepRangeLen{T,R,S,L}), :ref, :step, :len, :offset) - ) - end - end -else - @device_override function Base.StepRangeLen{T,R,S}(ref::R, step::S, len::Integer, - offset::Integer=1) where {T,R,S} +@eval begin + @device_override function Base.StepRangeLen{T,R,S,L}(ref::R, step::S, len::Integer, + offset::Integer=1) where {T,R,S,L} if T <: Integer && !isinteger(ref + step) @print_and_throw("StepRangeLen{<:Integer} cannot have non-integer step") end - len >= 0 || @print_and_throw("StepRangeLen length cannot be negative") - 1 <= offset <= max(1,len) || @print_and_throw("StepRangeLen: offset must be in [1,...]") - new(ref, step, len, offset) + len = convert(L, len) + len >= zero(len) || @print_and_throw("StepRangeLen length cannot be negative") + offset = convert(L, offset) + L1 = oneunit(typeof(len)) + L1 <= offset <= max(L1, len) || @print_and_throw("StepRangeLen: offset must be in [1,...]") + $( + Expr(:new, :(StepRangeLen{T,R,S,L}), :ref, :step, :len, :offset) + ) end end # LinearAlgebra -@static if VERSION >= v"1.8-" - @device_override function Base.setindex!(D::LinearAlgebra.Diagonal, v, i::Int, j::Int) - @boundscheck checkbounds(D, i, j) - if i == j - @inbounds D.diag[i] = v - elseif !iszero(v) - @print_and_throw("cannot set off-diagonal entry to a nonzero value") - end - return v +@device_override function Base.setindex!(D::LinearAlgebra.Diagonal, v, i::Int, j::Int) + @boundscheck checkbounds(D, i, j) + if i == j + @inbounds D.diag[i] = v + elseif !iszero(v) + @print_and_throw("cannot set off-diagonal entry to a nonzero value") end -end - -# fastmath.jl -@static if VERSION <= v"1.7-" -## prevent fallbacks to libm -for f in (:acosh, :asinh, :atanh, :cbrt, :cosh, :exp2, :expm1, :log1p, :sinh, :tanh) - f_fast = Base.FastMath.fast_op[f] - @eval begin - @device_override Base.FastMath.$f_fast(x::Float32) = $f(x) - @device_override Base.FastMath.$f_fast(x::Float64) = $f(x) - end -end + return v end diff --git a/src/device/random.jl b/src/device/random.jl index 6525617c0b..1609563db3 100644 --- a/src/device/random.jl +++ b/src/device/random.jl @@ -108,10 +108,8 @@ function Random.seed!(rng::Philox2x32, seed::Integer, counter::Integer=0) return end -if VERSION >= v"1.7-" @device_override Random.seed!(::Random._GLOBAL_RNG, seed) = Random.seed!(Random.default_rng(), seed) -end """ Random.rand(rng::Philox2x32, UInt32) diff --git a/src/pool.jl b/src/pool.jl index 3ed0f0278a..11b9aee724 100644 --- a/src/pool.jl +++ b/src/pool.jl @@ -191,11 +191,7 @@ function pool_mark(dev::CuDevice) # launch a task to periodically trim the pool if isinteractive() && !isassigned(__pool_cleanup) - __pool_cleanup[] = if VERSION < v"1.7" - Threads.@spawn pool_cleanup() - else - errormonitor(Threads.@spawn pool_cleanup()) - end + __pool_cleanup[] = errormonitor(Threads.@spawn pool_cleanup()) end else pool = memory_pool(dev) diff --git a/test/base/aqua.jl b/test/base/aqua.jl index 1a0e6391fe..dac505fee6 100644 --- a/test/base/aqua.jl +++ b/test/base/aqua.jl @@ -18,9 +18,4 @@ Aqua.test_stale_deps(CUDA; ignore=[:CUDA_Runtime_Discovery, :CUDA_Runtime_jll, Aqua.test_deps_compat(CUDA) Aqua.test_project_extras(CUDA) Aqua.test_project_toml_formatting(CUDA) - -if VERSION ≥ v"1.7" - # on 1.6, device overrides aren't implemented using overlay method tables, - # but using world age hacks which confuse Aqua's type piracy detection. - Aqua.test_piracy(CUDA) -end +Aqua.test_piracy(CUDA) diff --git a/test/base/linalg.jl b/test/base/linalg.jl index 7266ffb518..1238271dc8 100644 --- a/test/base/linalg.jl +++ b/test/base/linalg.jl @@ -1,18 +1,5 @@ using LinearAlgebra -VERSION <= v"1.8-" && @testset "qr size mismatch" begin - X = rand(Float32, 2, 1) - Q,R = qr(X) - - @test collect(Q) == Array(collect(Q)) - @test Array(Q) == Array(CuArray(Q)) - @test Array{Float32}(Q) == Array(CuArray{Float32}(Q)) - @test Matrix(Q) == Array(CuMatrix(Q)) - @test Matrix{Float32}(Q) == Array(CuMatrix{Float32}(Q)) - @test convert(Array, Q) == Array(convert(CuArray, Q)) - @test convert(Array{Float32}, Q) == Array(convert(CuArray{Float32}, Q)) -end - @testset "normalize!" begin x = rand(ComplexF32, 10) dx = CuVector{ComplexF32}(x) diff --git a/test/core/device/intrinsics/atomics.jl b/test/core/device/intrinsics/atomics.jl index 29810defe7..4d08117bac 100644 --- a/test/core/device/intrinsics/atomics.jl +++ b/test/core/device/intrinsics/atomics.jl @@ -419,22 +419,22 @@ end using CUDA: AtomicError - @test_throws_macro AtomicError("right-hand side of an @atomic assignment should be a call") @macroexpand begin + @test_throws AtomicError("right-hand side of an @atomic assignment should be a call") @macroexpand begin @atomic a[1] = 1 end - @test_throws_macro AtomicError("right-hand side of an @atomic assignment should be a call") @macroexpand begin + @test_throws AtomicError("right-hand side of an @atomic assignment should be a call") @macroexpand begin @atomic a[1] = b ? 1 : 2 end - @test_throws_macro AtomicError("right-hand side of a non-inplace @atomic assignment should reference the left-hand side") @macroexpand begin + @test_throws AtomicError("right-hand side of a non-inplace @atomic assignment should reference the left-hand side") @macroexpand begin @atomic a[1] = a[2] + 1 end - @test_throws_macro AtomicError("unknown @atomic expression") @macroexpand begin + @test_throws AtomicError("unknown @atomic expression") @macroexpand begin @atomic wat(a[1]) end - @test_throws_macro AtomicError("@atomic should be applied to an array reference expression") @macroexpand begin + @test_throws AtomicError("@atomic should be applied to an array reference expression") @macroexpand begin @atomic a = a + 1 end end diff --git a/test/core/device/random.jl b/test/core/device/random.jl index 71b72b81f4..a09e15d668 100644 --- a/test/core/device/random.jl +++ b/test/core/device/random.jl @@ -1,7 +1,3 @@ -if VERSION < v"1.6.1" -@warn "Julia version too old, skipping random tests" -else - using Random n = 256 @@ -129,5 +125,3 @@ end @test Array(a) == Array(b) end end - -end diff --git a/test/libraries/cublas.jl b/test/libraries/cublas.jl index 71fe29d76a..391e37b598 100644 --- a/test/libraries/cublas.jl +++ b/test/libraries/cublas.jl @@ -392,23 +392,19 @@ end @testset "spr!" begin # execute on host - VERSION>=v"1.8.0-DEV.1049" && BLAS.spr!('U',alpha,x,sAPU) + BLAS.spr!('U',alpha,x,sAPU) # execute on device CUBLAS.spr!('U',alpha,dx,dsAPU) # compare results - if VERSION>=v"1.8.0-DEV.1049" - hsAPU = Array(dsAPU) - @test sAPU ≈ hsAPU - end + hsAPU = Array(dsAPU) + @test sAPU ≈ hsAPU # execute on host - VERSION>=v"1.8.0-DEV.1049" && BLAS.spr!('U',alpha,x,sAPL) + BLAS.spr!('U',alpha,x,sAPL) # execute on device CUBLAS.spr!('U',alpha,dx,dsAPL) # compare results - if VERSION>=v"1.8.0-DEV.1049" - hAPL = Array(dAPL) - @test sAPL ≈ hAPL - end + hAPL = Array(dAPL) + @test sAPL ≈ hAPL end end diff --git a/test/libraries/cusolver/dense.jl b/test/libraries/cusolver/dense.jl index 5d184e78e5..e289d51ce7 100644 --- a/test/libraries/cusolver/dense.jl +++ b/test/libraries/cusolver/dense.jl @@ -16,7 +16,7 @@ k = 1 d_A = CuArray(A) d_B = CuArray(B) - pivot = VERSION >= v"1.8" ? NoPivot() : Val(false) + pivot = NoPivot() d_F = cholesky(d_A, pivot) F = cholesky(A, pivot) @test F.U ≈ collect(d_F.U) @@ -377,10 +377,8 @@ k = 1 qrstr = sprint(show, MIME"text/plain"(), d_F) if VERSION >= v"1.10-" @test qrstr == "$(typeof(d_F))\nQ factor: $(sprint(show, MIME"text/plain"(), d_F.Q))\nR factor:\n$(sprint(show, MIME"text/plain"(), d_F.R))" - elseif VERSION >= v"1.8-" - @test qrstr == "$(typeof(d_F))\nQ factor:\n$(sprint(show, MIME"text/plain"(), d_F.Q))\nR factor:\n$(sprint(show, MIME"text/plain"(), d_F.R))" else - @test qrstr == "$(typeof(d_F)) with factors Q and R:\n$(sprint(show, d_F.Q))\n$(sprint(show, d_F.R))" + @test qrstr == "$(typeof(d_F))\nQ factor:\n$(sprint(show, MIME"text/plain"(), d_F.Q))\nR factor:\n$(sprint(show, MIME"text/plain"(), d_F.R))" end end @@ -592,7 +590,7 @@ k = 1 end end - VERSION >= v"1.8-" && @testset "lu" begin + @testset "lu" begin @testset "elty = $elty" for elty in [Float32, Float64, ComplexF32, ComplexF64] A = CuArray(rand(elty, m, m)) F = lu(A) @@ -609,7 +607,7 @@ k = 1 lu_gpu = lu(A_d) @test ldiv!(lu_cpu, B) ≈ collect(ldiv!(lu_gpu, B_d)) end - + A = CuMatrix(rand(1024, 1024)) lua = lu(A) @test Matrix(lua.L) * Matrix(lua.U) ≈ Matrix(lua.P) * Matrix(A) @@ -617,7 +615,7 @@ k = 1 A = CuMatrix(rand(1024, 512)) lua = lu(A) @test Matrix(lua.L) * Matrix(lua.U) ≈ Matrix(lua.P) * Matrix(A) - + A = CuMatrix(rand(512, 1024)) lua = lu(A) @test Matrix(lua.L) * Matrix(lua.U) ≈ Matrix(lua.P) * Matrix(A) diff --git a/test/libraries/cusolver/multigpu.jl b/test/libraries/cusolver/multigpu.jl index a1200ef41a..43f56a05e6 100644 --- a/test/libraries/cusolver/multigpu.jl +++ b/test/libraries/cusolver/multigpu.jl @@ -101,8 +101,7 @@ if CUSOLVER.version() >= v"10.3" @testset "element type $elty" for elty in [Float32, Float64, ComplexF32, ComplexF64] A = rand(elty,m,m) h_A = copy(A) - pivot = VERSION >= v"1.7" ? NoPivot() : Val(false) - alu = lu(A, pivot) + alu = lu(A, NoPivot()) B = rand(elty, m, div(m,2)) h_B = copy(B) tol = real(elty) == Float32 ? 1e-1 : 1e-6 diff --git a/test/libraries/cusparse.jl b/test/libraries/cusparse.jl index bf3d659961..7d2615a52d 100644 --- a/test/libraries/cusparse.jl +++ b/test/libraries/cusparse.jl @@ -351,7 +351,7 @@ end d_A = CuSparseMatrixBSR(d_A, blockdim) d_A = CUSPARSE.ilu02!(d_A) h_A = SparseMatrixCSC(CuSparseMatrixCSR(d_A)) - pivot = VERSION >= v"1.7" ? NoPivot() : Val(false) + pivot = NoPivot() Alu = lu(Array(A), pivot) Ac = sparse(Alu.L*Alu.U) h_A = adjoint(h_A) * h_A @@ -367,7 +367,7 @@ end d_A = CuSparseMatrixBSR(d_A, blockdim) d_B = CUSPARSE.ilu02(d_A) h_A = SparseMatrixCSC(CuSparseMatrixCSR(d_B)) - pivot = VERSION >= v"1.7" ? NoPivot() : Val(false) + pivot = NoPivot() Alu = lu(Array(A),pivot) Ac = sparse(Alu.L*Alu.U) h_A = adjoint(h_A) * h_A @@ -536,7 +536,7 @@ end d_A = CuSparseMatrixCSR(sparse(A)) d_B = CUSPARSE.ilu02(d_A) h_A = SparseMatrixCSC(d_B) - pivot = VERSION >= v"1.7" ? NoPivot() : Val(false) + pivot = NoPivot() Alu = lu(Array(A),pivot) Ac = sparse(Alu.L*Alu.U) h_A = adjoint(h_A) * h_A @@ -550,7 +550,7 @@ end d_A = CuSparseMatrixCSC(sparse(A)) d_B = CUSPARSE.ilu02(d_A) h_A = SparseMatrixCSC(d_B) - pivot = VERSION >= v"1.7" ? NoPivot() : Val(false) + pivot = NoPivot() Alu = lu(Array(A),pivot) Ac = sparse(Alu.L*Alu.U) h_A = adjoint(h_A) * h_A diff --git a/test/libraries/cusparse/broadcast.jl b/test/libraries/cusparse/broadcast.jl index 9a6dfa85a9..37fef9ff2a 100644 --- a/test/libraries/cusparse/broadcast.jl +++ b/test/libraries/cusparse/broadcast.jl @@ -1,7 +1,5 @@ using CUDA.CUSPARSE, SparseArrays -if VERSION >= v"1.7" - m,n = 5,6 p = 0.5 @@ -43,5 +41,3 @@ end y = Int.(x) @test eltype(y) == Int end - -end diff --git a/test/libraries/cusparse/interfaces.jl b/test/libraries/cusparse/interfaces.jl index 834590f508..e53a9b3ab9 100644 --- a/test/libraries/cusparse/interfaces.jl +++ b/test/libraries/cusparse/interfaces.jl @@ -319,7 +319,7 @@ using LinearAlgebra, SparseArrays @test SparseMatrixCSC(CuSparseMatrixCSR(T)) ≈ f(S) end - VERSION >= v"1.7" && @testset "UniformScaling basic operations" begin + @testset "UniformScaling basic operations" begin for elty in (Float32, Float64, ComplexF32, ComplexF64) A = sprand(elty, 100, 100, 0.1) U1 = 2*I diff --git a/test/libraries/cusparse/reduce.jl b/test/libraries/cusparse/reduce.jl index 4af5bbd184..fa7c5243b3 100644 --- a/test/libraries/cusparse/reduce.jl +++ b/test/libraries/cusparse/reduce.jl @@ -1,7 +1,7 @@ using CUDA.CUSPARSE, SparseArrays # XXX: these tests cause GC corruption on 1.10+ (see JuliaGPU/CUDA.jl#2027) -if VERSION >= v"1.7" && VERSION < v"1.10-" +if VERSION < v"1.10-" m,n = 5,6 p = 0.5 diff --git a/test/runtests.jl b/test/runtests.jl index eaec65ab95..4ac1d24f98 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,16 +3,6 @@ using Dates import REPL using Printf: @sprintf -# work around JuliaLang/Pkg.jl#2500 -if VERSION < v"1.8" - test_project = first(Base.load_path()) - preferences_file = joinpath(dirname(@__DIR__), "LocalPreferences.toml") - test_preferences_file = joinpath(dirname(test_project), "LocalPreferences.toml") - if isfile(preferences_file) && !isfile(test_preferences_file) - cp(preferences_file, test_preferences_file) - end -end - # parse some command-line arguments function extract_flag!(args, flag, default=nothing; typ=typeof(default)) for f in args @@ -396,11 +386,7 @@ for (testname, (resp,)) in results elseif isa(resp, Tuple{Int,Int}) fake = Test.DefaultTestSet(testname) for i in 1:resp[1] - if VERSION >= v"1.7-" - Test.record(fake, Test.Pass(:test, nothing, nothing, nothing, nothing)) - else - Test.record(fake, Test.Pass(:test, nothing, nothing, nothing)) - end + Test.record(fake, Test.Pass(:test, nothing, nothing, nothing, nothing)) end for i in 1:resp[2] Test.record(fake, Test.Broken(:test, nothing)) @@ -414,11 +400,7 @@ for (testname, (resp,)) in results println() fake = Test.DefaultTestSet(testname) for i in 1:resp.captured.ex.pass - if VERSION >= v"1.7-" - Test.record(fake, Test.Pass(:test, nothing, nothing, nothing, nothing)) - else - Test.record(fake, Test.Pass(:test, nothing, nothing, nothing)) - end + Test.record(fake, Test.Pass(:test, nothing, nothing, nothing, nothing)) end for i in 1:resp.captured.ex.broken Test.record(fake, Test.Broken(:test, nothing)) diff --git a/test/setup.jl b/test/setup.jl index f8a01981a1..46412c4fd3 100644 --- a/test/setup.jl +++ b/test/setup.jl @@ -175,24 +175,6 @@ macro test_throws_message(f, typ, ex...) end end -# @test_throw, peeking into the load error for testing macro errors -macro test_throws_macro(ty, ex) - return quote - Test.@test_throws $(esc(ty)) try - $(esc(ex)) - catch err - if VERSION < v"1.7-" - @test err isa LoadError - @test err.file === $(string(__source__.file)) - @test err.line === $(__source__.line + 1) - rethrow(err.error) - else - rethrow(err) - end - end - end -end - # Run some code on-device macro on_device(ex...) code = ex[end]