@@ -176,30 +176,79 @@ function _string_to_algorithm_choice(algorithm_name::Union{String, Nothing})
176
176
end
177
177
178
178
# Load autotune preferences as constants for each element type and size category
179
+ # Support both best overall algorithm and best always-loaded algorithm as fallback
179
180
const AUTOTUNE_PREFS = (
180
181
Float32 = (
181
- small = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float32_small" , nothing )),
182
- medium = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float32_medium" , nothing )),
183
- large = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float32_large" , nothing )),
184
- big = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float32_big" , nothing ))
182
+ small = (
183
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float32_small" , nothing )),
184
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_Float32_small" , nothing ))
185
+ ),
186
+ medium = (
187
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float32_medium" , nothing )),
188
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_Float32_medium" , nothing ))
189
+ ),
190
+ large = (
191
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float32_large" , nothing )),
192
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_Float32_large" , nothing ))
193
+ ),
194
+ big = (
195
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float32_big" , nothing )),
196
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_Float32_big" , nothing ))
197
+ )
185
198
),
186
199
Float64 = (
187
- small = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float64_small" , nothing )),
188
- medium = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float64_medium" , nothing )),
189
- large = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float64_large" , nothing )),
190
- big = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float64_big" , nothing ))
200
+ small = (
201
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float64_small" , nothing )),
202
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_Float64_small" , nothing ))
203
+ ),
204
+ medium = (
205
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float64_medium" , nothing )),
206
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_Float64_medium" , nothing ))
207
+ ),
208
+ large = (
209
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float64_large" , nothing )),
210
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_Float64_large" , nothing ))
211
+ ),
212
+ big = (
213
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float64_big" , nothing )),
214
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_Float64_big" , nothing ))
215
+ )
191
216
),
192
217
ComplexF32 = (
193
- small = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF32_small" , nothing )),
194
- medium = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF32_medium" , nothing )),
195
- large = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF32_large" , nothing )),
196
- big = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF32_big" , nothing ))
218
+ small = (
219
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF32_small" , nothing )),
220
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_ComplexF32_small" , nothing ))
221
+ ),
222
+ medium = (
223
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF32_medium" , nothing )),
224
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_ComplexF32_medium" , nothing ))
225
+ ),
226
+ large = (
227
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF32_large" , nothing )),
228
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_ComplexF32_large" , nothing ))
229
+ ),
230
+ big = (
231
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF32_big" , nothing )),
232
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_ComplexF32_big" , nothing ))
233
+ )
197
234
),
198
235
ComplexF64 = (
199
- small = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF64_small" , nothing )),
200
- medium = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF64_medium" , nothing )),
201
- large = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF64_large" , nothing )),
202
- big = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF64_big" , nothing ))
236
+ small = (
237
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF64_small" , nothing )),
238
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_ComplexF64_small" , nothing ))
239
+ ),
240
+ medium = (
241
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF64_medium" , nothing )),
242
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_ComplexF64_medium" , nothing ))
243
+ ),
244
+ large = (
245
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF64_large" , nothing )),
246
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_ComplexF64_large" , nothing ))
247
+ ),
248
+ big = (
249
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF64_big" , nothing )),
250
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_ComplexF64_big" , nothing ))
251
+ )
203
252
)
204
253
)
205
254
@@ -208,7 +257,7 @@ const AUTOTUNE_PREFS_SET = let
208
257
any_set = false
209
258
for type_prefs in (AUTOTUNE_PREFS. Float32, AUTOTUNE_PREFS. Float64, AUTOTUNE_PREFS. ComplexF32, AUTOTUNE_PREFS. ComplexF64)
210
259
for size_pref in (type_prefs. small, type_prefs. medium, type_prefs. large, type_prefs. big)
211
- if size_pref != = nothing
260
+ if size_pref. best != = nothing || size_pref . fallback != = nothing
212
261
any_set = true
213
262
break
214
263
end
@@ -218,6 +267,33 @@ const AUTOTUNE_PREFS_SET = let
218
267
any_set
219
268
end
220
269
270
+ # Algorithm availability checking functions
271
+ """
272
+ is_algorithm_available(alg::DefaultAlgorithmChoice.T)
273
+
274
+ Check if the given algorithm is currently available (extensions loaded, etc.).
275
+ """
276
+ function is_algorithm_available (alg:: DefaultAlgorithmChoice.T )
277
+ if alg === DefaultAlgorithmChoice. LUFactorization
278
+ return true # Always available
279
+ elseif alg === DefaultAlgorithmChoice. GenericLUFactorization
280
+ return true # Always available
281
+ elseif alg === DefaultAlgorithmChoice. MKLLUFactorization
282
+ return usemkl # Available if MKL is loaded
283
+ elseif alg === DefaultAlgorithmChoice. AppleAccelerateLUFactorization
284
+ return appleaccelerate_isavailable () # Available on macOS with Accelerate
285
+ elseif alg === DefaultAlgorithmChoice. RFLUFactorization
286
+ return userecursivefactorization (nothing ) # Requires RecursiveFactorization extension
287
+ else
288
+ # For extension-dependent algorithms not explicitly handled above,
289
+ # we cannot easily check availability without trying to use them.
290
+ # For now, assume they're not available in the default selection.
291
+ # This includes FastLU, BLIS, CUDA, Metal, etc. which would require
292
+ # specific extension checks.
293
+ return false
294
+ end
295
+ end
296
+
221
297
"""
222
298
DefaultLinearSolver(;safetyfallback=true)
223
299
0 commit comments