-
-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -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 | ||||
|
||||
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 commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||
# Check if MKL algorithm is best for this category | ||||
if contains(algorithm, "MKL") | ||||
mkl_is_best_somewhere = true | ||||
@info "MKL algorithm ($algorithm) is best for $eltype at size $size_range" | ||||
end | ||||
end | ||||
end | ||||
|
||||
|
@@ -118,6 +126,18 @@ function set_algorithm_preferences(categories::Dict{String, String}) | |||
end | ||||
end | ||||
|
||||
# Set MKL preference based on whether it was best for any category | ||||
# If MKL wasn't best anywhere, disable it to avoid loading unnecessary dependencies | ||||
# 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 commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||
if mkl_is_best_somewhere | ||||
@info "MKL was best in at least one category - setting LoadMKL_JLL preference to true" | ||||
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 commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||
# Set a timestamp for when these preferences were created | ||||
Preferences.set_preferences!(LinearSolve, "autotune_timestamp" => string(Dates.now()); force = true) | ||||
|
||||
|
@@ -178,6 +198,10 @@ function clear_algorithm_preferences() | |||
Preferences.delete_preferences!(LinearSolve, "autotune_timestamp"; force = true) | ||||
end | ||||
|
||||
# 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 commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||
@info "Preferences cleared from LinearSolve.jl." | ||||
end | ||||
|
||||
|
@@ -214,6 +238,12 @@ function show_current_preferences() | |||
end | ||||
end | ||||
|
||||
# Show MKL preference | ||||
mkl_pref = Preferences.load_preference(LinearSolve, "LoadMKL_JLL", nothing) | ||||
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 commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||
timestamp = Preferences.load_preference(LinearSolve, "autotune_timestamp", "unknown") | ||||
println("\nLast updated: $timestamp") | ||||
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 🐶