@@ -323,30 +323,79 @@ function _string_to_algorithm_choice(algorithm_name::Union{String, Nothing})
323
323
end
324
324
325
325
# Load autotune preferences as constants for each element type and size category
326
+ # Support both best overall algorithm and best always-loaded algorithm as fallback
326
327
const AUTOTUNE_PREFS = (
327
328
Float32 = (
328
- small = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float32_small" , nothing )),
329
- medium = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float32_medium" , nothing )),
330
- large = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float32_large" , nothing )),
331
- big = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float32_big" , nothing ))
329
+ small = (
330
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float32_small" , nothing )),
331
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_Float32_small" , nothing ))
332
+ ),
333
+ medium = (
334
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float32_medium" , nothing )),
335
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_Float32_medium" , nothing ))
336
+ ),
337
+ large = (
338
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float32_large" , nothing )),
339
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_Float32_large" , nothing ))
340
+ ),
341
+ big = (
342
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float32_big" , nothing )),
343
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_Float32_big" , nothing ))
344
+ )
332
345
),
333
346
Float64 = (
334
- small = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float64_small" , nothing )),
335
- medium = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float64_medium" , nothing )),
336
- large = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float64_large" , nothing )),
337
- big = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float64_big" , nothing ))
347
+ small = (
348
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float64_small" , nothing )),
349
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_Float64_small" , nothing ))
350
+ ),
351
+ medium = (
352
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float64_medium" , nothing )),
353
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_Float64_medium" , nothing ))
354
+ ),
355
+ large = (
356
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float64_large" , nothing )),
357
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_Float64_large" , nothing ))
358
+ ),
359
+ big = (
360
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_Float64_big" , nothing )),
361
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_Float64_big" , nothing ))
362
+ )
338
363
),
339
364
ComplexF32 = (
340
- small = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF32_small" , nothing )),
341
- medium = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF32_medium" , nothing )),
342
- large = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF32_large" , nothing )),
343
- big = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF32_big" , nothing ))
365
+ small = (
366
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF32_small" , nothing )),
367
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_ComplexF32_small" , nothing ))
368
+ ),
369
+ medium = (
370
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF32_medium" , nothing )),
371
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_ComplexF32_medium" , nothing ))
372
+ ),
373
+ large = (
374
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF32_large" , nothing )),
375
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_ComplexF32_large" , nothing ))
376
+ ),
377
+ big = (
378
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF32_big" , nothing )),
379
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_ComplexF32_big" , nothing ))
380
+ )
344
381
),
345
382
ComplexF64 = (
346
- small = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF64_small" , nothing )),
347
- medium = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF64_medium" , nothing )),
348
- large = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF64_large" , nothing )),
349
- big = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF64_big" , nothing ))
383
+ small = (
384
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF64_small" , nothing )),
385
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_ComplexF64_small" , nothing ))
386
+ ),
387
+ medium = (
388
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF64_medium" , nothing )),
389
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_ComplexF64_medium" , nothing ))
390
+ ),
391
+ large = (
392
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF64_large" , nothing )),
393
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_ComplexF64_large" , nothing ))
394
+ ),
395
+ big = (
396
+ best = _string_to_algorithm_choice (Preferences. @load_preference (" best_algorithm_ComplexF64_big" , nothing )),
397
+ fallback = _string_to_algorithm_choice (Preferences. @load_preference (" best_always_loaded_ComplexF64_big" , nothing ))
398
+ )
350
399
)
351
400
)
352
401
@@ -355,7 +404,7 @@ const AUTOTUNE_PREFS_SET = let
355
404
any_set = false
356
405
for type_prefs in (AUTOTUNE_PREFS. Float32, AUTOTUNE_PREFS. Float64, AUTOTUNE_PREFS. ComplexF32, AUTOTUNE_PREFS. ComplexF64)
357
406
for size_pref in (type_prefs. small, type_prefs. medium, type_prefs. large, type_prefs. big)
358
- if size_pref != = nothing
407
+ if size_pref. best != = nothing || size_pref . fallback != = nothing
359
408
any_set = true
360
409
break
361
410
end
@@ -365,6 +414,33 @@ const AUTOTUNE_PREFS_SET = let
365
414
any_set
366
415
end
367
416
417
+ # Algorithm availability checking functions
418
+ """
419
+ is_algorithm_available(alg::DefaultAlgorithmChoice.T)
420
+
421
+ Check if the given algorithm is currently available (extensions loaded, etc.).
422
+ """
423
+ function is_algorithm_available (alg:: DefaultAlgorithmChoice.T )
424
+ if alg === DefaultAlgorithmChoice. LUFactorization
425
+ return true # Always available
426
+ elseif alg === DefaultAlgorithmChoice. GenericLUFactorization
427
+ return true # Always available
428
+ elseif alg === DefaultAlgorithmChoice. MKLLUFactorization
429
+ return usemkl # Available if MKL is loaded
430
+ elseif alg === DefaultAlgorithmChoice. AppleAccelerateLUFactorization
431
+ return appleaccelerate_isavailable () # Available on macOS with Accelerate
432
+ elseif alg === DefaultAlgorithmChoice. RFLUFactorization
433
+ return userecursivefactorization (nothing ) # Requires RecursiveFactorization extension
434
+ else
435
+ # For extension-dependent algorithms not explicitly handled above,
436
+ # we cannot easily check availability without trying to use them.
437
+ # For now, assume they're not available in the default selection.
438
+ # This includes FastLU, BLIS, CUDA, Metal, etc. which would require
439
+ # specific extension checks.
440
+ return false
441
+ end
442
+ end
443
+
368
444
"""
369
445
DefaultLinearSolver(;safetyfallback=true)
370
446
0 commit comments