|
1 | 1 | module LinearSolveAutotune
|
2 | 2 |
|
3 |
| -# Note: MKL preference should be set before loading LinearSolve for optimal performance |
4 |
| -# The autotune system will write the appropriate preference based on benchmark results |
| 3 | +# Ensure MKL is available for benchmarking by setting the preference before loading LinearSolve |
5 | 4 | using Preferences
|
6 | 5 | using MKL_jll
|
| 6 | + |
| 7 | +# Set MKL preference to true for benchmarking if MKL is available |
| 8 | +# We need to use UUID instead of the module since LinearSolve isn't loaded yet |
| 9 | +const LINEARSOLVE_UUID = Base.UUID("7ed4a6bd-45f5-4d41-b270-4a48e9bafcae") |
| 10 | +if MKL_jll.is_available() |
| 11 | + # Force load MKL for benchmarking to ensure we can test MKL algorithms |
| 12 | + # The autotune results will determine the final preference setting |
| 13 | + current_pref = Preferences.load_preference(LINEARSOLVE_UUID, "LoadMKL_JLL", nothing) |
| 14 | + if current_pref !== true |
| 15 | + Preferences.set_preferences!(LINEARSOLVE_UUID, "LoadMKL_JLL" => true; force = true) |
| 16 | + @info "Temporarily setting LoadMKL_JLL=true for benchmarking (was $(current_pref))" |
| 17 | + end |
| 18 | +end |
| 19 | + |
7 | 20 | using LinearSolve
|
8 | 21 | using BenchmarkTools
|
9 | 22 | using DataFrames
|
@@ -145,6 +158,12 @@ Run a comprehensive benchmark of all available LU factorization methods and opti
|
145 | 158 | - Set Preferences for optimal algorithm selection
|
146 | 159 | - Support both CPU and GPU algorithms based on hardware detection
|
147 | 160 | - Test algorithm compatibility with different element types
|
| 161 | + - Automatically manage MKL loading preference based on performance results |
| 162 | +
|
| 163 | +!!! note "MKL Preference Management" |
| 164 | + During benchmarking, MKL is temporarily enabled (if available) to test MKL algorithms. |
| 165 | + After benchmarking, the LoadMKL_JLL preference is set based on whether MKL algorithms |
| 166 | + performed best in any category. This optimizes startup time and memory usage. |
148 | 167 |
|
149 | 168 | # Arguments
|
150 | 169 |
|
|
0 commit comments