Skip to content

Commit 0a79d73

Browse files
ViralBShahdkarrasch
authored andcommitted
Revert "Use BLAS.trsm! instead of LAPACK.trtrs! in left-triangular solves" (#1239)
Reverts #1194 since it introduced a bug into BaseBenchmarks
1 parent 5567504 commit 0a79d73

File tree

4 files changed

+5
-25
lines changed

4 files changed

+5
-25
lines changed

src/blas.jl

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ export
8484
trsm!,
8585
trsm
8686

87-
using ..LinearAlgebra: libblastrampoline, BlasReal, BlasComplex, BlasFloat, BlasInt,
88-
DimensionMismatch, checksquare, chkstride1, SingularException
87+
using ..LinearAlgebra: libblastrampoline, BlasReal, BlasComplex, BlasFloat, BlasInt, DimensionMismatch, checksquare, chkstride1
8988

9089
include("lbt.jl")
9190

@@ -1370,11 +1369,6 @@ for (fname, elty) in ((:dtrsv_,:Float64),
13701369
throw(DimensionMismatch(lazy"size of A is $n != length(x) = $(length(x))"))
13711370
end
13721371
chkstride1(A)
1373-
if diag == 'N'
1374-
for i in 1:n
1375-
iszero(A[i,i]) && throw(SingularException(i))
1376-
end
1377-
end
13781372
px, stx = vec_pointer_stride(x, ArgumentError("input vector with 0 stride is not allowed"))
13791373
GC.@preserve x ccall((@blasfunc($fname), libblastrampoline), Cvoid,
13801374
(Ref{UInt8}, Ref{UInt8}, Ref{UInt8}, Ref{BlasInt},
@@ -2223,11 +2217,6 @@ for (mmname, smname, elty) in
22232217
end
22242218
chkstride1(A)
22252219
chkstride1(B)
2226-
if diag == 'N'
2227-
for i in 1:k
2228-
iszero(A[i,i]) && throw(SingularException(i))
2229-
end
2230-
end
22312220
ccall((@blasfunc($smname), libblastrampoline), Cvoid,
22322221
(Ref{UInt8}, Ref{UInt8}, Ref{UInt8}, Ref{UInt8},
22332222
Ref{BlasInt}, Ref{BlasInt}, Ref{$elty}, Ptr{$elty},

src/triangular.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,13 +1268,11 @@ function generic_mattrimul!(C::StridedMatrix{T}, uploc, isunitc, tfun::Function,
12681268
end
12691269
end
12701270
# division
1271-
generic_trimatdiv!(C::StridedVector{T}, uploc, isunitc, tfun::Function, A::StridedMatrix{T}, B::AbstractVector{T}) where {T<:BlasFloat} =
1272-
BLAS.trsv!(uploc, tfun === identity ? 'N' : tfun === transpose ? 'T' : 'C', isunitc, A, C === B ? C : copyto!(C, B))
1273-
function generic_trimatdiv!(C::StridedMatrix{T}, uploc, isunitc, tfun::Function, A::StridedMatrix{T}, B::AbstractMatrix{T}) where {T<:BlasFloat}
1271+
function generic_trimatdiv!(C::StridedVecOrMat{T}, uploc, isunitc, tfun::Function, A::StridedMatrix{T}, B::AbstractVecOrMat{T}) where {T<:BlasFloat}
12741272
if stride(C,1) == stride(A,1) == 1
1275-
BLAS.trsm!('L', uploc, tfun === identity ? 'N' : tfun === transpose ? 'T' : 'C', isunitc, one(T), A, C === B ? C : copyto!(C, B))
1273+
LAPACK.trtrs!(uploc, tfun === identity ? 'N' : tfun === transpose ? 'T' : 'C', isunitc, A, C === B ? C : copyto!(C, B))
12761274
else # incompatible with LAPACK
1277-
@invoke generic_trimatdiv!(C::AbstractVecOrMat, uploc, isunitc, tfun::Function, A::AbstractMatrix, B::AbstractMatrix)
1275+
@invoke generic_trimatdiv!(C::AbstractVecOrMat, uploc, isunitc, tfun::Function, A::AbstractMatrix, B::AbstractVecOrMat)
12781276
end
12791277
end
12801278
function generic_mattridiv!(C::StridedMatrix{T}, uploc, isunitc, tfun::Function, A::AbstractMatrix{T}, B::StridedMatrix{T}) where {T<:BlasFloat}

test/testtriag.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,6 @@ function test_triangular(elty1_types)
493493
@test_throws DimensionMismatch transpose(Ann) \ bm
494494
if t1 == UpperTriangular || t1 == LowerTriangular
495495
@test_throws SingularException ldiv!(t1(zeros(elty1, n, n)), fill(eltyB(1), n))
496-
@test_throws SingularException ldiv!(t1(zeros(elty1, n, n)), fill(eltyB(1), n, 2))
497-
@test_throws SingularException rdiv!(fill(eltyB(1), n, n), t1(zeros(elty1, n, n)))
498496
end
499497
@test B / A1 B / M1
500498
@test B / transpose(A1) B / transpose(M1)

test/triangular.jl

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -904,13 +904,8 @@ end
904904
end
905905
end
906906

907-
@testset "(l/r)mul! and (l/r)div! for non-contiguous arrays" begin
907+
@testset "(l/r)mul! and (l/r)div! for non-contiguous matrices" begin
908908
U = UpperTriangular(reshape(collect(3:27.0),5,5))
909-
b = float.(1:10)
910-
b2 = copy(b); b2v = view(b2, 1:2:9); b2vc = copy(b2v)
911-
@test lmul!(U, b2v) == lmul!(U, b2vc)
912-
b2 = copy(b); b2v = view(b2, 1:2:9); b2vc = copy(b2v)
913-
@test ldiv!(U, b2v) ldiv!(U, b2vc)
914909
B = float.(collect(reshape(1:100, 10,10)))
915910
B2 = copy(B); B2v = view(B2, 1:2:9, 1:5); B2vc = copy(B2v)
916911
@test lmul!(U, B2v) == lmul!(U, B2vc)

0 commit comments

Comments
 (0)