Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Towards supporting Julia 1.11 #2291

Merged
merged 6 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ steps:
- "1.8"
- "1.9"
- "1.10"
- "1.11"
- "nightly"
adjustments:
- with:
julia: "1.11"
soft_fail: true
- with:
julia: "nightly"
soft_fail: true
Expand Down
29 changes: 21 additions & 8 deletions lib/cusolver/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function Base.:\(_A::CuMatOrAdj, _B::CuOrAdj)
if n < m
# LQ decomposition
At = CuMatrix(A')
F, tau = CUSOLVER.geqrf!(At) # A = RᴴQᴴ
F, tau = geqrf!(At) # A = RᴴQᴴ
if B isa CuVector{T}
CUBLAS.trsv!('U', 'C', 'N', view(F,1:n,1:n), B)
X = CUDA.zeros(T, m)
Expand All @@ -45,15 +45,15 @@ function Base.:\(_A::CuMatOrAdj, _B::CuOrAdj)
X = CUDA.zeros(T, m, p)
view(X, 1:n, :) .= B
end
CUSOLVER.ormqr!('L', 'N', F, tau, X)
ormqr!('L', 'N', F, tau, X)
elseif n == m
# LU decomposition with partial pivoting
F, p, info = CUSOLVER.getrf!(A) # PA = LU
X = CUSOLVER.getrs!('N', F, p, B)
F, p, info = getrf!(A) # PA = LU
X = getrs!('N', F, p, B)
else
# QR decomposition
F, tau = CUSOLVER.geqrf!(A) # A = QR
CUSOLVER.ormqr!('L', 'C', F, tau, B)
F, tau = geqrf!(A) # A = QR
ormqr!('L', 'C', F, tau, B)
if B isa CuVector{T}
X = B[1:m]
CUBLAS.trsv!('U', 'N', 'N', view(F,1:m,1:m), X)
Expand Down Expand Up @@ -307,9 +307,22 @@ end

## LU

function LinearAlgebra.lu!(A::StridedCuMatrix{T}, ::RowMaximum; check::Bool = true) where {T}
function _check_lu_success(info, allowsingular)
if VERSION >= v"1.11.0-DEV.1535"
if info < 0 # zero pivot error from unpivoted LU
LinearAlgebra.checknozeropivot(-info)
else
allowsingular || LinearAlgebra.checknonsingular(info)
end
else
LinearAlgebra.checknonsingular(info)
end
end

function LinearAlgebra.lu!(A::StridedCuMatrix{T}, ::RowMaximum;
check::Bool=true, allowsingular::Bool=false) where {T}
lpt = getrf!(A)
check && LinearAlgebra.checknonsingular(lpt[3])
check && _check_lu_success(lpt[3], allowsingular)
return LU(lpt[1], lpt[2], Int(lpt[3]))
end

Expand Down
13 changes: 3 additions & 10 deletions test/base/sorting.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using Random
using DataStructures

@testset "quicksort" begin

import CUDA.QuickSortImpl: flex_lt, find_partition, quicksort!,
partition_batches_kernel, consolidate_batch_partition, bubble_sort
import CUDA.QuickSortImpl: flex_lt, find_partition, quicksort!, partition_batches_kernel,
consolidate_batch_partition, bubble_sort

@testset "integer functions" begin
@test flex_lt(1, 2, false, isless, identity) == true
Expand Down Expand Up @@ -279,9 +277,6 @@ end
end
end

# XXX: some tests here make compute-sanitizer hang, but only on CI.
# maybe related to the container set-up? try again once we use Sandbox.jl.

@testset "interface" begin
@testset "quicksort" begin
# pre-sorted
Expand Down Expand Up @@ -389,7 +384,7 @@ end
@test check_sortperm(Float64, 1000000; rev=true)
@test check_sortperm(Float64, 1000000; by=x->abs(x-0.5))
@test check_sortperm(Float64, 1000000; rev=true, by=x->abs(x-0.5))

if VERSION >= v"1.9"
# Base.jl didn't implement sortperm(;dims) until 1.9
@test check_sortperm(Float32, (100_000, 16); dims=1)
Expand All @@ -406,5 +401,3 @@ end
# mismatched types (JuliaGPU/CUDA.jl#2046)
@test check_sortperm!(collect(UInt64(1):UInt64(1000000)), Int64, 1000000)
end

end
8 changes: 4 additions & 4 deletions test/libraries/cusolver/dense_generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,20 @@ p = 5
A = rand(elty,m,n)
d_A = CuMatrix(A)
U, Σ, V, err_sigma = CUSOLVER.Xgesvdp!('V', 0, d_A)
@test A ≈ collect(U[:,1:n] * Diagonal(Σ) * V')
@test A ≈ collect(U[:,1:n]) * Diagonal(collect(Σ)) * collect(V)'

d_A = CuMatrix(A)
U, Σ, V, err_sigma = CUSOLVER.Xgesvdp!('V', 1, d_A)
@test A ≈ collect(U * Diagonal(Σ) * V')
@test A ≈ collect(U) * Diagonal(collect(Σ)) * collect(V)'

A = rand(elty,n,m)
d_A = CuMatrix(A)
U, Σ, V, err_sigma = CUSOLVER.Xgesvdp!('V', 0, d_A)
@test A ≈ collect(U * Diagonal(Σ) * V[:,1:n]')
@test A ≈ collect(U) * Diagonal(collect(Σ)) * collect(V[:,1:n])'

d_A = CuMatrix(A)
U, Σ, V, err_sigma = CUSOLVER.Xgesvdp!('V', 1, d_A)
@test A ≈ collect(U * Diagonal(Σ) * V')
@test A ≈ collect(U) * Diagonal(collect(Σ)) * collect(V)'
end

# @testset "gesvdr!" begin
Expand Down
11 changes: 9 additions & 2 deletions test/setup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,15 @@ function runtests(f, name, time_source=:cuda)
else
missing
end
passes,fails,error,broken,c_passes,c_fails,c_errors,c_broken =
Test.get_test_counts(data[1])
if VERSION >= v"1.11.0-DEV.1529"
tc = Test.get_test_counts(data[1])
passes,fails,error,broken,c_passes,c_fails,c_errors,c_broken =
tc.passes, tc.fails, tc.errors, tc.broken, tc.cumulative_passes,
tc.cumulative_fails, tc.cumulative_errors, tc.cumulative_broken
else
passes,fails,errors,broken,c_passes,c_fails,c_errors,c_broken =
Test.get_test_counts(data[1])
end
if data[1].anynonpass == false
data = ((passes+c_passes,broken+c_broken),
data[2],
Expand Down