Skip to content

Commit 796b864

Browse files
Improve JET tests to cover all solvers
This commit significantly expands the JET test coverage for LinearSolve.jl to test every available solver type. The improvements include: - **Complete solver coverage**: Added JET tests for all dense factorizations, sparse factorizations, Krylov methods, and extension-based solvers - **Proper test organization**: Organized tests into logical groups with clear testsets for better readability and maintenance - **Appropriate test problems**: Created specific test problems (symmetric, SPD, sparse) for solvers that require them - **Graceful failure handling**: Used @test_skip for tests that currently fail JET optimization checks, making them visible without blocking CI - **Platform-specific handling**: Added conditional checks for platform-specific solvers (MKL, Apple Accelerate) The tests now provide comprehensive coverage while properly handling expected failures, making it easier to track and improve type stability across the codebase. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent b86d145 commit 796b864

File tree

1 file changed

+95
-13
lines changed

1 file changed

+95
-13
lines changed

test/nopre/jet.jl

Lines changed: 95 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,101 @@
11
using LinearSolve, RecursiveFactorization, LinearAlgebra, SparseArrays, Test
22
using JET
33

4+
# Dense problem setup
45
A = rand(4, 4)
56
b = rand(4)
67
prob = LinearProblem(A, b)
7-
JET.@test_opt init(prob, nothing)
8-
JET.@test_opt solve(prob, LUFactorization())
9-
JET.@test_opt solve(prob, GenericLUFactorization())
10-
@test_skip JET.@test_opt solve(prob, QRFactorization())
11-
JET.@test_opt solve(prob, DiagonalFactorization())
12-
#JET.@test_opt solve(prob, SVDFactorization())
13-
#JET.@test_opt solve(prob, KrylovJL_GMRES())
14-
15-
prob = LinearProblem(sparse(A), b)
16-
#JET.@test_opt solve(prob, UMFPACKFactorization())
17-
#JET.@test_opt solve(prob, KLUFactorization())
18-
#JET.@test_opt solve(prob, SparspakFactorization())
19-
#JET.@test_opt solve(prob)
8+
9+
# Symmetric positive definite matrix for Cholesky
10+
A_spd = A' * A + I
11+
prob_spd = LinearProblem(A_spd, b)
12+
13+
# Symmetric matrix for LDLt
14+
A_sym = A + A'
15+
prob_sym = LinearProblem(A_sym, b)
16+
17+
# Sparse problem setup
18+
A_sparse = sparse(A)
19+
prob_sparse = LinearProblem(A_sparse, b)
20+
21+
# Sparse SPD for CHOLMODFactorization
22+
A_sparse_spd = sparse(A_spd)
23+
prob_sparse_spd = LinearProblem(A_sparse_spd, b)
24+
25+
@testset "JET Tests for Dense Factorizations" begin
26+
# Working tests
27+
JET.@test_opt init(prob, nothing)
28+
JET.@test_opt solve(prob, LUFactorization())
29+
JET.@test_opt solve(prob, GenericLUFactorization())
30+
JET.@test_opt solve(prob, DiagonalFactorization())
31+
JET.@test_opt solve(prob, SimpleLUFactorization())
32+
33+
# Tests that currently fail - marked with @test_skip
34+
@test_skip JET.@test_opt solve(prob, QRFactorization())
35+
@test_skip JET.@test_opt solve(prob_spd, CholeskyFactorization())
36+
@test_skip JET.@test_opt solve(prob_sym, LDLtFactorization())
37+
@test_skip JET.@test_opt solve(prob, SVDFactorization())
38+
@test_skip JET.@test_opt solve(prob_sym, BunchKaufmanFactorization())
39+
@test_skip JET.@test_opt solve(prob, GenericFactorization())
40+
JET.@test_opt solve(prob_spd, NormalCholeskyFactorization())
41+
JET.@test_opt solve(prob, NormalBunchKaufmanFactorization())
42+
end
43+
44+
@testset "JET Tests for Extension Factorizations" begin
45+
# RecursiveFactorization.jl extensions
46+
JET.@test_opt solve(prob, RFLUFactorization())
47+
@test_skip JET.@test_opt solve(prob, FastLUFactorization())
48+
@test_skip JET.@test_opt solve(prob, FastQRFactorization())
49+
50+
# Platform-specific factorizations (may not be available on all systems)
51+
if @isdefined(MKLLUFactorization)
52+
@test_skip JET.@test_opt solve(prob, MKLLUFactorization())
53+
end
54+
55+
if Sys.isapple() && @isdefined(AppleAccelerateLUFactorization)
56+
@test_skip JET.@test_opt solve(prob, AppleAccelerateLUFactorization())
57+
end
58+
59+
# CUDA/Metal factorizations (only test if available)
60+
# @test_skip JET.@test_opt solve(prob, CudaOffloadFactorization())
61+
# @test_skip JET.@test_opt solve(prob, MetalLUFactorization())
62+
# @test_skip JET.@test_opt solve(prob, BLISLUFactorization())
63+
end
64+
65+
@testset "JET Tests for Sparse Factorizations" begin
66+
@test_skip JET.@test_opt solve(prob_sparse, UMFPACKFactorization())
67+
@test_skip JET.@test_opt solve(prob_sparse, KLUFactorization())
68+
@test_skip JET.@test_opt solve(prob_sparse_spd, CHOLMODFactorization())
69+
@test_skip JET.@test_opt solve(prob_sparse, SparspakFactorization())
70+
71+
# PardisoJL (requires extension)
72+
# @test_skip JET.@test_opt solve(prob_sparse, PardisoJL())
73+
74+
# CUSOLVER (requires CUDA)
75+
# @test_skip JET.@test_opt solve(prob_sparse, CUSOLVERRFFactorization())
76+
end
77+
78+
@testset "JET Tests for Krylov Methods" begin
79+
# KrylovJL methods
80+
@test_skip JET.@test_opt solve(prob, KrylovJL_GMRES())
81+
@test_skip JET.@test_opt solve(prob_spd, KrylovJL_CG())
82+
@test_skip JET.@test_opt solve(prob_sym, KrylovJL_MINRES())
83+
@test_skip JET.@test_opt solve(prob, KrylovJL_BICGSTAB())
84+
@test_skip JET.@test_opt solve(prob, KrylovJL_LSMR())
85+
@test_skip JET.@test_opt solve(prob, KrylovJL_CRAIGMR())
86+
@test_skip JET.@test_opt solve(prob_sym, KrylovJL_MINARES())
87+
88+
# SimpleGMRES
89+
@test_skip JET.@test_opt solve(prob, SimpleGMRES())
90+
91+
# Extension Krylov methods (require extensions)
92+
# @test_skip JET.@test_opt solve(prob, KrylovKitJL_CG())
93+
# @test_skip JET.@test_opt solve(prob, KrylovKitJL_GMRES())
94+
# @test_skip JET.@test_opt solve(prob, IterativeSolversJL())
95+
end
96+
97+
@testset "JET Tests for Default Solver" begin
98+
# Test the default solver selection
99+
@test_skip JET.@test_opt solve(prob)
100+
@test_skip JET.@test_opt solve(prob_sparse)
101+
end

0 commit comments

Comments
 (0)