Skip to content

Commit b47ab29

Browse files
committed
Simplify availability checks - remove try/catch and symbol checking
Per review feedback, simplified the availability checks: - Removed try/catch blocks as they're unnecessary - Removed Libdl symbol checking - if the binary exists via is_available(), it's fine - Just check if the JLL module is defined and is_available() returns true This makes the code cleaner and follows the principle that if the binary exists, we can trust it has the required symbols. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 44e3032 commit b47ab29

File tree

2 files changed

+4
-44
lines changed

2 files changed

+4
-44
lines changed

src/mkl.jl

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using Libdl
2-
31
"""
42
```julia
53
MKLLUFactorization()
@@ -10,30 +8,12 @@ to avoid allocations and does not require libblastrampoline.
108
"""
119
struct MKLLUFactorization <: AbstractFactorization end
1210

13-
# Check if MKL is available and can be loaded
11+
# Check if MKL is available
1412
function __mkl_isavailable()
1513
if !@isdefined(MKL_jll)
1614
return false
1715
end
18-
if !MKL_jll.is_available()
19-
return false
20-
end
21-
# Try to load the library and check for required symbols
22-
try
23-
mkl_hdl = Libdl.dlopen(MKL_jll.libmkl_rt)
24-
if mkl_hdl == C_NULL
25-
return false
26-
end
27-
# Check for a required symbol
28-
if Libdl.dlsym_e(mkl_hdl, "dgetrf_") == C_NULL
29-
Libdl.dlclose(mkl_hdl)
30-
return false
31-
end
32-
Libdl.dlclose(mkl_hdl)
33-
return true
34-
catch
35-
return false
36-
end
16+
return MKL_jll.is_available()
3717
end
3818

3919
function getrf!(A::AbstractMatrix{<:ComplexF64};

src/openblas.jl

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using Libdl
2-
31
"""
42
```julia
53
OpenBLASLUFactorization()
@@ -35,30 +33,12 @@ sol = solve(prob, OpenBLASLUFactorization())
3533
"""
3634
struct OpenBLASLUFactorization <: AbstractFactorization end
3735

38-
# Check if OpenBLAS is available and can be loaded
36+
# Check if OpenBLAS is available
3937
function __openblas_isavailable()
4038
if !@isdefined(OpenBLAS_jll)
4139
return false
4240
end
43-
if !OpenBLAS_jll.is_available()
44-
return false
45-
end
46-
# Try to load the library and check for required symbols
47-
try
48-
openblas_hdl = Libdl.dlopen(OpenBLAS_jll.libopenblas)
49-
if openblas_hdl == C_NULL
50-
return false
51-
end
52-
# Check for a required symbol
53-
if Libdl.dlsym_e(openblas_hdl, "dgetrf_") == C_NULL
54-
Libdl.dlclose(openblas_hdl)
55-
return false
56-
end
57-
Libdl.dlclose(openblas_hdl)
58-
return true
59-
catch
60-
return false
61-
end
41+
return OpenBLAS_jll.is_available()
6242
end
6343

6444
function openblas_getrf!(A::AbstractMatrix{<:ComplexF64};

0 commit comments

Comments
 (0)