Skip to content

Commit 1abbd37

Browse files
authored
use libblastrampoline instead of libblas/liblapack (#157)
* don't import libblas/liblapack * bump version to v0.6.9 * add tests * tests for hesseneigvals * tests for gemm
1 parent fc1b2cb commit 1abbd37

File tree

4 files changed

+56
-5
lines changed

4 files changed

+56
-5
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ApproxFunBase"
22
uuid = "fbd15aa5-315a-5a7d-a8a4-24992e37be05"
3-
version = "0.6.8"
3+
version = "0.6.9"
44

55
[deps]
66
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"

src/LinearAlgebra/blas.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import LinearAlgebra.BLAS: @blasfunc, libblas
2-
import LinearAlgebra.LAPACK: liblapack
1+
import LinearAlgebra.BLAS: @blasfunc
2+
const libblas = VERSION < v"1.8" ? LinearAlgebra.BLAS.libblas : "libblastrampoline"
3+
const liblapack = VERSION < v"1.8" ? LinearAlgebra.LAPACK.liblapack : "libblastrampoline"
4+
35
# Level 2
46
## mv
57
### gemv

src/LinearAlgebra/hesseneigs.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ for (hseqr,elty) in ((:zhseqr_,:ComplexF64),)
2222

2323
Ec='E'
2424
Nc='N'
25-
ccall((@blasfunc($hseqr),LAPACK.liblapack),
25+
ccall((@blasfunc($hseqr),liblapack),
2626
Nothing,
2727
(Ref{UInt8}, Ref{UInt8},
2828
Ref{BlasInt}, Ref{BlasInt}, Ref{BlasInt}, Ptr{$elty}, #A
@@ -59,7 +59,7 @@ for (hseqr,elty) in ((:dhseqr_,:Float64),)
5959
Ec='E'
6060
Nc='N'
6161
for i=1:2
62-
ccall((@blasfunc($hseqr),LAPACK.liblapack),
62+
ccall((@blasfunc($hseqr),liblapack),
6363
Nothing,
6464
(Ref{UInt8},Ref{UInt8},
6565
Ref{BlasInt},Ref{BlasInt},Ref{BlasInt},Ptr{$elty}, #A

test/runtests.jl

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,5 +230,54 @@ end
230230
@test a[2] exp(1)
231231
end
232232

233+
@testset "BLAS/LAPACK" begin
234+
@testset "gemv" begin
235+
# test for the pointer versions, and assert that libblastrampoline works
236+
@testset for T in [Float32, Float64, ComplexF32, ComplexF64]
237+
a = zeros(T, 4)
238+
b = zeros(T, 4)
239+
A = Matrix{T}(I,4,4)
240+
x = T[1:4;]
241+
α, β = T(1.0), T(0.0)
242+
ApproxFunBase.gemv!('N', α, A, x, β, a)
243+
LinearAlgebra.BLAS.gemv!('N', α, A, x, β, b)
244+
@test a == b == x
245+
β = T(1.0)
246+
ApproxFunBase.gemv!('N', α, A, x, β, a)
247+
LinearAlgebra.BLAS.gemv!('N', α, A, x, β, b)
248+
@test a == b == 2x
249+
end
250+
end
251+
252+
@testset "gemm" begin
253+
# test for the pointer versions, and assert that libblastrampoline works
254+
@testset for T in [Float32, Float64, ComplexF32, ComplexF64]
255+
C1 = zeros(T, 4, 4)
256+
C2 = zeros(T, 4, 4)
257+
A = Matrix{T}(I,4,4)
258+
B = reshape(T[1:16;], 4, 4)
259+
α, β = T(1.0), T(0.0)
260+
ApproxFunBase.gemm!('N', 'N', α, A, B, β, C1)
261+
LinearAlgebra.BLAS.gemm!('N', 'N', α, A, B, β, C2)
262+
@test C1 == C2 == B
263+
β = T(1.0)
264+
ApproxFunBase.gemm!('N', 'N', α, A, B, β, C1)
265+
LinearAlgebra.BLAS.gemm!('N', 'N', α, A, B, β, C2)
266+
@test C1 == C2 == 2B
267+
end
268+
end
269+
270+
@testset "hesseneigs" begin
271+
A = Float64[1 4 2 3; 1 4 1 7; 0 2 3 4; 0 0 1 3]
272+
λ1 = sort(ApproxFunBase.hesseneigvals(A), by = x->(real(x), imag(x)))
273+
λ2 = eigvals(A)
274+
@test λ1 λ2
275+
B = ComplexF64.(A)
276+
λ1 = sort(ApproxFunBase.hesseneigvals(B), by = x->(real(x), imag(x)))
277+
λ2 = eigvals(B)
278+
@test λ1 λ2
279+
end
280+
end
281+
233282
@time include("ETDRK4Test.jl")
234283
include("show.jl")

0 commit comments

Comments
 (0)