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
Performance issue with (sparse) backsolve after LU factorization (turn off iterative refinement by default) #122
Comments
Maybe same issue as JuliaLang/julia#19500. You could try run MATLAB single threaded and see if things change. |
Knowing if this is the same issue is out of reach for my uneducated brain. But it seems to me they are different because issue JuliaLang/julia#19500 is about multiple RHS, while the performance issue herein is the same with both a single RHS and multiple RHS... Could you let me know how to force single thread? (The machine I used was a 1-node 12-cores one.) |
Yeah, I read a bit quickly and mostly noticed the slowdown for the multiple RHS. |
JuliaLang/julia#19500 mentions two possible speed-ups and I think the first one is mentioned there might explain the difference to Matlab. I'm getting julia> @btime Mf \ x ;
710.918 ms (6 allocations: 1.22 MiB)
julia> @btime Mf \ [x 2x 3x 4x] ;
3.198 s (32 allocations: 5.95 MiB)
julia> SuiteSparse.UMFPACK.umf_ctrl[8]
2.0
julia> SuiteSparse.UMFPACK.umf_ctrl[8]=0
0
julia> @btime Mf \ x ;
225.241 ms (6 allocations: 625.19 KiB)
julia> @btime Mf \ [x 2x 3x 4x] ;
905.906 ms (32 allocations: 3.51 MiB) i.e. disabling iterative refinements helps a lot. I still don't think we expose this option in a more convenient way and I'm also wondering if we should disable the refinements by default but julia> norm(x - M*sol_refinements)
3.877108630658927e-12
julia> norm(x - M*sol_no_refinements)
5.613799611342331e-8 Could you check the error in Matlab? Does it look like refinements are on by default? |
Hey there, sorry for the delayed response, but here it is. It seems that you are right, the refinements are off in MATLAB when using I used the same data as earlier (loading the same file) and I checked a couple of norms to compare the errors in MATLAB and Julia. First are the results (the code I used is at the end of this post).
(In addition to the absolute error I added the relative one because I think its magnitude is likely more robust, in case you want to compare those from different machines / runs / randomly-created matrices Code used:
|
@andreasnoack Should I close this issue? Or do you want it to remain open as a reminder in case you want to eventually "expose this option [to turn the iterative refinements on or off] in a more convenient way"? |
I think we should keep this one open until we have made a decision about the iterative refinements. |
I think iterative refinement should not be the default and should be opt-in. |
@SobhanMP In your workspace sizing code, I noticed the comment that it could be smaller if iterative refinement is off. Would it be a huge gain? We do want to turn off iterative refinement by default, but have a way to turn it on optionally. |
@ViralBShah |
That's huge. Would love to get those savings! |
|
#181 disables iterative refinement. Would be nice if folks can confirm performance improvement. |
I noticed there was a performance issue with the backsolve that I thought I should share here.
Coming from MATLAB I thought the best way to show this performance issue was to benchmark the two on the same machine with the same data, so here it is. I perform a simple backslash (
M \ x
), a factorization (factorize(M)
), and two backsolves (Mf \ x
andMf \ [x 2x 3x 4x]
) using a somewhat-random matrixM
and vectorx
. First, I use MATLAB (v2017b) to perform this test and I saveM
andx
in a.mat
file. Finally I load these in Julia (v1.1.0) using the MAT.jl package and perform the same test again. (I] up
'd my packages before this test.)Here are the results (the code I used is at the end of this post):
MATLAB performance:
Julia performance:
As you can see the backsolves in Julia take roughly 3–4 times as long as the MATLAB equivalent, while the factorization takes roughly the same time. Any idea what is the issue there? (Note using inplace
ldiv!
does not change those times).(I know I am comparing apples to oranges, and that this could be an artefact of the random
M
andx
but I seem to see this happen every time and I think there is too significant a difference in performance to be neglected. Please tell me if I am wrong 🙂)The code I used:
MATLAB code:
Julia code
The text was updated successfully, but these errors were encountered: