1
+ using LinearAlgebra
2
+ using Libdl
3
+
1
4
# For now, only use BLAS from Accelerate (that is to say, vecLib)
2
5
global const libacc = " /System/Library/Frameworks/Accelerate.framework/Accelerate"
3
6
@@ -12,33 +15,33 @@ to avoid allocations and does not require libblastrampoline.
12
15
struct AppleAccelerateLUFactorization <: AbstractFactorization end
13
16
14
17
function appleaccelerate_isavailable ()
15
- libacc_hdl = dlopen_e (libacc)
18
+ libacc_hdl = Libdl . dlopen_e (libacc)
16
19
if libacc_hdl == C_NULL
17
20
return false
18
21
end
19
22
20
- if dlsym_e (libacc_hdl, " dgemm \$ NEWLAPACK \$ ILP64 " ) == C_NULL
23
+ if dlsym_e (libacc_hdl, " dgetrf_ " ) == C_NULL
21
24
return false
22
25
end
23
26
return true
24
27
end
25
28
26
- function aa_getrf! (A:: AbstractMatrix{<:Float64} ; ipiv = similar (A, BlasInt , min (size (A,1 ),size (A,2 ))), info = Ref {BlasInt } (), check = false )
29
+ function aa_getrf! (A:: AbstractMatrix{<:Float64} ; ipiv = similar (A, Cint , min (size (A,1 ),size (A,2 ))), info = Ref {Cint } (), check = false )
27
30
require_one_based_indexing (A)
28
31
check && chkfinite (A)
29
32
chkstride1 (A)
30
33
m, n = size (A)
31
34
lda = max (1 ,stride (A, 2 ))
32
35
if isempty (ipiv)
33
- ipiv = similar (A, BlasInt , min (size (A,1 ),size (A,2 )))
36
+ ipiv = similar (A, Cint , min (size (A,1 ),size (A,2 )))
34
37
end
35
38
36
- ccall ((" dgetrf \$ NEWLAPACK \$ ILP64 " , libacc), Cvoid,
37
- (Ref{BlasInt }, Ref{BlasInt }, Ptr{Float64},
38
- Ref{BlasInt }, Ptr{BlasInt }, Ptr{BlasInt }),
39
+ ccall ((" dgetrf_ " , libacc), Cvoid,
40
+ (Ref{Cint }, Ref{Cint }, Ptr{Float64},
41
+ Ref{Cint }, Ptr{Cint }, Ptr{Cint }),
39
42
m, n, A, lda, ipiv, info)
40
- chkargsok ( info[])
41
- A, ipiv, info[] # Error code is stored in LU factorization type
43
+ info[] < 0 && throw ( ArgumentError ( " Invalid arguments sent to LAPACK dgetrf_ " ) )
44
+ A, Vector {BlasInt} ( ipiv), BlasInt ( info[]) # Error code is stored in LU factorization type
42
45
end
43
46
44
47
default_alias_A (:: AppleAccelerateLUFactorization , :: Any , :: Any ) = false
@@ -62,4 +65,4 @@ function SciMLBase.solve!(cache::LinearCache, alg::AppleAccelerateLUFactorizatio
62
65
end
63
66
y = ldiv! (cache. u, @get_cacheval (cache, :AppleAccelerateLUFactorization ), cache. b)
64
67
SciMLBase. build_linear_solution (alg, y, nothing , cache)
65
- end
68
+ end
0 commit comments