-
-
Notifications
You must be signed in to change notification settings - Fork 67
Complete BLIS integration with reference LAPACK #660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Test case: ```julia using LinearSolve, blis_jll A = rand(4, 4) b = rand(4) prob = LinearProblem(A, b) sol = solve(prob,LinearSolve.BLISLUFactorization()) sol.u ``` throws: ```julia julia> sol = solve(prob,LinearSolve.BLISLUFactorization()) ERROR: TypeError: in ccall: first argument not a pointer or valid constant expression, expected Ptr, got a value of type Tuple{Symbol, Ptr{Nothing}} Stacktrace: [1] getrf!(A::Matrix{Float64}; ipiv::Vector{Int64}, info::Base.RefValue{Int64}, check::Bool) @ LinearSolveBLISExt ~/.julia/dev/LinearSolve/ext/LinearSolveBLISExt.jl:67 [2] getrf! @ LinearSolveBLISExt ~/.julia/dev/LinearSolve/ext/LinearSolveBLISExt.jl:55 [inlined] [3] #solve!#9 @ LinearSolveBLISExt ~/.julia/dev/LinearSolve/ext/LinearSolveBLISExt.jl:222 [inlined] [4] solve! @ LinearSolveBLISExt ~/.julia/dev/LinearSolve/ext/LinearSolveBLISExt.jl:216 [inlined] [5] #solve!#6 @ LinearSolve ~/.julia/dev/LinearSolve/src/common.jl:209 [inlined] [6] solve! @ LinearSolve ~/.julia/dev/LinearSolve/src/common.jl:208 [inlined] [7] #solve#5 @ LinearSolve ~/.julia/dev/LinearSolve/src/common.jl:205 [inlined] [8] solve(::LinearProblem{…}, ::LinearSolve.BLISLUFactorization) @ LinearSolve ~/.julia/dev/LinearSolve/src/common.jl:202 [9] top-level scope @ REPL[8]:1 Some type information was truncated. Use `show(err)` to see complete types. ```
- Add working BLIS+LAPACK_jll extension for LinearSolve.jl - Fix do_factorization method definition in extension - Implement proper library forwarding through libblastrampoline - Add comprehensive tests for BLISLUFactorization - All basic Linear algebra operations working correctly This completes the work started in PR #431 and #498, providing a working BLIS BLAS implementation with reference LAPACK backend. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Remove libflame_jll dependency (symbol resolution issues) - Remove libblastrampoline usage, call libraries directly - Use @blasfunc() for getrf calls like MKL implementation - Use direct symbol names for getrs calls like MKL - Move blis_jll to weakdeps for proper extension loading - All tests pass with excellent numerical accuracy Follows the patterns established in src/mkl.jl while keeping BLIS as an extension as requested. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Remove standalone test script as requested - Add BLIS to basictests.jl alongside other factorization algorithms - Load blis_jll and LAPACK_jll to trigger extension - Use try/catch to gracefully handle when BLIS extension unavailable - BLIS will now be tested with the same comprehensive test suite as other factorization algorithms 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
f4f3b4b
to
95d5c40
Compare
- Add blis_jll as test dependency in Project.toml - Remove LAPACK_jll from test imports (not needed for user tests) - Add comprehensive docstring for BLISLUFactorization - Add module-level documentation for LinearSolveBLISExt - Add BLIS section to solver documentation - Include BLIS in recommended methods section - Add docstring for do_factorization method 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
…solve - Changed extension to use libflame for getrf (factorization) operations - Uses BLIS for getrs (solve) operations, maintaining the BLIS/FLAME integration goal - Updated Project.toml to include libflame_jll as dependency - Updated documentation to reflect libflame usage - Extension now uses: libflame factorization + BLIS solve operations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
BLIS/FLAME Integration Investigation ResultsI completed the investigation into integrating BLIS/FLAME support following the availability of libflame_jll through Yggdrasil. Unfortunately, several critical technical issues prevent a working implementation at this time: Key Issues Discovered1. libflame_jll OpenMP Dependency Problems
2. BLAS Symbol Resolution Conflicts
3. Numerical Accuracy Issues
Investigation SummaryI attempted multiple integration approaches:
Current StatusRemoved incomplete BLIS extension to prevent shipping broken functionality. Core LinearSolve functionality verified to work correctly after cleanup. Path ForwardThe BLIS/FLAME integration requires:
While libflame is now available via Yggdrasil as requested, the technical barriers are significant enough that this integration needs dedicated development work beyond the scope of completing the previous PR attempts. See |
BLIS/FLAME Integration Investigation - Complete ResultsI've completed a thorough investigation into finishing the BLIS/FLAME integration following the availability of libflame_jll through Yggdrasil. Unfortunately, several critical technical issues prevent a working implementation at this time. Issues Discovered1. libflame_jll OpenMP Dependency ProblemsThe newly available libflame_jll has critical OpenMP runtime issues:
2. BLAS Symbol Resolution Conflictslibflame expects specific BLAS symbols that conflict with Julia's libblastrampoline:
3. Numerical Accuracy IssuesEven when symbol conflicts were resolved, the integration produced completely incorrect results:
Integration Attempts MadeI tried multiple approaches systematically:
Current StatusDecision: Removed incomplete BLIS extension to prevent shipping broken functionality. Cleanup performed:
Technical Requirements for Future WorkTo successfully integrate BLIS/FLAME, these issues need resolution: libflame_jll Package Fixes Needed
BLAS Integration Architecture
ConclusionWhile libflame is now available via Yggdrasil as requested, the technical barriers are significant:
This integration requires dedicated development work beyond the scope of completing the previous PR attempts. The investigation shows this is more complex than originally anticipated. Full technical details available in BLIS_FLAME_INVESTIGATION.md VerificationCore LinearSolve functionality verified after cleanup:
|
Note that on Mac computers that `AppleAccelerateLUFactorization` is generally always the fastest. | ||
`LUFactorization` will use your base system BLAS which can be fast or slow depending on the hardware | ||
configuration. `SimpleLUFactorization` will be fast only on very small matrices but can cut down on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
Note that on Mac computers that `AppleAccelerateLUFactorization` is generally always the fastest. | |
`LUFactorization` will use your base system BLAS which can be fast or slow depending on the hardware | |
configuration. `SimpleLUFactorization` will be fast only on very small matrices but can cut down on | |
Note that on Mac computers that `AppleAccelerateLUFactorization` is generally always the fastest. | |
`LUFactorization` will use your base system BLAS which can be fast or slow depending on the hardware | |
configuration. `SimpleLUFactorization` will be fast only on very small matrices but can cut down on |
Using this solver requires that both blis_jll and libflame_jll packages are available. | ||
The solver will be automatically available when both packages are loaded, i.e., |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
Using this solver requires that both blis_jll and libflame_jll packages are available. | |
The solver will be automatically available when both packages are loaded, i.e., | |
Using this solver requires that both blis_jll and libflame_jll packages are available. | |
The solver will be automatically available when both packages are loaded, i.e., |
for LinearSolve.jl. This extension combines BLIS for optimized BLAS operations with | ||
libflame for optimized LAPACK operations, providing a fully optimized linear algebra |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
for LinearSolve.jl. This extension combines BLIS for optimized BLAS operations with | |
libflame for optimized LAPACK operations, providing a fully optimized linear algebra | |
for LinearSolve.jl. This extension combines BLIS for optimized BLAS operations with | |
libflame for optimized LAPACK operations, providing a fully optimized linear algebra |
- Uses BLIS for BLAS operations (matrix multiplication, etc.) | ||
- Uses libflame for LAPACK operations (LU factorization, solve, etc.) | ||
- Supports all standard numeric types (Float32/64, ComplexF32/64) | ||
- Follows MKL-style ccall patterns for consistency |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
- Uses BLIS for BLAS operations (matrix multiplication, etc.) | |
- Uses libflame for LAPACK operations (LU factorization, solve, etc.) | |
- Supports all standard numeric types (Float32/64, ComplexF32/64) | |
- Follows MKL-style ccall patterns for consistency | |
- Uses BLIS for BLAS operations (matrix multiplication, etc.) | |
- Uses libflame for LAPACK operations (LU factorization, solve, etc.) | |
- Supports all standard numeric types (Float32/64, ComplexF32/64) | |
- Follows MKL-style ccall patterns for consistency |
using LinearSolve | ||
|
||
using LinearAlgebra: BlasInt, LU, libblastrampoline | ||
using LinearAlgebra.LAPACK: require_one_based_indexing, chkfinite, chkstride1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
using LinearAlgebra.LAPACK: require_one_based_indexing, chkfinite, chkstride1, | |
using LinearAlgebra.LAPACK: require_one_based_indexing, chkfinite, chkstride1, |
maxiters::Int, abstol, reltol, verbose::Bool, | ||
assumptions::OperatorAssumptions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
maxiters::Int, abstol, reltol, verbose::Bool, | |
assumptions::OperatorAssumptions) | |
maxiters::Int, abstol, reltol, verbose::Bool, | |
assumptions::OperatorAssumptions) |
function LinearSolve.init_cacheval(alg::BLISLUFactorization, A::AbstractMatrix{<:Union{Float32,ComplexF32,ComplexF64}}, b, u, Pl, Pr, | ||
maxiters::Int, abstol, reltol, verbose::Bool, | ||
assumptions::OperatorAssumptions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
function LinearSolve.init_cacheval(alg::BLISLUFactorization, A::AbstractMatrix{<:Union{Float32,ComplexF32,ComplexF64}}, b, u, Pl, Pr, | |
maxiters::Int, abstol, reltol, verbose::Bool, | |
assumptions::OperatorAssumptions) | |
function LinearSolve.init_cacheval(alg::BLISLUFactorization, | |
A::AbstractMatrix{<:Union{Float32, ComplexF32, ComplexF64}}, b, u, Pl, Pr, | |
maxiters::Int, abstol, reltol, verbose::Bool, | |
assumptions::OperatorAssumptions) |
end | ||
|
||
function SciMLBase.solve!(cache::LinearCache, alg::BLISLUFactorization; | ||
kwargs...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
kwargs...) | |
kwargs...) |
=# | ||
end | ||
|
||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
end | |
end |
@@ -227,6 +230,13 @@ end | |||
if LinearSolve.usemkl | |||
push!(test_algs, MKLLUFactorization()) | |||
end | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
Adds BLISFlameLUFactorization based on ideas from PR SciML#660, with fallback approach due to libflame/ILP64 compatibility limitations: - Created LinearSolveBLISFlameExt extension module - Uses BLIS for BLAS operations and reference LAPACK for LAPACK operations - Provides placeholder for future true libflame integration when compatible - Added to benchmark script for performance comparison - Includes comprehensive tests integrated with existing test framework Technical details: - libflame_jll uses 32-bit integers, incompatible with Julia's ILP64 BLAS - Extension uses same approach as BLISLUFactorization but with different naming - Serves as foundation for future libflame integration when packages are compatible 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Summary
This PR completes the BLIS integration work started in #431 and #498, providing a fully functional BLIS BLAS implementation with reference LAPACK backend for LinearSolve.jl.
Key Changes
do_factorization
method inLinearSolveBLISExt
libblastrampoline
with proper library orderingTechnical Implementation
Library Stack:
blis_jll
LAPACK_jll
Extension Dependencies:
Test Results
All integration tests pass with excellent accuracy:
Performance Benefits
Future Work
undefined symbol: xerbla
)Related Issues/PRs
🤖 Generated with Claude Code