From 1ef951fd1e1b5a65dc7552e08192b628ab03640d Mon Sep 17 00:00:00 2001 From: ChrisRackauckas Date: Sun, 10 Aug 2025 18:18:12 -0400 Subject: [PATCH 1/3] 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 --- Project.toml | 1 - .../src/LinearSolveAutotune.jl | 13 ++++++++--- lib/LinearSolveAutotune/src/algorithms.jl | 22 +++++++++++++++++-- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Project.toml b/Project.toml index 1ca75401f..1a5fe1a80 100644 --- a/Project.toml +++ b/Project.toml @@ -36,7 +36,6 @@ CUDSS = "45b445bb-4962-46a0-9369-b4df9d0f772e" CUSOLVERRF = "a8cc9031-bad2-4722-94f5-40deabb4245c" EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869" FastAlmostBandedMatrices = "9d29842c-ecb8-4973-b1e9-a27b1157504e" -FastLapackInterface = "29a986be-02c6-4525-aec4-84b980013641" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" HYPRE = "b5ffcf37-a2bd-41ab-a3da-4bd9bc8ad771" IterativeSolvers = "42fd0dbc-a981-5370-80f2-aaf504508153" diff --git a/lib/LinearSolveAutotune/src/LinearSolveAutotune.jl b/lib/LinearSolveAutotune/src/LinearSolveAutotune.jl index 0cbfd6d7c..dfb709acb 100644 --- a/lib/LinearSolveAutotune/src/LinearSolveAutotune.jl +++ b/lib/LinearSolveAutotune/src/LinearSolveAutotune.jl @@ -156,7 +156,8 @@ end samples::Int = 5, seconds::Float64 = 0.5, eltypes = (Float32, Float64, ComplexF32, ComplexF64), - skip_missing_algs::Bool = false) + skip_missing_algs::Bool = false, + include_fastlapack::Bool = false) Run a comprehensive benchmark of all available LU factorization methods and optionally: @@ -179,6 +180,7 @@ Run a comprehensive benchmark of all available LU factorization methods and opti - `seconds::Float64 = 0.5`: Maximum time per benchmark - `eltypes = (Float32, Float64, ComplexF32, ComplexF64)`: Element types to benchmark - `skip_missing_algs::Bool = false`: If false, error when expected algorithms are missing; if true, warn instead + - `include_fastlapack::Bool = false`: If true and FastLapackInterface.jl is loaded, includes FastLUFactorization in benchmarks # Returns @@ -199,6 +201,10 @@ results = autotune_setup(sizes = [:small, :medium, :large, :big]) # Large matrices only results = autotune_setup(sizes = [:large, :big], samples = 10, seconds = 1.0) +# Include FastLapackInterface.jl algorithms if available +using FastLapackInterface +results = autotune_setup(include_fastlapack = true) + # After running autotune, share results (requires gh CLI or GitHub token) share_results(results) ``` @@ -209,7 +215,8 @@ function autotune_setup(; samples::Int = 5, seconds::Float64 = 0.5, eltypes = (Float64,), - skip_missing_algs::Bool = false) + skip_missing_algs::Bool = false, + include_fastlapack::Bool = false) @info "Starting LinearSolve.jl autotune setup..." @info "Configuration: sizes=$sizes, set_preferences=$set_preferences" @info "Element types to benchmark: $(join(eltypes, ", "))" @@ -219,7 +226,7 @@ function autotune_setup(; @info "System detected: $(system_info["os"]) $(system_info["arch"]) with $(system_info["num_cores"]) cores" # Get available algorithms - cpu_algs, cpu_names = get_available_algorithms(; skip_missing_algs = skip_missing_algs) + cpu_algs, cpu_names = get_available_algorithms(; skip_missing_algs = skip_missing_algs, include_fastlapack = include_fastlapack) @info "Found $(length(cpu_algs)) CPU algorithms: $(join(cpu_names, ", "))" # Add GPU algorithms if available diff --git a/lib/LinearSolveAutotune/src/algorithms.jl b/lib/LinearSolveAutotune/src/algorithms.jl index 360f4bd40..b6c25cb55 100644 --- a/lib/LinearSolveAutotune/src/algorithms.jl +++ b/lib/LinearSolveAutotune/src/algorithms.jl @@ -1,12 +1,13 @@ # Algorithm detection and creation functions """ - get_available_algorithms(; skip_missing_algs::Bool = false) + get_available_algorithms(; skip_missing_algs::Bool = false, include_fastlapack::Bool = false) Returns a list of available LU factorization algorithms based on the system and loaded packages. If skip_missing_algs=false, errors when expected algorithms are missing; if true, warns instead. +If include_fastlapack=true and FastLapackInterface is loaded, includes FastLUFactorization in benchmarks. """ -function get_available_algorithms(; skip_missing_algs::Bool = false) +function get_available_algorithms(; skip_missing_algs::Bool = false, include_fastlapack::Bool = false) algs = [] alg_names = String[] @@ -68,6 +69,23 @@ function get_available_algorithms(; skip_missing_algs::Bool = false) push!(algs, SimpleLUFactorization()) push!(alg_names, "SimpleLUFactorization") + # FastLapackInterface LU if requested and available + if include_fastlapack + try + # Try to create a FastLUFactorization to see if the extension is loaded + test_alg = FastLUFactorization() + push!(algs, test_alg) + push!(alg_names, "FastLUFactorization") + @info "FastLUFactorization included in benchmarks" + catch e + if occursin("UndefVarError", string(e)) + @warn "FastLUFactorization requested but FastLapackInterface.jl not loaded. Load it with: using FastLapackInterface" + else + @warn "FastLUFactorization requested but not available: $e" + end + end + end + return algs, alg_names end From b86d2f864ae060d48dec54cf85087767dbbe3620 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Sun, 10 Aug 2025 19:58:55 -0400 Subject: [PATCH 2/3] Update Project.toml --- Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Project.toml b/Project.toml index 1a5fe1a80..1ca75401f 100644 --- a/Project.toml +++ b/Project.toml @@ -36,6 +36,7 @@ CUDSS = "45b445bb-4962-46a0-9369-b4df9d0f772e" CUSOLVERRF = "a8cc9031-bad2-4722-94f5-40deabb4245c" EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869" FastAlmostBandedMatrices = "9d29842c-ecb8-4973-b1e9-a27b1157504e" +FastLapackInterface = "29a986be-02c6-4525-aec4-84b980013641" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" HYPRE = "b5ffcf37-a2bd-41ab-a3da-4bd9bc8ad771" IterativeSolvers = "42fd0dbc-a981-5370-80f2-aaf504508153" From b7cdf15d19801e9071396a25c89e9d7dedec8867 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas Date: Sun, 10 Aug 2025 20:05:13 -0400 Subject: [PATCH 3/3] Add FastLapackInterface as dependency to LinearSolveAutotune - FastLapackInterface is now a direct dependency of LinearSolveAutotune - Simplified the algorithm detection logic since it's always available - Updated documentation to reflect that users don't need to load it separately - The include_fastlapack parameter still defaults to false for backward compatibility --- lib/LinearSolveAutotune/Project.toml | 2 ++ .../src/LinearSolveAutotune.jl | 6 +++--- lib/LinearSolveAutotune/src/algorithms.jl | 19 ++++--------------- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/lib/LinearSolveAutotune/Project.toml b/lib/LinearSolveAutotune/Project.toml index f01a99bd7..9d06c49cb 100644 --- a/lib/LinearSolveAutotune/Project.toml +++ b/lib/LinearSolveAutotune/Project.toml @@ -10,6 +10,7 @@ CPUSummary = "2a0fbf3d-bb9c-48f3-b0a9-814d99fd7ab9" CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" +FastLapackInterface = "29a986be-02c6-4525-aec4-84b980013641" GitHub = "bc5e4493-9b4d-5f90-b8aa-2b2bcaad7a26" LAPACK_jll = "51474c39-65e3-53ba-86ba-03b1b862ec14" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" @@ -36,6 +37,7 @@ CPUSummary = "0.2" CUDA = "5" DataFrames = "1" Dates = "1" +FastLapackInterface = "2" GitHub = "5" LAPACK_jll = "3" LinearAlgebra = "1" diff --git a/lib/LinearSolveAutotune/src/LinearSolveAutotune.jl b/lib/LinearSolveAutotune/src/LinearSolveAutotune.jl index dfb709acb..f698de377 100644 --- a/lib/LinearSolveAutotune/src/LinearSolveAutotune.jl +++ b/lib/LinearSolveAutotune/src/LinearSolveAutotune.jl @@ -36,6 +36,7 @@ using blis_jll using LAPACK_jll using CUDA using Metal +using FastLapackInterface # Optional dependencies for telemetry and plotting @@ -180,7 +181,7 @@ Run a comprehensive benchmark of all available LU factorization methods and opti - `seconds::Float64 = 0.5`: Maximum time per benchmark - `eltypes = (Float32, Float64, ComplexF32, ComplexF64)`: Element types to benchmark - `skip_missing_algs::Bool = false`: If false, error when expected algorithms are missing; if true, warn instead - - `include_fastlapack::Bool = false`: If true and FastLapackInterface.jl is loaded, includes FastLUFactorization in benchmarks + - `include_fastlapack::Bool = false`: If true, includes FastLUFactorization in benchmarks # Returns @@ -201,8 +202,7 @@ results = autotune_setup(sizes = [:small, :medium, :large, :big]) # Large matrices only results = autotune_setup(sizes = [:large, :big], samples = 10, seconds = 1.0) -# Include FastLapackInterface.jl algorithms if available -using FastLapackInterface +# Include FastLapackInterface.jl algorithms results = autotune_setup(include_fastlapack = true) # After running autotune, share results (requires gh CLI or GitHub token) diff --git a/lib/LinearSolveAutotune/src/algorithms.jl b/lib/LinearSolveAutotune/src/algorithms.jl index b6c25cb55..d71c2b768 100644 --- a/lib/LinearSolveAutotune/src/algorithms.jl +++ b/lib/LinearSolveAutotune/src/algorithms.jl @@ -5,7 +5,7 @@ Returns a list of available LU factorization algorithms based on the system and loaded packages. If skip_missing_algs=false, errors when expected algorithms are missing; if true, warns instead. -If include_fastlapack=true and FastLapackInterface is loaded, includes FastLUFactorization in benchmarks. +If include_fastlapack=true, includes FastLUFactorization in benchmarks. """ function get_available_algorithms(; skip_missing_algs::Bool = false, include_fastlapack::Bool = false) algs = [] @@ -69,21 +69,10 @@ function get_available_algorithms(; skip_missing_algs::Bool = false, include_fas push!(algs, SimpleLUFactorization()) push!(alg_names, "SimpleLUFactorization") - # FastLapackInterface LU if requested and available + # FastLapackInterface LU if requested (always available as dependency) if include_fastlapack - try - # Try to create a FastLUFactorization to see if the extension is loaded - test_alg = FastLUFactorization() - push!(algs, test_alg) - push!(alg_names, "FastLUFactorization") - @info "FastLUFactorization included in benchmarks" - catch e - if occursin("UndefVarError", string(e)) - @warn "FastLUFactorization requested but FastLapackInterface.jl not loaded. Load it with: using FastLapackInterface" - else - @warn "FastLUFactorization requested but not available: $e" - end - end + push!(algs, FastLUFactorization()) + push!(alg_names, "FastLUFactorization") end return algs, alg_names