Skip to content

Commit e37a60a

Browse files
Merge pull request #469 from SciML/ap/appledisable
Check appleaccelerate is available in __init__
2 parents 31784ff + 8becdf4 commit e37a60a

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "LinearSolve"
22
uuid = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
33
authors = ["SciML"]
4-
version = "2.23.1"
4+
version = "2.23.2"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

src/LinearSolve.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ end
182182
const IS_OPENBLAS = Ref(true)
183183
isopenblas() = IS_OPENBLAS[]
184184

185+
const HAS_APPLE_ACCELERATE = Ref(false)
186+
appleaccelerate_isavailable() = HAS_APPLE_ACCELERATE[]
187+
185188
PrecompileTools.@compile_workload begin
186189
A = rand(4, 4)
187190
b = rand(4)

src/appleaccelerate.jl

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,20 @@ to avoid allocations and does not require libblastrampoline.
1414
"""
1515
struct AppleAccelerateLUFactorization <: AbstractFactorization end
1616

17-
function appleaccelerate_isavailable()
18-
libacc_hdl = Libdl.dlopen_e(libacc)
19-
if libacc_hdl == C_NULL
20-
return false
21-
end
17+
@static if !Sys.isapple()
18+
__appleaccelerate_isavailable() = false
19+
else
20+
function __appleaccelerate_isavailable()
21+
libacc_hdl = Libdl.dlopen_e(libacc)
22+
if libacc_hdl == C_NULL
23+
return false
24+
end
2225

23-
if dlsym_e(libacc_hdl, "dgetrf_") == C_NULL
24-
return false
26+
if dlsym_e(libacc_hdl, "dgetrf_") == C_NULL
27+
return false
28+
end
29+
return true
2530
end
26-
return true
2731
end
2832

2933
function aa_getrf!(A::AbstractMatrix{<:ComplexF64};

src/init.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
function __init__()
22
IS_OPENBLAS[] = occursin("openblas", BLAS.get_config().loaded_libs[1].libname)
3+
4+
HAS_APPLE_ACCELERATE[] = __appleaccelerate_isavailable()
35
end

0 commit comments

Comments
 (0)