1
+ using Libdl
2
+
1
3
"""
2
4
```julia
3
5
OpenBLASLUFactorization()
@@ -33,12 +35,38 @@ sol = solve(prob, OpenBLASLUFactorization())
33
35
"""
34
36
struct OpenBLASLUFactorization <: AbstractFactorization end
35
37
36
- # OpenBLAS methods - OpenBLAS_jll is always available as a standard library
38
+ # Check if OpenBLAS is available and can be loaded
39
+ function __openblas_isavailable ()
40
+ if ! @isdefined (OpenBLAS_jll)
41
+ return false
42
+ 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
62
+ end
37
63
38
64
function openblas_getrf! (A:: AbstractMatrix{<:ComplexF64} ;
39
65
ipiv = similar (A, BlasInt, min (size (A, 1 ), size (A, 2 ))),
40
66
info = Ref {BlasInt} (),
41
67
check = false )
68
+ __openblas_isavailable () ||
69
+ error (" Error, OpenBLAS binary is missing but solve is being called. Report this issue" )
42
70
require_one_based_indexing (A)
43
71
check && chkfinite (A)
44
72
chkstride1 (A)
@@ -59,6 +87,8 @@ function openblas_getrf!(A::AbstractMatrix{<:ComplexF32};
59
87
ipiv = similar (A, BlasInt, min (size (A, 1 ), size (A, 2 ))),
60
88
info = Ref {BlasInt} (),
61
89
check = false )
90
+ __openblas_isavailable () ||
91
+ error (" Error, OpenBLAS binary is missing but solve is being called. Report this issue" )
62
92
require_one_based_indexing (A)
63
93
check && chkfinite (A)
64
94
chkstride1 (A)
@@ -79,6 +109,8 @@ function openblas_getrf!(A::AbstractMatrix{<:Float64};
79
109
ipiv = similar (A, BlasInt, min (size (A, 1 ), size (A, 2 ))),
80
110
info = Ref {BlasInt} (),
81
111
check = false )
112
+ __openblas_isavailable () ||
113
+ error (" Error, OpenBLAS binary is missing but solve is being called. Report this issue" )
82
114
require_one_based_indexing (A)
83
115
check && chkfinite (A)
84
116
chkstride1 (A)
@@ -99,6 +131,8 @@ function openblas_getrf!(A::AbstractMatrix{<:Float32};
99
131
ipiv = similar (A, BlasInt, min (size (A, 1 ), size (A, 2 ))),
100
132
info = Ref {BlasInt} (),
101
133
check = false )
134
+ __openblas_isavailable () ||
135
+ error (" Error, OpenBLAS binary is missing but solve is being called. Report this issue" )
102
136
require_one_based_indexing (A)
103
137
check && chkfinite (A)
104
138
chkstride1 (A)
@@ -120,6 +154,8 @@ function openblas_getrs!(trans::AbstractChar,
120
154
ipiv:: AbstractVector{BlasInt} ,
121
155
B:: AbstractVecOrMat{<:ComplexF64} ;
122
156
info = Ref {BlasInt} ())
157
+ __openblas_isavailable () ||
158
+ error (" Error, OpenBLAS binary is missing but solve is being called. Report this issue" )
123
159
require_one_based_indexing (A, ipiv, B)
124
160
LinearAlgebra. LAPACK. chktrans (trans)
125
161
chkstride1 (A, B, ipiv)
@@ -145,6 +181,8 @@ function openblas_getrs!(trans::AbstractChar,
145
181
ipiv:: AbstractVector{BlasInt} ,
146
182
B:: AbstractVecOrMat{<:ComplexF32} ;
147
183
info = Ref {BlasInt} ())
184
+ __openblas_isavailable () ||
185
+ error (" Error, OpenBLAS binary is missing but solve is being called. Report this issue" )
148
186
require_one_based_indexing (A, ipiv, B)
149
187
LinearAlgebra. LAPACK. chktrans (trans)
150
188
chkstride1 (A, B, ipiv)
@@ -170,6 +208,8 @@ function openblas_getrs!(trans::AbstractChar,
170
208
ipiv:: AbstractVector{BlasInt} ,
171
209
B:: AbstractVecOrMat{<:Float64} ;
172
210
info = Ref {BlasInt} ())
211
+ __openblas_isavailable () ||
212
+ error (" Error, OpenBLAS binary is missing but solve is being called. Report this issue" )
173
213
require_one_based_indexing (A, ipiv, B)
174
214
LinearAlgebra. LAPACK. chktrans (trans)
175
215
chkstride1 (A, B, ipiv)
@@ -195,6 +235,8 @@ function openblas_getrs!(trans::AbstractChar,
195
235
ipiv:: AbstractVector{BlasInt} ,
196
236
B:: AbstractVecOrMat{<:Float32} ;
197
237
info = Ref {BlasInt} ())
238
+ __openblas_isavailable () ||
239
+ error (" Error, OpenBLAS binary is missing but solve is being called. Report this issue" )
198
240
require_one_based_indexing (A, ipiv, B)
199
241
LinearAlgebra. LAPACK. chktrans (trans)
200
242
chkstride1 (A, B, ipiv)
239
281
240
282
function SciMLBase. solve! (cache:: LinearCache , alg:: OpenBLASLUFactorization ;
241
283
kwargs... )
284
+ __openblas_isavailable () ||
285
+ error (" Error, OpenBLAS binary is missing but solve is being called. Report this issue" )
242
286
A = cache. A
243
287
A = convert (AbstractMatrix, A)
244
288
if cache. isfresh
0 commit comments