Skip to content

Commit 1ef951f

Browse files
Add optional FastLapackInterface.jl's LU to LinearSolveAutotune
- Added include_fastlapack parameter to autotune_setup (default: false) - FastLUFactorization is only included when explicitly requested - Keeps FastLapackInterface as a weak dependency in LinearSolve.jl - Users must load FastLapackInterface.jl before using include_fastlapack=true - Updated documentation with usage examples
1 parent 1adf243 commit 1ef951f

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

Project.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ CUDSS = "45b445bb-4962-46a0-9369-b4df9d0f772e"
3636
CUSOLVERRF = "a8cc9031-bad2-4722-94f5-40deabb4245c"
3737
EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869"
3838
FastAlmostBandedMatrices = "9d29842c-ecb8-4973-b1e9-a27b1157504e"
39-
FastLapackInterface = "29a986be-02c6-4525-aec4-84b980013641"
4039
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
4140
HYPRE = "b5ffcf37-a2bd-41ab-a3da-4bd9bc8ad771"
4241
IterativeSolvers = "42fd0dbc-a981-5370-80f2-aaf504508153"

lib/LinearSolveAutotune/src/LinearSolveAutotune.jl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ end
156156
samples::Int = 5,
157157
seconds::Float64 = 0.5,
158158
eltypes = (Float32, Float64, ComplexF32, ComplexF64),
159-
skip_missing_algs::Bool = false)
159+
skip_missing_algs::Bool = false,
160+
include_fastlapack::Bool = false)
160161
161162
Run a comprehensive benchmark of all available LU factorization methods and optionally:
162163
@@ -179,6 +180,7 @@ Run a comprehensive benchmark of all available LU factorization methods and opti
179180
- `seconds::Float64 = 0.5`: Maximum time per benchmark
180181
- `eltypes = (Float32, Float64, ComplexF32, ComplexF64)`: Element types to benchmark
181182
- `skip_missing_algs::Bool = false`: If false, error when expected algorithms are missing; if true, warn instead
183+
- `include_fastlapack::Bool = false`: If true and FastLapackInterface.jl is loaded, includes FastLUFactorization in benchmarks
182184
183185
# Returns
184186
@@ -199,6 +201,10 @@ results = autotune_setup(sizes = [:small, :medium, :large, :big])
199201
# Large matrices only
200202
results = autotune_setup(sizes = [:large, :big], samples = 10, seconds = 1.0)
201203
204+
# Include FastLapackInterface.jl algorithms if available
205+
using FastLapackInterface
206+
results = autotune_setup(include_fastlapack = true)
207+
202208
# After running autotune, share results (requires gh CLI or GitHub token)
203209
share_results(results)
204210
```
@@ -209,7 +215,8 @@ function autotune_setup(;
209215
samples::Int = 5,
210216
seconds::Float64 = 0.5,
211217
eltypes = (Float64,),
212-
skip_missing_algs::Bool = false)
218+
skip_missing_algs::Bool = false,
219+
include_fastlapack::Bool = false)
213220
@info "Starting LinearSolve.jl autotune setup..."
214221
@info "Configuration: sizes=$sizes, set_preferences=$set_preferences"
215222
@info "Element types to benchmark: $(join(eltypes, ", "))"
@@ -219,7 +226,7 @@ function autotune_setup(;
219226
@info "System detected: $(system_info["os"]) $(system_info["arch"]) with $(system_info["num_cores"]) cores"
220227

221228
# Get available algorithms
222-
cpu_algs, cpu_names = get_available_algorithms(; skip_missing_algs = skip_missing_algs)
229+
cpu_algs, cpu_names = get_available_algorithms(; skip_missing_algs = skip_missing_algs, include_fastlapack = include_fastlapack)
223230
@info "Found $(length(cpu_algs)) CPU algorithms: $(join(cpu_names, ", "))"
224231

225232
# Add GPU algorithms if available

lib/LinearSolveAutotune/src/algorithms.jl

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Algorithm detection and creation functions
22

33
"""
4-
get_available_algorithms(; skip_missing_algs::Bool = false)
4+
get_available_algorithms(; skip_missing_algs::Bool = false, include_fastlapack::Bool = false)
55
66
Returns a list of available LU factorization algorithms based on the system and loaded packages.
77
If skip_missing_algs=false, errors when expected algorithms are missing; if true, warns instead.
8+
If include_fastlapack=true and FastLapackInterface is loaded, includes FastLUFactorization in benchmarks.
89
"""
9-
function get_available_algorithms(; skip_missing_algs::Bool = false)
10+
function get_available_algorithms(; skip_missing_algs::Bool = false, include_fastlapack::Bool = false)
1011
algs = []
1112
alg_names = String[]
1213

@@ -68,6 +69,23 @@ function get_available_algorithms(; skip_missing_algs::Bool = false)
6869
push!(algs, SimpleLUFactorization())
6970
push!(alg_names, "SimpleLUFactorization")
7071

72+
# FastLapackInterface LU if requested and available
73+
if include_fastlapack
74+
try
75+
# Try to create a FastLUFactorization to see if the extension is loaded
76+
test_alg = FastLUFactorization()
77+
push!(algs, test_alg)
78+
push!(alg_names, "FastLUFactorization")
79+
@info "FastLUFactorization included in benchmarks"
80+
catch e
81+
if occursin("UndefVarError", string(e))
82+
@warn "FastLUFactorization requested but FastLapackInterface.jl not loaded. Load it with: using FastLapackInterface"
83+
else
84+
@warn "FastLUFactorization requested but not available: $e"
85+
end
86+
end
87+
end
88+
7189
return algs, alg_names
7290
end
7391

0 commit comments

Comments
 (0)