Skip to content

Commit

Permalink
Work around issue with truncated Float32 representation of lwork in
Browse files Browse the repository at this point in the history
sgesdd by using nextfloat. Now with comments and test so this commit
supersedes ad59ceb

See

http://icl.cs.utk.edu/lapack-forum/viewtopic.php?f=13&t=4587&p=11036&hilit=sgesdd#p11036

and

scipy/scipy#5401

Fixes #15784
  • Loading branch information
andreasnoack committed Apr 11, 2016
1 parent 365a0b9 commit b6988df
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion base/linalg/lapack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1572,7 +1572,12 @@ for (geev, gesvd, gesdd, ggsvd, elty, relty) in
end
chklapackerror(info[])
if i == 1
lwork = BlasInt(real(work[1]))
# Work around issue with truncated Float32 representation of lwork in
# sgesdd by using nextfloat. See
# http://icl.cs.utk.edu/lapack-forum/viewtopic.php?f=13&t=4587&p=11036&hilit=sgesdd#p11036
# and
# https://github.com/scipy/scipy/issues/5401
lwork = round(BlasInt, nextfloat(real(work[1])))
work = Array($elty, lwork)
end
end
Expand Down
7 changes: 7 additions & 0 deletions test/perf/lapack/perf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ include("../perfutil.jl")

include("eig.jl")
include("factorizations.jl")

# The test below is not a perf test but it takes too long for the normal test suite.
# This tests a work around for a bug in LAPACK where the work space is truncated
# to a too small number because the number is too big to be represented as a Float32.
# See the calculation for lwork in our sgesdd wrapper in lapack.jl.
println("testing work space bug in sgesdd")
svd(rand(Float32, 9537, 9537))

0 comments on commit b6988df

Please sign in to comment.