Skip to content

Commit

Permalink
Merge pull request #469 from SciML/ap/appledisable
Browse files Browse the repository at this point in the history
Check appleaccelerate is available in __init__
  • Loading branch information
ChrisRackauckas authored Feb 13, 2024
2 parents 31784ff + 8becdf4 commit e37a60a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LinearSolve"
uuid = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
authors = ["SciML"]
version = "2.23.1"
version = "2.23.2"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
3 changes: 3 additions & 0 deletions src/LinearSolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ end
const IS_OPENBLAS = Ref(true)
isopenblas() = IS_OPENBLAS[]

const HAS_APPLE_ACCELERATE = Ref(false)
appleaccelerate_isavailable() = HAS_APPLE_ACCELERATE[]

PrecompileTools.@compile_workload begin
A = rand(4, 4)
b = rand(4)
Expand Down
20 changes: 12 additions & 8 deletions src/appleaccelerate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@ to avoid allocations and does not require libblastrampoline.
"""
struct AppleAccelerateLUFactorization <: AbstractFactorization end

function appleaccelerate_isavailable()
libacc_hdl = Libdl.dlopen_e(libacc)
if libacc_hdl == C_NULL
return false
end
@static if !Sys.isapple()
__appleaccelerate_isavailable() = false
else
function __appleaccelerate_isavailable()
libacc_hdl = Libdl.dlopen_e(libacc)
if libacc_hdl == C_NULL
return false
end

if dlsym_e(libacc_hdl, "dgetrf_") == C_NULL
return false
if dlsym_e(libacc_hdl, "dgetrf_") == C_NULL
return false
end
return true
end
return true
end

function aa_getrf!(A::AbstractMatrix{<:ComplexF64};
Expand Down
2 changes: 2 additions & 0 deletions src/init.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
function __init__()
IS_OPENBLAS[] = occursin("openblas", BLAS.get_config().loaded_libs[1].libname)

HAS_APPLE_ACCELERATE[] = __appleaccelerate_isavailable()
end

0 comments on commit e37a60a

Please sign in to comment.