Skip to content

Commit c55e420

Browse files
Update documentation for dual preference system and show_algorithm_choices
Updated documentation to reflect the new dual preference system and analysis function: ## Autotune Tutorial Updates - Removed "in progress" warning about automatic preference setting - Added mention of show_algorithm_choices() function - Updated preference integration section to reflect working system - Added example of viewing algorithm choices after autotune ## Algorithm Selection Basics Updates - Added "Tuned Algorithm Selection" section explaining preference system - Added show_algorithm_choices() usage examples - Documented dual preference system benefits - Explained size categories and preference structure ## Internal API Documentation Updates - Added new internal functions: get_tuned_algorithm, is_algorithm_available, show_algorithm_choices - Added preference system internals documentation - Explained size categorization and dual preference structure - Documented fallback mechanism architecture These updates reflect that the dual preference system is now fully functional and provide users with clear guidance on how to use the new capabilities. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent beeec34 commit c55e420

File tree

3 files changed

+94
-18
lines changed

3 files changed

+94
-18
lines changed

docs/src/advanced/internal_api.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,30 @@ The automatic algorithm selection is one of LinearSolve.jl's key features:
3030

3131
```@docs
3232
LinearSolve.defaultalg
33+
LinearSolve.get_tuned_algorithm
34+
LinearSolve.is_algorithm_available
35+
LinearSolve.show_algorithm_choices
3336
```
3437

38+
### Preference System Internals
39+
40+
The dual preference system provides intelligent algorithm selection with fallbacks:
41+
42+
- **`get_tuned_algorithm`**: Retrieves tuned algorithm preferences based on matrix size and element type
43+
- **`is_algorithm_available`**: Checks if a specific algorithm is currently available (extensions loaded)
44+
- **`show_algorithm_choices`**: Analysis function to display current algorithm choices and preferences
45+
46+
The system categorizes matrix sizes as:
47+
- **tiny**: ≤20 elements
48+
- **small**: 21-100 elements
49+
- **medium**: 101-300 elements
50+
- **large**: 301-1000 elements
51+
- **big**: >1000 elements
52+
53+
For each category and element type, preferences store both:
54+
- `best_algorithm_{type}_{size}`: Overall fastest algorithm
55+
- `best_always_loaded_{type}_{size}`: Fastest always-available algorithm (fallback)
56+
3557
## Trait Functions
3658

3759
These trait functions help determine algorithm capabilities and requirements:

docs/src/basics/algorithm_selection.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,46 @@ end
160160
sol = solve(prob, LinearSolveFunction(my_custom_solver))
161161
```
162162

163-
See the [Custom Linear Solvers](@ref custom) section for more details.
163+
See the [Custom Linear Solvers](@ref custom) section for more details.
164+
165+
## Tuned Algorithm Selection
166+
167+
LinearSolve.jl includes a sophisticated preference system that can be tuned using LinearSolveAutotune for optimal performance on your specific hardware:
168+
169+
```julia
170+
using LinearSolve
171+
using LinearSolveAutotune
172+
173+
# Run autotune to benchmark algorithms and set preferences
174+
results = autotune_setup(set_preferences = true)
175+
176+
# View what algorithms are now being chosen
177+
show_algorithm_choices()
178+
```
179+
180+
The system automatically sets preferences for:
181+
- **Different matrix sizes**: tiny (≤20), small (21-100), medium (101-300), large (301-1000), big (>1000)
182+
- **Different element types**: Float32, Float64, ComplexF32, ComplexF64
183+
- **Dual preferences**: Best overall algorithm + best always-available fallback
184+
185+
### Viewing Algorithm Choices
186+
187+
Use `show_algorithm_choices()` to see what algorithms are currently being selected:
188+
189+
```julia
190+
using LinearSolve
191+
show_algorithm_choices()
192+
```
193+
194+
This shows:
195+
- Current autotune preferences (if set)
196+
- Algorithm choices for each size category
197+
- System information (available extensions)
198+
- Element type behavior
199+
200+
### Preference System Benefits
201+
202+
- **Automatic optimization**: Uses the fastest algorithms found by benchmarking
203+
- **Intelligent fallbacks**: Falls back to always-available algorithms when extensions aren't loaded
204+
- **Size-specific tuning**: Different algorithms optimized for different matrix sizes
205+
- **Type-specific tuning**: Optimized algorithm selection for different numeric types

docs/src/tutorials/autotune.md

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
LinearSolve.jl includes an automatic tuning system that benchmarks all available linear algebra algorithms on your specific hardware and automatically selects optimal algorithms for different problem sizes and data types. This tutorial will show you how to use the `LinearSolveAutotune` sublibrary to optimize your linear solve performance.
44

5-
!!! warn
6-
The autotuning system is under active development. While benchmarking and result sharing are fully functional, automatic preference setting for algorithm selection is still being refined.
5+
The autotuning system provides comprehensive benchmarking and automatic algorithm selection optimization for your specific hardware.
76

87
## Quick Start
98

@@ -418,33 +417,46 @@ for config in configs
418417
end
419418
```
420419

421-
## Preferences Integration
420+
## Algorithm Selection Analysis
421+
422+
You can analyze what algorithms are currently being chosen for different matrix sizes:
423+
424+
```julia
425+
using LinearSolve
422426

423-
!!! warn
424-
Automatic preference setting is still under development and may not affect algorithm selection in the current version.
427+
# Show current algorithm choices and preferences
428+
show_algorithm_choices()
429+
```
430+
431+
This displays:
432+
- Current autotune preferences (if any are set)
433+
- Algorithm choices for representative sizes in each category
434+
- Element type behavior
435+
- System information (MKL, Apple Accelerate, RecursiveFactorization status)
436+
437+
## Preferences Integration
425438

426-
The autotuner can set preferences that LinearSolve.jl will use for automatic algorithm selection:
439+
The autotuner sets preferences that LinearSolve.jl uses for automatic algorithm selection:
427440

428441
```julia
429442
using LinearSolveAutotune
430443

431-
# View current preferences (if any)
432-
LinearSolveAutotune.show_current_preferences()
433-
434444
# Run autotune and set preferences
435445
results = autotune_setup(set_preferences = true)
436446

437-
# Clear all autotune preferences
438-
LinearSolveAutotune.clear_algorithm_preferences()
447+
# View what algorithms are now being chosen
448+
using LinearSolve
449+
show_algorithm_choices()
439450

440-
# Manually set custom preferences
441-
custom_categories = Dict(
442-
"Float64_0-128" => "RFLUFactorization",
443-
"Float64_128-256" => "LUFactorization"
444-
)
445-
LinearSolveAutotune.set_algorithm_preferences(custom_categories)
451+
# View current preferences
452+
LinearSolveAutotune.show_current_preferences()
453+
454+
# Clear all autotune preferences if needed
455+
LinearSolveAutotune.clear_algorithm_preferences()
446456
```
447457

458+
After running autotune with `set_preferences = true`, LinearSolve.jl will automatically use the fastest algorithms found for each matrix size and element type, with intelligent fallbacks when extensions are not available.
459+
448460
## Troubleshooting
449461

450462
### Common Issues

0 commit comments

Comments
 (0)