Skip to content

Commit 0ebbdd0

Browse files
Fix performance of AppleAccelerate check for Enzyme (#755)
Fixes a big performance regression
1 parent 3d4482e commit 0ebbdd0

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/appleaccelerate.jl

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,18 @@ to avoid allocations and does not require libblastrampoline.
1414
"""
1515
struct AppleAccelerateLUFactorization <: AbstractFactorization end
1616

17-
17+
# To make Enzyme happy, this has to be static
1818
@static if !Sys.isapple()
19+
const AA_IS_AVAILABLE = false
1920
__appleaccelerate_isavailable() = false
2021
else
21-
function __appleaccelerate_isavailable()
22-
libacc_hdl = Libdl.dlopen_e(libacc)
23-
if libacc_hdl == C_NULL
24-
return false
25-
end
26-
27-
if dlsym_e(libacc_hdl, "dgetrf_") == C_NULL
28-
return false
29-
end
30-
return true
22+
@static if Libdl.dlopen_e(libacc) == C_NULL
23+
__appleaccelerate_isavailable() = false
24+
end
25+
@static if dlsym_e(Libdl.dlopen_e(libacc), "dgetrf_") == C_NULL
26+
__appleaccelerate_isavailable() = false
27+
else
28+
__appleaccelerate_isavailable() = true
3129
end
3230
end
3331

0 commit comments

Comments
 (0)