Skip to content

Commit beeec34

Browse files
Move show_algorithm_choices to main package and simplify
Moved show_algorithm_choices from test/ to src/analysis.jl and simplified: - Removed preference clearing and testing functionality - Shows current preferences and what default algorithm chooses - One representative matrix per size category (not boundary testing) - Shows system information (MKL, Apple Accelerate, RecursiveFactorization status) - Exported from main LinearSolve package for easy access Usage: julia -e "using LinearSolve; show_algorithm_choices()" 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 4958c38 commit beeec34

File tree

3 files changed

+106
-210
lines changed

3 files changed

+106
-210
lines changed

src/LinearSolve.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ include("simplelu.jl")
479479
include("simplegmres.jl")
480480
include("iterative_wrappers.jl")
481481
include("preconditioners.jl")
482+
include("analysis.jl")
482483
include("solve_function.jl")
483484
include("default.jl")
484485
include("init.jl")
@@ -560,7 +561,7 @@ export LUFactorization, SVDFactorization, QRFactorization, GenericFactorization,
560561
BunchKaufmanFactorization, CHOLMODFactorization, LDLtFactorization,
561562
CUSOLVERRFFactorization, CliqueTreesFactorization
562563

563-
export LinearSolveFunction, DirectLdiv!
564+
export LinearSolveFunction, DirectLdiv!, show_algorithm_choices
564565

565566
export KrylovJL, KrylovJL_CG, KrylovJL_MINRES, KrylovJL_GMRES,
566567
KrylovJL_BICGSTAB, KrylovJL_LSMR, KrylovJL_CRAIGMR,

src/analysis.jl

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
using Preferences
2+
3+
"""
4+
show_algorithm_choices()
5+
6+
Display what algorithm choices are actually made by the default solver for
7+
representative matrix sizes. Shows current preferences and system information.
8+
"""
9+
function show_algorithm_choices()
10+
println("="^60)
11+
println("LinearSolve.jl Algorithm Choice Analysis")
12+
println("="^60)
13+
14+
# Show current preferences
15+
println("📋 Current Preferences:")
16+
println("-"^60)
17+
18+
any_prefs_set = false
19+
for eltype in ["Float64"] # Focus on Float64
20+
for size_cat in ["tiny", "small", "medium", "large", "big"]
21+
best_pref = Preferences.load_preference(LinearSolve, "best_algorithm_$(eltype)_$(size_cat)", nothing)
22+
fallback_pref = Preferences.load_preference(LinearSolve, "best_always_loaded_$(eltype)_$(size_cat)", nothing)
23+
24+
if best_pref !== nothing || fallback_pref !== nothing
25+
any_prefs_set = true
26+
println("$(eltype) $(size_cat):")
27+
if best_pref !== nothing
28+
println(" Best: $(best_pref)")
29+
end
30+
if fallback_pref !== nothing
31+
println(" Always-loaded: $(fallback_pref)")
32+
end
33+
end
34+
end
35+
end
36+
37+
if !any_prefs_set
38+
println("No autotune preferences currently set.")
39+
end
40+
41+
# Show algorithm choices for one representative size per category
42+
println("\n📊 Default Algorithm Choices (Float64):")
43+
println("-"^60)
44+
println("Size Category Chosen Algorithm")
45+
println("-"^60)
46+
47+
# One representative size per category
48+
test_cases = [
49+
(8, "tiny"), # ≤10 override
50+
(50, "small"), # 21-100
51+
(200, "medium"), # 101-300
52+
(500, "large"), # 301-1000
53+
(1500, "big") # >1000
54+
]
55+
56+
for (size, expected_category) in test_cases
57+
# Create test problem
58+
A = rand(Float64, size, size) + I(size)
59+
b = rand(Float64, size)
60+
61+
# Get algorithm choice
62+
chosen_alg = defaultalg(A, b, OperatorAssumptions(true))
63+
64+
size_str = lpad("$(size)×$(size)", 10)
65+
cat_str = rpad(expected_category, 11)
66+
alg_str = string(chosen_alg.alg)
67+
68+
println("$(size_str) $(cat_str) $(alg_str)")
69+
end
70+
71+
# Show different element types for medium size
72+
println("\n📊 Element Type Choices (200×200):")
73+
println("-"^60)
74+
println("Element Type Chosen Algorithm")
75+
println("-"^60)
76+
77+
test_eltypes = [Float32, Float64, ComplexF32, ComplexF64]
78+
test_size = 200 # Medium category
79+
80+
for eltype in test_eltypes
81+
A = rand(eltype, test_size, test_size) + I(test_size)
82+
b = rand(eltype, test_size)
83+
84+
chosen_alg = defaultalg(A, b, OperatorAssumptions(true))
85+
86+
type_str = rpad(string(eltype), 15)
87+
alg_str = string(chosen_alg.alg)
88+
89+
println("$(type_str) $(alg_str)")
90+
end
91+
92+
# Show system information
93+
println("\n🖥️ System Information:")
94+
println("-"^60)
95+
println("MKL available: ", usemkl)
96+
println("Apple Accelerate available: ", appleaccelerate_isavailable())
97+
println("RecursiveFactorization enabled: ", userecursivefactorization(nothing))
98+
99+
println("\n💡 Size Categories:")
100+
println("tiny (≤20), small (21-100), medium (101-300), large (301-1000), big (>1000)")
101+
println("Matrices ≤10 elements always use GenericLUFactorization override")
102+
103+
println("="^60)
104+
end

test/show_algorithm_choices.jl

Lines changed: 0 additions & 209 deletions
This file was deleted.

0 commit comments

Comments
 (0)