-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
Setup MKL direct factorizations #349
Conversation
MWE: ```julia using LinearSolve, MKL_jll A = rand(4, 4); b = rand(4); u0 = zeros(4); lp = LinearProblem(A, b); truesol = solve(lp, LUFactorization()) mklsol = solve(lp, MKLLUFactorization()) @test truesol ≈ mklsol ``` The segfault can be reproduced just with the triangular solver. MWE without LinearSolve: ```julia using MKL_jll using LinearAlgebra: BlasInt, LU using LinearAlgebra.LAPACK: require_one_based_indexing, chkfinite, chkstride1, chkargsok const usemkl = MKL_jll.is_available() function getrf!(A::AbstractMatrix{<:Float64}; ipiv = similar(A, BlasInt, min(size(A,1),size(A,2))), info = Ref{BlasInt}(), check = false) require_one_based_indexing(A) check && chkfinite(A) chkstride1(A) m, n = size(A) lda = max(1,stride(A, 2)) ccall((:dgetrf_, MKL_jll.libmkl_rt), Cvoid, (Ref{BlasInt}, Ref{BlasInt}, Ptr{Float64}, Ref{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}), m, n, A, lda, ipiv, info) chkargsok(info[]) A, ipiv, info[] #Error code is stored in LU factorization type end A = rand(4,4); b = rand(4) getrf!(A) LU(getrf!(A)...) \ b ```
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.
AI-Maintainer Review for PR - WIP: Setup MKL direct factorizations
Title and Description 👍
Scope of Changes 👍
Documentation 👍
Testing 👍
Suggested Changes
- Please provide more context in the PR description about why these changes are necessary and what problem they aim to solve.
- Please provide more details about the testing process, such as any additional test cases or scenarios that were considered.
Reviewed with AI Maintainer
@staticfloat or @chriselrod maybe you might have an idea of what I'm doing wrong here to cause a segfault? |
Codecov Report
@@ Coverage Diff @@
## main #349 +/- ##
===========================================
- Coverage 75.29% 64.70% -10.60%
===========================================
Files 17 18 +1
Lines 1267 1292 +25
===========================================
- Hits 954 836 -118
- Misses 313 456 +143
... and 4 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
ext/LinearSolveMKLExt.jl
Outdated
ipiv = similar(A, BlasInt, min(size(A,1),size(A,2))) | ||
end | ||
|
||
ccall((:dgetrf_, MKL_jll.libmkl_rt), Cvoid, |
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.
I don't seem to be adding a trailing underscore to dgetrf_
You've got MKL in 32-bit mode, but passing it
There are a bunch of ways to fix this, but the best is to import |
MWE:
The segfault can be reproduced just with the triangular solver. MWE without LinearSolve: