Skip to content

Commit 8555f03

Browse files
authored
Move use_* extension functions to their respective extensions (#784)
This will technically invalidate when loading this extensions, but most of their implementation does that already by design so this at least resolves #778.
1 parent 174d8a9 commit 8555f03

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

ext/LinearSolveBLISExt.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ using SciMLBase: ReturnCode
1515
const global libblis = blis_jll.blis
1616
const global liblapack = LAPACK_jll.liblapack
1717

18+
LinearSolve.useblis() = true
19+
1820
function getrf!(A::AbstractMatrix{<:ComplexF64};
1921
ipiv = similar(A, BlasInt, min(size(A, 1), size(A, 2))),
2022
info = Ref{BlasInt}(),

ext/LinearSolveCUDAExt.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ using LinearSolve: LinearSolve, is_cusparse, defaultalg, cudss_loaded, DefaultLi
1111
using LinearSolve.LinearAlgebra, LinearSolve.SciMLBase, LinearSolve.ArrayInterface
1212
using SciMLBase: AbstractSciMLOperator
1313

14+
LinearSolve.usecuda() = CUDA.functional()
15+
1416
function LinearSolve.is_cusparse(A::Union{
1517
CUDA.CUSPARSE.CuSparseMatrixCSR, CUDA.CUSPARSE.CuSparseMatrixCSC})
1618
true

ext/LinearSolveMetalExt.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ using SciMLBase: AbstractSciMLOperator
66
using LinearSolve: ArrayInterface, MKLLUFactorization, MetalOffload32MixedLUFactorization,
77
@get_cacheval, LinearCache, SciMLBase, OperatorAssumptions
88

9+
@static if Sys.isapple()
10+
11+
LinearSolve.usemetal() = true
12+
13+
end
14+
915
default_alias_A(::MetalLUFactorization, ::Any, ::Any) = false
1016
default_alias_b(::MetalLUFactorization, ::Any, ::Any) = false
1117

src/LinearSolve.jl

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -436,18 +436,9 @@ const HAS_APPLE_ACCELERATE = Ref(false)
436436
appleaccelerate_isavailable() = HAS_APPLE_ACCELERATE[]
437437

438438
# Extension availability checking functions
439-
useblis() = Base.get_extension(@__MODULE__, :LinearSolveBLISExt) !== nothing
440-
function usecuda()
441-
ext = Base.get_extension(@__MODULE__, :LinearSolveCUDAExt)
442-
!isnothing(ext) && ext.CUDA.functional()
443-
end
444-
445-
# Metal is only available on Apple platforms
446-
@static if !Sys.isapple()
447-
usemetal() = false
448-
else
449-
usemetal() = Base.get_extension(@__MODULE__, :LinearSolveMetalExt) !== nothing
450-
end
439+
useblis() = false
440+
usecuda() = false
441+
usemetal() = false
451442

452443
PrecompileTools.@compile_workload begin
453444
A = rand(4, 4)

0 commit comments

Comments
 (0)