-
-
Notifications
You must be signed in to change notification settings - Fork 72
Add MKL preference management to autotune system #706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Analyze if MKL algorithms (MKLLUFactorization) perform best in any category - Write LoadMKL_JLL preference based on benchmark results - Set to false if MKL is never best to avoid loading unnecessary dependencies - Set to true if MKL wins in any category to ensure availability - Add MKL preference display in show_current_preferences - Include MKL preference clearing in clear_algorithm_preferences This optimization reduces startup time and memory usage when MKL is not beneficial for the user's workload.
@@ -23,13 +23,21 @@ function set_algorithm_preferences(categories::Dict{String, String}) | |||
|
|||
# Extract benchmarked results by element type and size | |||
benchmarked = Dict{String, Dict{String, String}}() | |||
mkl_is_best_somewhere = false # Track if MKL wins any category | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
for (key, algorithm) in categories | ||
if contains(key, "_") | ||
eltype, size_range = split(key, "_", limit=2) | ||
if !haskey(benchmarked, eltype) | ||
benchmarked[eltype] = Dict{String, String}() | ||
end | ||
benchmarked[eltype][size_range] = algorithm | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
- Set LoadMKL_JLL=true before loading LinearSolve in autotune module - This ensures MKL algorithms are available for benchmarking - Track the original preference to inform user of temporary change - Final preference is still set based on benchmark results - Added documentation explaining this behavior
# Note: During benchmarking, MKL is temporarily enabled to test MKL algorithms | ||
# This final preference setting determines whether MKL loads in normal usage | ||
Preferences.set_preferences!(LinearSolve, "LoadMKL_JLL" => mkl_is_best_somewhere; force = true) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
else | ||
@info "MKL was not best in any category - setting LoadMKL_JLL preference to false to avoid loading unnecessary dependencies" | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
# Clear MKL preference | ||
Preferences.delete_preferences!(LinearSolve, "LoadMKL_JLL"; force = true) | ||
@info "Cleared MKL preference" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
if mkl_pref !== nothing | ||
println("\nMKL Usage: $(mkl_pref ? "Enabled" : "Disabled")") | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
Summary
Details
This PR adds MKL preference management to the autotune system:
Benefits
Testing
Added test file to verify: