Skip to content

Commit 33bf0ee

Browse files
ViralBShahLilithHafner
authored andcommitted
Simplification of libblastrampoline stuff in LinearAlgebra (JuliaLang#44360)
* Report libblastrampoline as Base.libblas_name and Base.liblapack_name * Cleanup a lot of the LBT stuff * Fix * Remove test for LinearAlgebra.LAPACK.liblapack * Fix * Fix the precompile tests
1 parent a8206c9 commit 33bf0ee

File tree

10 files changed

+15
-68
lines changed

10 files changed

+15
-68
lines changed

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ Standard library changes
4242

4343
#### LinearAlgebra
4444

45+
* We are now wholly reliant on libblastrampoline (LBT) for calling
46+
BLAS and LAPACK. OpenBLAS is shipped by default, but building the
47+
system image with other BLAS/LAPACK libraries is not
48+
supported. Instead, it is recommended that the LBT mechanism be used
49+
for swapping BLAS/LAPACK with vendor provided ones. ([#44360])
50+
4551
#### Markdown
4652

4753
#### Printf

base/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ else
4747
@echo "const MACHINE = \"$(XC_HOST)\"" >> $@
4848
endif
4949
@echo "const libm_name = \"$(LIBMNAME)\"" >> $@
50-
@echo "const libblas_name = \"$(LIBBLASNAME)\"" >> $@
51-
@echo "const liblapack_name = \"$(LIBLAPACKNAME)\"" >> $@
5250
ifeq ($(USE_BLAS64), 1)
5351
@echo "const USE_BLAS64 = true" >> $@
5452
else

stdlib/LinearAlgebra/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
44
[deps]
55
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
66
libblastrampoline_jll = "8e850b90-86db-534c-a0d3-1478176c7d93"
7+
OpenBLAS_jll = "4536629a-c528-5b80-bd46-f80d51c5b363"
78

89
[extras]
910
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

stdlib/LinearAlgebra/src/LinearAlgebra.jl

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ using Base: IndexLinear, promote_eltype, promote_op, promote_typeof,
1919
@propagate_inbounds, @pure, reduce, typed_hvcat, typed_vcat, require_one_based_indexing,
2020
splat
2121
using Base.Broadcast: Broadcasted, broadcasted
22+
using OpenBLAS_jll
23+
using libblastrampoline_jll
2224
import Libdl
2325

2426
export
@@ -563,42 +565,9 @@ function versioninfo(io::IO=stdout)
563565
return nothing
564566
end
565567

566-
function find_library_path(name)
567-
shlib_ext = string(".", Libdl.dlext)
568-
if !endswith(name, shlib_ext)
569-
name_ext = string(name, shlib_ext)
570-
end
571-
572-
# On windows, we look in `bin` and never in `lib`
573-
@static if Sys.iswindows()
574-
path = joinpath(Sys.BINDIR, name_ext)
575-
isfile(path) && return path
576-
else
577-
# On other platforms, we check `lib/julia` first, and if that doesn't exist, `lib`.
578-
path = joinpath(Sys.BINDIR, Base.LIBDIR, "julia", name_ext)
579-
isfile(path) && return path
580-
581-
path = joinpath(Sys.BINDIR, Base.LIBDIR, name_ext)
582-
isfile(path) && return path
583-
end
584-
585-
# If we can't find it by absolute path, we'll try just passing this straight through to `dlopen()`
586-
return name
587-
end
588-
589568
function __init__()
590569
try
591-
libblas_path = find_library_path(Base.libblas_name)
592-
liblapack_path = find_library_path(Base.liblapack_name)
593-
# We manually `dlopen()` these libraries here, so that we search with `libjulia-internal`'s
594-
# `RPATH` and not `libblastrampoline's`. Once it's been opened, when LBT tries to open it,
595-
# it will find the library already loaded.
596-
libblas_path = Libdl.dlpath(Libdl.dlopen(libblas_path))
597-
BLAS.lbt_forward(libblas_path; clear=true)
598-
if liblapack_path != libblas_path
599-
liblapack_path = Libdl.dlpath(Libdl.dlopen(liblapack_path))
600-
BLAS.lbt_forward(liblapack_path)
601-
end
570+
BLAS.lbt_forward(OpenBLAS_jll.libopenblas_path; clear=true)
602571
BLAS.check()
603572
catch ex
604573
Base.showerror_nostdio(ex, "WARNING: Error during initialization of module LinearAlgebra")

stdlib/LinearAlgebra/src/blas.jl

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,7 @@ export
6363
trsm!,
6464
trsm
6565

66-
# Eventually this will be replaced with `libblastrampoline_jll.libblastrampoline`
67-
const libblastrampoline = "libblastrampoline"
68-
libblastrampoline_handle = C_NULL
69-
70-
# Legacy bindings that some packages (such as NNlib.jl) use.
71-
# We maintain these for backwards-compatibility but new packages
72-
# should not look at these, instead preferring to parse the output
73-
# of BLAS.get_config()
74-
const libblas = libblastrampoline
75-
const liblapack = libblastrampoline
76-
77-
import LinearAlgebra
78-
using LinearAlgebra: BlasReal, BlasComplex, BlasFloat, BlasInt, DimensionMismatch, checksquare, stride1, chkstride1
66+
using ..LinearAlgebra: libblastrampoline, BlasReal, BlasComplex, BlasFloat, BlasInt, DimensionMismatch, checksquare, stride1, chkstride1
7967

8068
include("lbt.jl")
8169

stdlib/LinearAlgebra/src/lapack.jl

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,9 @@ module LAPACK
55
Interfaces to LAPACK subroutines.
66
""" LAPACK
77

8-
const libblastrampoline = "libblastrampoline"
9-
10-
# Legacy binding maintained for backwards-compatibility but new packages
11-
# should not look at this, instead preferring to parse the output
12-
# of BLAS.get_config()
13-
const liblapack = libblastrampoline
14-
158
using ..LinearAlgebra.BLAS: @blasfunc, chkuplo
169

17-
using ..LinearAlgebra: BlasFloat, BlasInt, LAPACKException, DimensionMismatch,
10+
using ..LinearAlgebra: libblastrampoline, BlasFloat, BlasInt, LAPACKException, DimensionMismatch,
1811
SingularException, PosDefException, chkstride1, checksquare,triu, tril, dot
1912

2013
using Base: iszero, require_one_based_indexing

stdlib/LinearAlgebra/test/blas.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -668,10 +668,6 @@ end
668668
@test BLAS.get_num_threads() === default
669669
end
670670

671-
# https://github.com/JuliaLang/julia/pull/39845
672-
@test LinearAlgebra.BLAS.libblas == "libblastrampoline"
673-
@test LinearAlgebra.BLAS.liblapack == "libblastrampoline"
674-
675671
@testset "test for 0-strides" for elty in (Float32, Float64, ComplexF32, ComplexF64)
676672
A = randn(elty, 10, 10);
677673
a = view([randn(elty)], 1 .+ 0(1:10))

stdlib/LinearAlgebra/test/lapack.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -702,9 +702,6 @@ let A = [NaN NaN; NaN NaN]
702702
@test_throws ArgumentError eigen(A)
703703
end
704704

705-
# # https://github.com/JuliaLang/julia/pull/39845
706-
@test LinearAlgebra.LAPACK.liblapack == "libblastrampoline"
707-
708705
# Issue #42762 https://github.com/JuliaLang/julia/issues/42762
709706
# Tests geqrf! and gerqf! with null column dimensions
710707
a = zeros(2,0), zeros(0)

stdlib/libblastrampoline_jll/Project.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ version = "5.0.1+0"
55
[deps]
66
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
77
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
8-
OpenBLAS_jll = "4536629a-c528-5b80-bd46-f80d51c5b363"
98

109
[compat]
1110
julia = "1.8"

test/precompile.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,10 @@ precompile_test_harness(false) do dir
359359
Dict(let m = Base.root_module(Base, s)
360360
Base.PkgId(m) => Base.module_build_id(m)
361361
end for s in
362-
[:ArgTools, :Artifacts, :Base64, :CRC32c, :Dates, :DelimitedFiles,
363-
:Distributed, :Downloads, :FileWatching, :Future, :InteractiveUtils,
362+
[:ArgTools, :Artifacts, :Base64, :CompilerSupportLibraries_jll, :CRC32c, :Dates, :DelimitedFiles,
363+
:Distributed, :Downloads, :FileWatching, :Future, :InteractiveUtils, :libblastrampoline_jll,
364364
:LazyArtifacts, :LibCURL, :LibCURL_jll, :LibGit2, :Libdl, :LinearAlgebra,
365-
:Logging, :Markdown, :Mmap, :MozillaCACerts_jll, :NetworkOptions, :Pkg, :Printf,
365+
:Logging, :Markdown, :Mmap, :MozillaCACerts_jll, :NetworkOptions, :OpenBLAS_jll, :Pkg, :Printf,
366366
:Profile, :p7zip_jll, :REPL, :Random, :SHA, :Serialization, :SharedArrays, :Sockets,
367367
:SparseArrays, :Statistics, :SuiteSparse, :TOML, :Tar, :Test, :UUIDs, :Unicode,
368368
:nghttp2_jll]

0 commit comments

Comments
 (0)