SciML / LinearSolve.jl

LinearSolve.jl: High-Performance Unified Interface for Linear Solvers in Julia. Easily switch between factorization and Krylov methods, add preconditioners, and all in one interface.
https://docs.sciml.ai/LinearSolve/stable/
Other
241 stars 52 forks source link

WIP: Wrap BLIS #431

Open ChrisRackauckas opened 9 months ago

ChrisRackauckas commented 9 months ago

Test case:

using LinearSolve, blis_jll

A = rand(4, 4)
b = rand(4)
prob = LinearProblem(A, b)
sol = solve(prob,LinearSolve.BLISLUFactorization())
sol.u

throws:

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.
ChrisRackauckas commented 9 months ago

@staticfloat do you know why it would give that error? That's the same way I'm loading the other BLAS's. I thought this would be a nice factorization choice for you to give a try on EPYC.

codecov[bot] commented 9 months ago

Codecov Report

Merging #431 (afcc28e) into main (a455e27) will decrease coverage by 37.63%. The diff coverage is 0.00%.

@@             Coverage Diff             @@
##             main     #431       +/-   ##
===========================================
- Coverage   63.80%   26.17%   -37.63%     
===========================================
  Files          26       27        +1     
  Lines        2097     2204      +107     
===========================================
- Hits         1338      577      -761     
- Misses        759     1627      +868     
Files Coverage Δ
src/extension_algs.jl 66.66% <ø> (-2.90%) :arrow_down:
ext/LinearSolveBLISExt.jl 0.00% <0.00%> (ø)

... and 16 files with indirect coverage changes

:mega: Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

ChrisRackauckas commented 9 months ago

I guess my issue is that BLIS isn't a full BLAS and this is in FLAME?

amontoison commented 9 months ago

getrf! is a LAPACK routine. BLIS is an implementation BLAS so you need to combine blis_jll.jl with LAPACK_jll.jl. It's what is done in AppleAccelerate.jl.

We should probably update BLISBLAS.jl to do that automatically like MKL.jl or AppleAccelerate.jl.

jd-foster commented 3 months ago

@amontoison I've taken up your idea and shown it can be done in #498, but I also think the best course would be to enable this in one go in a package automatically (i.e. in BLISBLAS.jl and use that in the extension.)

amontoison commented 3 months ago

@jd-foster I opened a PR in BLISBLAS.jl for the 32-bit integer version that is used by many artifact package (such as Ipopt, MUMPS, ...) and the PR was never merged.

I don't know if BLISBLAS.jl is still maintained.