Skip to content

Commit b277456

Browse files
Safety measures around AppleAccelerate (#676)
```julia Enzyme Derivative Rules: Error During Test at /home/runner/.julia/packages/SafeTestsets/raUNr/src/SafeTestsets.jl:30 Got exception outside of a @test LoadError: could not load library "/System/Library/Frameworks/Accelerate.framework/Accelerate" /System/Library/Frameworks/Accelerate.framework/Accelerate.so: cannot open shared object file: No such file or directory Stacktrace: [1] fix_ptr_lookup(name::String) @ Enzyme.Compiler.JIT ~/.julia/packages/Enzyme/LMVya/src/compiler/orcv2.jl:63 [2] add!(mod::LLVM.Module) @ Enzyme.Compiler.JIT ~/.julia/packages/Enzyme/LMVya/src/compiler/orcv2.jl:251 [3] _link(job::GPUCompiler.CompilerJob{<:Enzyme.Compiler.EnzymeTarget}, mod::LLVM.Module, edges::Vector{Any}, adjoint_name::String, primal_name::Union{Nothing, String}, TapeType::Any, prepost::String) @ Enzyme.Compiler ~/.julia/packages/Enzyme/LMVya/src/compiler.jl:5661 [4] cached_compilation @ ~/.julia/packages/Enzyme/LMVya/src/compiler.jl:5750 ``` Basically, you can't do option dependencies, but BinaryBuilder just simply sends no binary if the platform isn't supported. So LinearSolve.jl always has a dependency on AppleAccelerate, and if the binary exists it defaults to it (since it's pretty much always the fastest on M-series mac) and otherwise it disables it. Enzyme still seems to want to try to call it, so this should fix that.
1 parent f468950 commit b277456

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/appleaccelerate.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ function aa_getrf!(A::AbstractMatrix{<:ComplexF64};
3434
ipiv = similar(A, Cint, min(size(A, 1), size(A, 2))),
3535
info = Ref{Cint}(),
3636
check = false)
37+
__appleaccelerate_isavailable() ||
38+
error("Error, AppleAccelerate binary is missing but solve is being called. Report this issue")
3739
require_one_based_indexing(A)
3840
check && chkfinite(A)
3941
chkstride1(A)
@@ -54,6 +56,8 @@ function aa_getrf!(A::AbstractMatrix{<:ComplexF32};
5456
ipiv = similar(A, Cint, min(size(A, 1), size(A, 2))),
5557
info = Ref{Cint}(),
5658
check = false)
59+
__appleaccelerate_isavailable() ||
60+
error("Error, AppleAccelerate binary is missing but solve is being called. Report this issue")
5761
require_one_based_indexing(A)
5862
check && chkfinite(A)
5963
chkstride1(A)
@@ -74,6 +78,8 @@ function aa_getrf!(A::AbstractMatrix{<:Float64};
7478
ipiv = similar(A, Cint, min(size(A, 1), size(A, 2))),
7579
info = Ref{Cint}(),
7680
check = false)
81+
__appleaccelerate_isavailable() ||
82+
error("Error, AppleAccelerate binary is missing but solve is being called. Report this issue")
7783
require_one_based_indexing(A)
7884
check && chkfinite(A)
7985
chkstride1(A)
@@ -94,6 +100,8 @@ function aa_getrf!(A::AbstractMatrix{<:Float32};
94100
ipiv = similar(A, Cint, min(size(A, 1), size(A, 2))),
95101
info = Ref{Cint}(),
96102
check = false)
103+
__appleaccelerate_isavailable() ||
104+
error("Error, AppleAccelerate binary is missing but solve is being called. Report this issue")
97105
require_one_based_indexing(A)
98106
check && chkfinite(A)
99107
chkstride1(A)
@@ -116,6 +124,8 @@ function aa_getrs!(trans::AbstractChar,
116124
ipiv::AbstractVector{Cint},
117125
B::AbstractVecOrMat{<:ComplexF64};
118126
info = Ref{Cint}())
127+
__appleaccelerate_isavailable() ||
128+
error("Error, AppleAccelerate binary is missing but solve is being called. Report this issue")
119129
require_one_based_indexing(A, ipiv, B)
120130
LinearAlgebra.LAPACK.chktrans(trans)
121131
chkstride1(A, B, ipiv)
@@ -140,6 +150,8 @@ function aa_getrs!(trans::AbstractChar,
140150
ipiv::AbstractVector{Cint},
141151
B::AbstractVecOrMat{<:ComplexF32};
142152
info = Ref{Cint}())
153+
__appleaccelerate_isavailable() ||
154+
error("Error, AppleAccelerate binary is missing but solve is being called. Report this issue")
143155
require_one_based_indexing(A, ipiv, B)
144156
LinearAlgebra.LAPACK.chktrans(trans)
145157
chkstride1(A, B, ipiv)
@@ -165,6 +177,8 @@ function aa_getrs!(trans::AbstractChar,
165177
ipiv::AbstractVector{Cint},
166178
B::AbstractVecOrMat{<:Float64};
167179
info = Ref{Cint}())
180+
__appleaccelerate_isavailable() ||
181+
error("Error, AppleAccelerate binary is missing but solve is being called. Report this issue")
168182
require_one_based_indexing(A, ipiv, B)
169183
LinearAlgebra.LAPACK.chktrans(trans)
170184
chkstride1(A, B, ipiv)
@@ -190,6 +204,8 @@ function aa_getrs!(trans::AbstractChar,
190204
ipiv::AbstractVector{Cint},
191205
B::AbstractVecOrMat{<:Float32};
192206
info = Ref{Cint}())
207+
__appleaccelerate_isavailable() ||
208+
error("Error, AppleAccelerate binary is missing but solve is being called. Report this issue")
193209
require_one_based_indexing(A, ipiv, B)
194210
LinearAlgebra.LAPACK.chktrans(trans)
195211
chkstride1(A, B, ipiv)
@@ -236,6 +252,8 @@ end
236252

237253
function SciMLBase.solve!(cache::LinearCache, alg::AppleAccelerateLUFactorization;
238254
kwargs...)
255+
__appleaccelerate_isavailable() ||
256+
error("Error, AppleAccelerate binary is missing but solve is being called. Report this issue")
239257
A = cache.A
240258
A = convert(AbstractMatrix, A)
241259
if cache.isfresh

0 commit comments

Comments
 (0)