Skip to content

Commit

Permalink
Merge pull request #424 from SciML/simplify1.9
Browse files Browse the repository at this point in the history
Simplify a ton since the bound is now v1.9
  • Loading branch information
ChrisRackauckas authored Nov 7, 2023
2 parents cea1a07 + f7e0e32 commit b9da6ac
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 133 deletions.
20 changes: 10 additions & 10 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,33 +62,33 @@ ArrayInterface = "7.4.11"
BandedMatrices = "1"
BlockDiagonals = "0.1"
ConcreteStructs = "0.2"
DocStringExtensions = "0.8, 0.9"
DocStringExtensions = "0.9"
EnumX = "1"
EnzymeCore = "0.5, 0.6"
FastLapackInterface = "1, 2"
EnzymeCore = "0.6"
FastLapackInterface = "2"
GPUArraysCore = "0.1"
HYPRE = "1.4.0"
InteractiveUtils = "1.6"
IterativeSolvers = "0.9.3"
Libdl = "1.6"
LinearAlgebra = "1.6"
LinearAlgebra = "1.9"
KLU = "0.3.0, 0.4"
KernelAbstractions = "0.9"
Krylov = "0.9"
KrylovKit = "0.5, 0.6"
KrylovKit = "0.6"
MKL = "0.6"
PrecompileTools = "1"
Preferences = "1"
RecursiveArrayTools = "2"
RecursiveFactorization = "0.2.8"
Reexport = "1"
Requires = "1"
SciMLBase = "1.82, 2"
SciMLOperators = "0.2, 0.3"
Setfield = "0.7, 0.8, 1"
SparseArrays = "1.6"
SciMLBase = "2"
SciMLOperators = "0.3"
Setfield = "1"
SparseArrays = "1.9"
Sparspak = "0.3.6"
SuiteSparse = "1.6"
SuiteSparse = "1.9"
UnPack = "1"
julia = "1.9"

Expand Down
2 changes: 1 addition & 1 deletion src/LinearSolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ PrecompileTools.@recompile_invalidations begin
import Preferences
end

if VERSION >= v"1.8" && Preferences.@load_preference("TriggerMKLLBT", true)
if Preferences.@load_preference("TriggerMKLLBT", true)
using MKL
end

Expand Down
4 changes: 1 addition & 3 deletions src/appleaccelerate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,10 @@ end
default_alias_A(::AppleAccelerateLUFactorization, ::Any, ::Any) = false
default_alias_b(::AppleAccelerateLUFactorization, ::Any, ::Any) = false

const PREALLOCATED_APPLE_LU = @static if VERSION >= v"1.8"
const PREALLOCATED_APPLE_LU = begin
A = rand(0, 0)
luinst = ArrayInterface.lu_instance(A)
LU(luinst.factors, similar(A, Cint, 0), luinst.info), Ref{Cint}()
else
nothing
end

function LinearSolve.init_cacheval(alg::AppleAccelerateLUFactorization, A, b, u, Pl, Pr,
Expand Down
26 changes: 5 additions & 21 deletions src/default.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,7 @@ function defaultalg(A::GPUArraysCore.AbstractGPUArray, b, assump::OperatorAssump
if assump.condition === OperatorCondition.IllConditioned || !assump.issq
DefaultLinearSolver(DefaultAlgorithmChoice.QRFactorization)
else
@static if VERSION >= v"1.8-"
DefaultLinearSolver(DefaultAlgorithmChoice.LUFactorization)
else
DefaultLinearSolver(DefaultAlgorithmChoice.QRFactorization)
end
DefaultLinearSolver(DefaultAlgorithmChoice.LUFactorization)
end
end

Expand All @@ -110,11 +106,7 @@ function defaultalg(A, b::GPUArraysCore.AbstractGPUArray, assump::OperatorAssump
if assump.condition === OperatorCondition.IllConditioned || !assump.issq
DefaultLinearSolver(DefaultAlgorithmChoice.QRFactorization)
else
@static if VERSION >= v"1.8-"
DefaultLinearSolver(DefaultAlgorithmChoice.LUFactorization)
else
DefaultLinearSolver(DefaultAlgorithmChoice.QRFactorization)
end
DefaultLinearSolver(DefaultAlgorithmChoice.LUFactorization)
end
end

Expand All @@ -124,11 +116,7 @@ function defaultalg(A::GPUArraysCore.AbstractGPUArray, b::GPUArraysCore.Abstract
if assump.condition === OperatorCondition.IllConditioned || !assump.issq
DefaultLinearSolver(DefaultAlgorithmChoice.QRFactorization)
else
@static if VERSION >= v"1.8-"
DefaultLinearSolver(DefaultAlgorithmChoice.LUFactorization)
else
DefaultLinearSolver(DefaultAlgorithmChoice.QRFactorization)
end
DefaultLinearSolver(DefaultAlgorithmChoice.LUFactorization)
end
end

Expand Down Expand Up @@ -162,7 +150,7 @@ function defaultalg(A, b, assump::OperatorAssumptions)
__conditioning(assump) === OperatorCondition.WellConditioned)
if length(b) <= 10
DefaultAlgorithmChoice.GenericLUFactorization
elseif VERSION >= v"1.8" && appleaccelerate_isavailable()
elseif appleaccelerate_isavailable()
DefaultAlgorithmChoice.AppleAccelerateLUFactorization
elseif (length(b) <= 100 || (isopenblas() && length(b) <= 500) ||
(usemkl && length(b) <= 200)) &&
Expand Down Expand Up @@ -327,11 +315,7 @@ function defaultalg_symbol(::Type{T}) where {T}
end
defaultalg_symbol(::Type{<:GenericFactorization{typeof(ldlt!)}}) = :LDLtFactorization

@static if VERSION >= v"1.7"
defaultalg_symbol(::Type{<:QRFactorization{ColumnNorm}}) = :QRFactorizationPivoted
else
defaultalg_symbol(::Type{<:QRFactorization{Val{true}}}) = :QRFactorizationPivoted
end
defaultalg_symbol(::Type{<:QRFactorization{ColumnNorm}}) = :QRFactorizationPivoted

"""
if alg.alg === DefaultAlgorithmChoice.LUFactorization
Expand Down
13 changes: 3 additions & 10 deletions src/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,6 @@ function set_cacheval(cache::LinearCache, alg_cache)
end
end

@static if VERSION >= v"1.9" # qualified names only supported in Julia 1.9
@deprecate SciMLBase.solve(cache::LinearCache, args...; kwargs...) SciMLBase.solve!(cache::LinearCache,
args...;
kwargs...) false
else
function SciMLBase.solve(cache::LinearCache, args...; kwargs...)
@warn "SciMLBase.solve(cache::LinearCache, args...; kwargs...) is deprecated for SciMLBase.solve!(cache::LinearCache, args...; kwargs...) to follow the CommonSolve.jl interface."
SciMLBase.solve!(cache::LinearCache, args...; kwargs...)
end
end
@deprecate SciMLBase.solve(cache::LinearCache, args...; kwargs...) SciMLBase.solve!(cache::LinearCache,
args...;
kwargs...) false
139 changes: 51 additions & 88 deletions src/extension_algs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,12 @@ sol = solve(prob, alg; Pl = prec)
"""
struct HYPREAlgorithm <: SciMLLinearSolveAlgorithm
solver::Any

@static if VERSION >= v"1.9-"
function HYPREAlgorithm(solver)
ext = Base.get_extension(@__MODULE__, :LinearSolveHYPREExt)
if ext === nothing
error("HYPREAlgorithm requires that HYPRE is loaded, i.e. `using HYPRE`")
else
return new{}(solver)
end
function HYPREAlgorithm(solver)
ext = Base.get_extension(@__MODULE__, :LinearSolveHYPREExt)
if ext === nothing
error("HYPREAlgorithm requires that HYPRE is loaded, i.e. `using HYPRE`")
else
return new{}(solver)
end
end
end
Expand All @@ -75,14 +72,12 @@ Requires a sufficiently large `A` to overcome the data transfer costs.
Using this solver requires adding the package CUDA.jl, i.e. `using CUDA`
"""
struct CudaOffloadFactorization <: LinearSolve.AbstractFactorization
@static if VERSION >= v"1.9-"
function CudaOffloadFactorization()
ext = Base.get_extension(@__MODULE__, :LinearSolveCUDAExt)
if ext === nothing
error("CudaOffloadFactorization requires that CUDA is loaded, i.e. `using CUDA`")
else
return new{}()
end
function CudaOffloadFactorization()
ext = Base.get_extension(@__MODULE__, :LinearSolveCUDAExt)
if ext === nothing
error("CudaOffloadFactorization requires that CUDA is loaded, i.e. `using CUDA`")
else
return new{}()
end
end
end
Expand Down Expand Up @@ -133,83 +128,51 @@ default handling process. This should not be required by most users.
"""
MKLPardisoIterate(; kwargs...) = PardisoJL(; solver_type = 1, kwargs...)

@static if VERSION >= v"1.9-"
"""
```julia
PardisoJL(; nprocs::Union{Int, Nothing} = nothing,
solver_type = nothing,
matrix_type = nothing,
iparm::Union{Vector{Tuple{Int, Int}}, Nothing} = nothing,
dparm::Union{Vector{Tuple{Int, Int}}, Nothing} = nothing)
```
A generic method using MKL Pardiso. Specifying `solver_type` is required.
!!! note
Using this solver requires adding the package Pardiso.jl, i.e. `using Pardiso`
## Keyword Arguments
For the definition of the keyword arguments, see the Pardiso.jl documentation.
All values default to `nothing` and the solver internally determines the values
given the input types, and these keyword arguments are only for overriding the
default handling process. This should not be required by most users.
"""
struct PardisoJL{T1, T2} <: LinearSolve.SciMLLinearSolveAlgorithm
nprocs::Union{Int, Nothing}
solver_type::T1
matrix_type::T2
iparm::Union{Vector{Tuple{Int, Int}}, Nothing}
dparm::Union{Vector{Tuple{Int, Int}}, Nothing}

function PardisoJL(; nprocs::Union{Int, Nothing} = nothing,
"""
```julia
PardisoJL(; nprocs::Union{Int, Nothing} = nothing,
solver_type = nothing,
matrix_type = nothing,
iparm::Union{Vector{Tuple{Int, Int}}, Nothing} = nothing,
dparm::Union{Vector{Tuple{Int, Int}}, Nothing} = nothing)
ext = Base.get_extension(@__MODULE__, :LinearSolvePardisoExt)
if ext === nothing
error("PardisoJL requires that Pardiso is loaded, i.e. `using Pardiso`")
else
T1 = typeof(solver_type)
T2 = typeof(matrix_type)
@assert T1 <: Union{Int, Nothing, ext.Pardiso.Solver}
@assert T2 <: Union{Int, Nothing, ext.Pardiso.MatrixType}
return new{T1, T2}(nprocs, solver_type, matrix_type, iparm, dparm)
end
```
A generic method using MKL Pardiso. Specifying `solver_type` is required.
!!! note
Using this solver requires adding the package Pardiso.jl, i.e. `using Pardiso`
## Keyword Arguments
For the definition of the keyword arguments, see the Pardiso.jl documentation.
All values default to `nothing` and the solver internally determines the values
given the input types, and these keyword arguments are only for overriding the
default handling process. This should not be required by most users.
"""
struct PardisoJL{T1, T2} <: LinearSolve.SciMLLinearSolveAlgorithm
nprocs::Union{Int, Nothing}
solver_type::T1
matrix_type::T2
iparm::Union{Vector{Tuple{Int, Int}}, Nothing}
dparm::Union{Vector{Tuple{Int, Int}}, Nothing}

function PardisoJL(; nprocs::Union{Int, Nothing} = nothing,
solver_type = nothing,
matrix_type = nothing,
iparm::Union{Vector{Tuple{Int, Int}}, Nothing} = nothing,
dparm::Union{Vector{Tuple{Int, Int}}, Nothing} = nothing)
ext = Base.get_extension(@__MODULE__, :LinearSolvePardisoExt)
if ext === nothing
error("PardisoJL requires that Pardiso is loaded, i.e. `using Pardiso`")
else
T1 = typeof(solver_type)
T2 = typeof(matrix_type)
@assert T1 <: Union{Int, Nothing, ext.Pardiso.Solver}
@assert T2 <: Union{Int, Nothing, ext.Pardiso.MatrixType}
return new{T1, T2}(nprocs, solver_type, matrix_type, iparm, dparm)
end
end
else
"""
```julia
PardisoJL(; nprocs::Union{Int, Nothing} = nothing,
solver_type = nothing,
matrix_type = nothing,
iparm::Union{Vector{Tuple{Int, Int}}, Nothing} = nothing,
dparm::Union{Vector{Tuple{Int, Int}}, Nothing} = nothing)
```
A generic method using MKL Pardiso. Specifying `solver_type` is required.
!!! note
Using this solver requires adding the package Pardiso.jl, i.e. `using Pardiso`
## Keyword Arguments
For the definition of the keyword arguments, see the Pardiso.jl documentation.
All values default to `nothing` and the solver internally determines the values
given the input types, and these keyword arguments are only for overriding the
default handling process. This should not be required by most users.
"""
Base.@kwdef struct PardisoJL <: LinearSolve.SciMLLinearSolveAlgorithm
nprocs::Union{Int, Nothing} = nothing
solver_type::Any = nothing
matrix_type::Any = nothing
iparm::Union{Vector{Tuple{Int, Int}}, Nothing} = nothing
dparm::Union{Vector{Tuple{Int, Int}}, Nothing} = nothing
end
end

"""
Expand Down

0 comments on commit b9da6ac

Please sign in to comment.