Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- "LinearSolveHYPRE"
- "LinearSolvePardiso"
- "LinearSolveBandedMatrices"
- "Enzyme"
- "NoPre"
uses: "SciML/.github/.github/workflows/tests.yml@v1"
with:
group: "${{ matrix.group }}"
Expand Down
6 changes: 1 addition & 5 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ ChainRulesCore = "1.22"
ConcreteStructs = "0.2.3"
DocStringExtensions = "0.9.3"
EnumX = "1.0.4"
Enzyme = "0.13"
EnzymeCore = "0.8.1"
FastAlmostBandedMatrices = "0.1"
FastLapackInterface = "2"
Expand All @@ -85,7 +84,6 @@ GPUArraysCore = "0.1.6, 0.2"
HYPRE = "1.4.0"
InteractiveUtils = "1.10"
IterativeSolvers = "0.9.3"
JET = "0.8.28, 0.9"
KernelAbstractions = "0.9.27"
Krylov = "0.10"
KrylovKit = "0.8, 0.9"
Expand Down Expand Up @@ -124,15 +122,13 @@ AllocCheck = "9b6a8646-10ed-4001-bbdc-1d2f46dfbb1a"
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
BlockDiagonals = "0a1fb500-61f7-11e9-3c65-f5ef3456f9f0"
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
FastAlmostBandedMatrices = "9d29842c-ecb8-4973-b1e9-a27b1157504e"
FastLapackInterface = "29a986be-02c6-4525-aec4-84b980013641"
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
HYPRE = "b5ffcf37-a2bd-41ab-a3da-4bd9bc8ad771"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
IterativeSolvers = "42fd0dbc-a981-5370-80f2-aaf504508153"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
KrylovKit = "0b1a1467-8014-51b9-945f-bf0ae24f4b77"
KrylovPreconditioners = "45d422c2-293f-44ce-8315-2cb988662dec"
Expand All @@ -152,4 +148,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[targets]
test = ["Aqua", "Test", "IterativeSolvers", "InteractiveUtils", "JET", "KrylovKit", "KrylovPreconditioners", "Pkg", "Random", "SafeTestsets", "MultiFloats", "ForwardDiff", "HYPRE", "MPI", "BlockDiagonals", "Enzyme", "FiniteDiff", "BandedMatrices", "FastAlmostBandedMatrices", "StaticArrays", "AllocCheck", "StableRNGs", "Zygote", "RecursiveFactorization", "Sparspak", "FastLapackInterface", "SparseArrays"]
test = ["Aqua", "Test", "IterativeSolvers", "InteractiveUtils", "KrylovKit", "KrylovPreconditioners", "Pkg", "Random", "SafeTestsets", "MultiFloats", "ForwardDiff", "HYPRE", "MPI", "BlockDiagonals", "FiniteDiff", "BandedMatrices", "FastAlmostBandedMatrices", "StaticArrays", "AllocCheck", "StableRNGs", "Zygote", "RecursiveFactorization", "Sparspak", "FastLapackInterface", "SparseArrays"]
28 changes: 10 additions & 18 deletions src/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ function SciMLBase.reinit!(cache::LinearCache;
b = cache.b,
u = cache.u,
p = nothing,
reinit_cache = false,
reuse_precs = false)
(; alg, cacheval, abstol, reltol, maxiters, verbose, assumptions, sensealg) = cache

Expand All @@ -270,23 +269,16 @@ function SciMLBase.reinit!(cache::LinearCache;
p = isnothing(p) ? cache.p : p
Pl = cache.Pl
Pr = cache.Pr
if reinit_cache
return LinearCache{
typeof(A), typeof(b), typeof(u), typeof(p), typeof(alg), typeof(cacheval),
typeof(Pl), typeof(Pr), typeof(reltol), typeof(assumptions.issq),
typeof(sensealg)}(
A, b, u, p, alg, cacheval, precsisfresh, isfresh, Pl, Pr, abstol, reltol,
maxiters, verbose, assumptions, sensealg)
else
cache.A = A
cache.b = b
cache.u = u
cache.p = p
cache.Pl = Pl
cache.Pr = Pr
cache.isfresh = true
cache.precsisfresh = precsisfresh
end

cache.A = A
cache.b = b
cache.u = u
cache.p = p
cache.Pl = Pl
cache.Pr = Pr
cache.isfresh = true
cache.precsisfresh = precsisfresh
nothing
end

function SciMLBase.solve(prob::LinearProblem, args...; kwargs...)
Expand Down
15 changes: 2 additions & 13 deletions test/default_algs.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using LinearSolve, RecursiveFactorization, LinearAlgebra, SparseArrays, Test, JET
using LinearSolve, RecursiveFactorization, LinearAlgebra, SparseArrays, Test

@test LinearSolve.defaultalg(nothing, zeros(3)).alg ===
LinearSolve.DefaultAlgorithmChoice.GenericLUFactorization
prob = LinearProblem(rand(3, 3), rand(3))
Expand Down Expand Up @@ -55,19 +56,7 @@ solve(prob)
A = rand(4, 4)
b = rand(4)
prob = LinearProblem(A, b)
VERSION ≥ v"1.10-" && JET.@test_opt init(prob, nothing)
JET.@test_opt solve(prob, LUFactorization())
JET.@test_opt solve(prob, GenericLUFactorization())
@test_skip JET.@test_opt solve(prob, QRFactorization())
JET.@test_opt solve(prob, DiagonalFactorization())
#JET.@test_opt solve(prob, SVDFactorization())
#JET.@test_opt solve(prob, KrylovJL_GMRES())

prob = LinearProblem(sparse(A), b)
#JET.@test_opt solve(prob, UMFPACKFactorization())
#JET.@test_opt solve(prob, KLUFactorization())
#JET.@test_opt solve(prob, SparspakFactorization())
#JET.@test_opt solve(prob)
@inferred solve(prob)
@inferred init(prob, nothing)

Expand Down
10 changes: 10 additions & 0 deletions test/nopre/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[deps]
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
RecursiveFactorization = "f2c3362d-daeb-58d1-803e-2bc74f2840b4"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
File renamed without changes.
19 changes: 19 additions & 0 deletions test/nopre/jet.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using LinearSolve, RecursiveFactorization, LinearAlgebra, SparseArrays, Test
using JET

A = rand(4, 4)
b = rand(4)
prob = LinearProblem(A, b)
JET.@test_opt init(prob, nothing)
JET.@test_opt solve(prob, LUFactorization())
JET.@test_opt solve(prob, GenericLUFactorization())
@test_skip JET.@test_opt solve(prob, QRFactorization())
JET.@test_opt solve(prob, DiagonalFactorization())
#JET.@test_opt solve(prob, SVDFactorization())
#JET.@test_opt solve(prob, KrylovJL_GMRES())

prob = LinearProblem(sparse(A), b)
#JET.@test_opt solve(prob, UMFPACKFactorization())
#JET.@test_opt solve(prob, KLUFactorization())
#JET.@test_opt solve(prob, SparspakFactorization())
#JET.@test_opt solve(prob)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
#JET.@test_opt solve(prob)
#JET.@test_opt solve(prob)

11 changes: 8 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ if GROUP == "All" || GROUP == "Core"
@time @safetestset "Static Arrays" include("static_arrays.jl")
end

if GROUP == "All" || GROUP == "Enzyme"
@time @safetestset "Enzyme Derivative Rules" include("enzyme.jl")
# Don't run Enzyme tests on prerelease
if GROUP == "All" || GROUP == "NoPre" && isempty(VERSION.prerelease)
Pkg.activate("nopre")
Pkg.develop(PackageSpec(path = dirname(@__DIR__)))
Pkg.instantiate()
@time @safetestset "Enzyme Derivative Rules" include("nopre/enzyme.jl")
@time @safetestset "JET Tests" include("nopre/jet.jl")
end

if GROUP == "DefaultsLoading"
@time @safetestset "Enzyme Derivative Rules" include("defaults_loading.jl")
@time @safetestset "Defaults Loading Tests" include("defaults_loading.jl")
end

if GROUP == "LinearSolveCUDA"
Expand Down
8 changes: 6 additions & 2 deletions test/static_arrays.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
using LinearSolve, StaticArrays, LinearAlgebra, Test, StableRNGs
using AllocCheck

rng = StableRNG(0)

A = SMatrix{5, 5}(Hermitian(rand(rng, 5, 5) + I))
b = SVector{5}(rand(rng, 5))

@check_allocs __solve_no_alloc(A, b, alg) = solve(LinearProblem(A, b), alg)
if isempty(VERSION.prerelease)
using AllocCheck
@check_allocs __solve_no_alloc(A, b, alg) = solve(LinearProblem(A, b), alg)
else
__solve_no_alloc(A, b, alg) = solve(LinearProblem(A, b), alg)
end

function __non_native_static_array_alg(alg)
return alg isa SVDFactorization || alg isa KrylovJL
Expand Down
Loading