Skip to content

Commit 1be6f5b

Browse files
Update documentation for final preference system implementation
Comprehensive documentation updates reflecting all changes since last update: ## Autotune Tutorial Updates - Updated show_algorithm_choices() documentation with comprehensive output - Added example showing algorithm choices across all element types - Enhanced preference integration examples - Documented improved tabular analysis format ## Internal API Documentation Updates - Updated function reference: reset_defaults! → make_preferences_dynamic! - Added comprehensive preference system architecture documentation - Documented src/preferences.jl file organization and structure - Added testing mode operation explanation with eval-based approach - Documented LU-only algorithm support scope ## Algorithm Selection Basics Updates - Enhanced show_algorithm_choices() documentation with full feature set - Added example output showing all element types side-by-side - Updated preference system benefits with latest capabilities - Documented comprehensive analysis and display features ## Key Documentation Features ### **File Organization** - All preference functionality consolidated in src/preferences.jl - Compile-time constants for production performance - Runtime testing infrastructure for verification - Analysis and display functions integrated ### **Testing Architecture** - make_preferences_dynamic!() enables runtime preference checking - Eval-based function redefinition maintains type stability - No performance impact on production code - Comprehensive preference verification capabilities ### **Enhanced Analysis** - Algorithm choices for all element types across all sizes - Clear tabular format showing preference effects - System information and extension availability - Preference display for all configured categories The documentation now fully reflects the clean, efficient, and comprehensive dual preference system implementation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent bb9c717 commit 1be6f5b

File tree

3 files changed

+81
-16
lines changed

3 files changed

+81
-16
lines changed

docs/src/advanced/internal_api.md

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,71 @@ LinearSolve.show_algorithm_choices
3636
LinearSolve.make_preferences_dynamic!
3737
```
3838

39-
### Preference System Internals
39+
### Preference System Architecture
4040

41-
The dual preference system provides intelligent algorithm selection with fallbacks:
41+
The dual preference system provides intelligent algorithm selection with comprehensive fallbacks:
4242

43+
#### **Core Functions**
4344
- **`get_tuned_algorithm`**: Retrieves tuned algorithm preferences based on matrix size and element type
44-
- **`is_algorithm_available`**: Checks if a specific algorithm is currently available (extensions loaded)
45-
- **`show_algorithm_choices`**: Analysis function to display current algorithm choices and preferences
45+
- **`is_algorithm_available`**: Checks if a specific algorithm is currently available (extensions loaded)
46+
- **`show_algorithm_choices`**: Analysis function displaying algorithm choices for all element types
47+
- **`make_preferences_dynamic!`**: Testing function that enables runtime preference checking
4648

47-
The system categorizes matrix sizes as:
48-
- **tiny**: ≤20 elements
49+
#### **Size Categorization**
50+
The system categorizes matrix sizes to match LinearSolveAutotune benchmarking:
51+
- **tiny**: ≤20 elements (matrices ≤10 always override to GenericLU)
4952
- **small**: 21-100 elements
5053
- **medium**: 101-300 elements
5154
- **large**: 301-1000 elements
5255
- **big**: >1000 elements
5356

54-
For each category and element type, preferences store both:
55-
- `best_algorithm_{type}_{size}`: Overall fastest algorithm
57+
#### **Dual Preference Structure**
58+
For each category and element type (Float32, Float64, ComplexF32, ComplexF64):
59+
- `best_algorithm_{type}_{size}`: Overall fastest algorithm from autotune
5660
- `best_always_loaded_{type}_{size}`: Fastest always-available algorithm (fallback)
5761

62+
#### **Preference File Organization**
63+
All preference-related functionality is consolidated in `src/preferences.jl`:
64+
65+
**Compile-Time Constants**:
66+
- `AUTOTUNE_PREFS`: Preference structure loaded at package import
67+
- `AUTOTUNE_PREFS_SET`: Fast path check for whether any preferences are set
68+
- `_string_to_algorithm_choice`: Mapping from preference strings to algorithm enums
69+
70+
**Runtime Functions**:
71+
- `_get_tuned_algorithm_runtime`: Dynamic preference checking for testing
72+
- `_choose_available_algorithm`: Algorithm availability and fallback logic
73+
- `show_algorithm_choices`: Comprehensive analysis and display function
74+
75+
**Testing Infrastructure**:
76+
- `make_preferences_dynamic!`: Eval-based function redefinition for testing
77+
- Enables runtime preference verification without affecting production performance
78+
79+
#### **Testing Mode Operation**
80+
The testing system uses an elegant eval-based approach:
81+
```julia
82+
# Production: Uses compile-time constants (maximum performance)
83+
get_tuned_algorithm(Float64, Float64, 200) # → Uses AUTOTUNE_PREFS constants
84+
85+
# Testing: Redefines function to use runtime checking
86+
make_preferences_dynamic!()
87+
get_tuned_algorithm(Float64, Float64, 200) # → Uses runtime preference loading
88+
```
89+
90+
This approach maintains type stability and inference while enabling comprehensive testing.
91+
92+
#### **Algorithm Support Scope**
93+
The preference system focuses exclusively on LU algorithms for dense matrices:
94+
95+
**Supported LU Algorithms**:
96+
- `LUFactorization`, `GenericLUFactorization`, `RFLUFactorization`
97+
- `MKLLUFactorization`, `AppleAccelerateLUFactorization`
98+
- `SimpleLUFactorization`, `FastLUFactorization` (both map to LU)
99+
- GPU LU variants (CUDA, Metal, AMDGPU - all map to LU)
100+
101+
**Non-LU algorithms** (QR, Cholesky, SVD, etc.) are not included in the preference system
102+
as they serve different use cases and are not typically the focus of dense matrix autotune optimization.
103+
58104
## Trait Functions
59105

60106
These trait functions help determine algorithm capabilities and requirements:

docs/src/basics/algorithm_selection.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,22 @@ using LinearSolve
191191
show_algorithm_choices()
192192
```
193193

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
194+
This shows a comprehensive analysis:
195+
- Current autotune preferences for all element types (if set)
196+
- Algorithm choices for all element types across all size categories
197+
- Side-by-side comparison showing Float32, Float64, ComplexF32, ComplexF64 behavior
198+
- System information (available extensions: MKL, Apple Accelerate, RecursiveFactorization)
199+
200+
Example output:
201+
```
202+
📊 Default Algorithm Choices:
203+
Size Category Float32 Float64 ComplexF32 ComplexF64
204+
8×8 tiny GenericLUFactorization GenericLUFactorization GenericLUFactorization GenericLUFactorization
205+
50×50 small MKLLUFactorization MKLLUFactorization MKLLUFactorization MKLLUFactorization
206+
200×200 medium MKLLUFactorization GenericLUFactorization MKLLUFactorization MKLLUFactorization
207+
```
208+
209+
When preferences are set, you can see exactly how they affect algorithm choice across different element types.
199210

200211
### Preference System Benefits
201212

docs/src/tutorials/autotune.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,11 +429,19 @@ show_algorithm_choices()
429429
```
430430

431431
This displays:
432-
- Current autotune preferences (if any are set)
433-
- Algorithm choices for representative sizes in each category
434-
- Element type behavior
432+
- Current autotune preferences for all element types (if any are set)
433+
- Algorithm choices for all element types across representative sizes in each category
434+
- Comprehensive element type behavior (Float32, Float64, ComplexF32, ComplexF64)
435435
- System information (MKL, Apple Accelerate, RecursiveFactorization status)
436436

437+
The output shows a clear table format:
438+
```
439+
📊 Default Algorithm Choices:
440+
Size Category Float32 Float64 ComplexF32 ComplexF64
441+
8×8 tiny GenericLUFactorization GenericLUFactorization GenericLUFactorization GenericLUFactorization
442+
200×200 medium MKLLUFactorization MKLLUFactorization MKLLUFactorization MKLLUFactorization
443+
```
444+
437445
## Preferences Integration
438446

439447
The autotuner sets preferences that LinearSolve.jl uses for automatic algorithm selection:

0 commit comments

Comments
 (0)