Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check appleaccelerate is available in __init__ #469

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
"""
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
Loading