Skip to content

Commit 8a16d53

Browse files
committed
Use @static if for compile-time availability checks
Changed the availability check functions to use @static if for compile-time determination, matching the pattern used in AppleAccelerate: - Uses @static if to check @isdefined at compile time - Returns is_available() result statically when JLL is defined - Returns false statically when JLL is not defined This makes the checks more efficient as they're resolved at compile time rather than runtime. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent b47ab29 commit 8a16d53

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/mkl.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ to avoid allocations and does not require libblastrampoline.
99
struct MKLLUFactorization <: AbstractFactorization end
1010

1111
# Check if MKL is available
12-
function __mkl_isavailable()
13-
if !@isdefined(MKL_jll)
14-
return false
15-
end
16-
return MKL_jll.is_available()
12+
@static if !@isdefined(MKL_jll)
13+
__mkl_isavailable() = false
14+
else
15+
__mkl_isavailable() = MKL_jll.is_available()
1716
end
1817

1918
function getrf!(A::AbstractMatrix{<:ComplexF64};

src/openblas.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ sol = solve(prob, OpenBLASLUFactorization())
3434
struct OpenBLASLUFactorization <: AbstractFactorization end
3535

3636
# Check if OpenBLAS is available
37-
function __openblas_isavailable()
38-
if !@isdefined(OpenBLAS_jll)
39-
return false
40-
end
41-
return OpenBLAS_jll.is_available()
37+
@static if !@isdefined(OpenBLAS_jll)
38+
__openblas_isavailable() = false
39+
else
40+
__openblas_isavailable() = OpenBLAS_jll.is_available()
4241
end
4342

4443
function openblas_getrf!(A::AbstractMatrix{<:ComplexF64};

0 commit comments

Comments
 (0)