|
58 | 58 | const usemkl = false |
59 | 59 | end |
60 | 60 |
|
| 61 | + |
61 | 62 | @reexport using SciMLBase |
62 | 63 |
|
63 | 64 | abstract type SciMLLinearSolveAlgorithm <: SciMLBase.AbstractLinearAlgorithm end |
@@ -129,6 +130,65 @@ EnumX.@enumx DefaultAlgorithmChoice begin |
129 | 130 | KrylovJL_LSMR |
130 | 131 | end |
131 | 132 |
|
| 133 | +# Autotune preference constants - loaded once at package import time |
| 134 | +# Helper function to convert algorithm name string to DefaultAlgorithmChoice enum |
| 135 | +function _string_to_algorithm_choice(algorithm_name::Union{String, Nothing}) |
| 136 | + algorithm_name === nothing && return nothing |
| 137 | + |
| 138 | + if algorithm_name == "LUFactorization" |
| 139 | + return DefaultAlgorithmChoice.LUFactorization |
| 140 | + elseif algorithm_name == "RFLUFactorization" || algorithm_name == "RecursiveFactorization" |
| 141 | + return DefaultAlgorithmChoice.RFLUFactorization |
| 142 | + elseif algorithm_name == "MKLLUFactorization" |
| 143 | + return DefaultAlgorithmChoice.MKLLUFactorization |
| 144 | + elseif algorithm_name == "AppleAccelerateLUFactorization" |
| 145 | + return DefaultAlgorithmChoice.AppleAccelerateLUFactorization |
| 146 | + elseif algorithm_name == "GenericLUFactorization" |
| 147 | + return DefaultAlgorithmChoice.GenericLUFactorization |
| 148 | + elseif algorithm_name == "QRFactorization" |
| 149 | + return DefaultAlgorithmChoice.QRFactorization |
| 150 | + elseif algorithm_name == "CholeskyFactorization" |
| 151 | + return DefaultAlgorithmChoice.CholeskyFactorization |
| 152 | + elseif algorithm_name == "SVDFactorization" |
| 153 | + return DefaultAlgorithmChoice.SVDFactorization |
| 154 | + elseif algorithm_name == "BunchKaufmanFactorization" |
| 155 | + return DefaultAlgorithmChoice.BunchKaufmanFactorization |
| 156 | + elseif algorithm_name == "LDLtFactorization" |
| 157 | + return DefaultAlgorithmChoice.LDLtFactorization |
| 158 | + else |
| 159 | + @warn "Unknown algorithm preference: $algorithm_name, falling back to heuristics" |
| 160 | + return nothing |
| 161 | + end |
| 162 | +end |
| 163 | + |
| 164 | +# Load autotune preferences as constants for each element type and size category |
| 165 | +const AUTOTUNE_PREFS = ( |
| 166 | + Float32 = ( |
| 167 | + small = _string_to_algorithm_choice(Preferences.@load_preference("best_algorithm_Float32_small", nothing)), |
| 168 | + medium = _string_to_algorithm_choice(Preferences.@load_preference("best_algorithm_Float32_medium", nothing)), |
| 169 | + large = _string_to_algorithm_choice(Preferences.@load_preference("best_algorithm_Float32_large", nothing)), |
| 170 | + big = _string_to_algorithm_choice(Preferences.@load_preference("best_algorithm_Float32_big", nothing)) |
| 171 | + ), |
| 172 | + Float64 = ( |
| 173 | + small = _string_to_algorithm_choice(Preferences.@load_preference("best_algorithm_Float64_small", nothing)), |
| 174 | + medium = _string_to_algorithm_choice(Preferences.@load_preference("best_algorithm_Float64_medium", nothing)), |
| 175 | + large = _string_to_algorithm_choice(Preferences.@load_preference("best_algorithm_Float64_large", nothing)), |
| 176 | + big = _string_to_algorithm_choice(Preferences.@load_preference("best_algorithm_Float64_big", nothing)) |
| 177 | + ), |
| 178 | + ComplexF32 = ( |
| 179 | + small = _string_to_algorithm_choice(Preferences.@load_preference("best_algorithm_ComplexF32_small", nothing)), |
| 180 | + medium = _string_to_algorithm_choice(Preferences.@load_preference("best_algorithm_ComplexF32_medium", nothing)), |
| 181 | + large = _string_to_algorithm_choice(Preferences.@load_preference("best_algorithm_ComplexF32_large", nothing)), |
| 182 | + big = _string_to_algorithm_choice(Preferences.@load_preference("best_algorithm_ComplexF32_big", nothing)) |
| 183 | + ), |
| 184 | + ComplexF64 = ( |
| 185 | + small = _string_to_algorithm_choice(Preferences.@load_preference("best_algorithm_ComplexF64_small", nothing)), |
| 186 | + medium = _string_to_algorithm_choice(Preferences.@load_preference("best_algorithm_ComplexF64_medium", nothing)), |
| 187 | + large = _string_to_algorithm_choice(Preferences.@load_preference("best_algorithm_ComplexF64_large", nothing)), |
| 188 | + big = _string_to_algorithm_choice(Preferences.@load_preference("best_algorithm_ComplexF64_big", nothing)) |
| 189 | + ) |
| 190 | +) |
| 191 | + |
132 | 192 | """ |
133 | 193 | DefaultLinearSolver(;safetyfallback=true) |
134 | 194 |
|
|
0 commit comments