Skip to content

Commit

Permalink
Check appleaccelerate is available in __init__
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Feb 12, 2024
1 parent 31784ff commit 8becdf4
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

Check warning on line 23 in src/appleaccelerate.jl

View check run for this annotation

Codecov / codecov/patch

src/appleaccelerate.jl#L20-L23

Added lines #L20 - L23 were not covered by tests
end

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

Check warning on line 27 in src/appleaccelerate.jl

View check run for this annotation

Codecov / codecov/patch

src/appleaccelerate.jl#L26-L27

Added lines #L26 - L27 were not covered by tests
end
return true

Check warning on line 29 in src/appleaccelerate.jl

View check run for this annotation

Codecov / codecov/patch

src/appleaccelerate.jl#L29

Added line #L29 was not covered by tests
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 8becdf4

Please sign in to comment.