[petsc-users] Speed of KSPSolve using Matshell vs. regular matrix
Yuyun Yang
yyang85 at stanford.edu
Sat Mar 28 20:14:33 CDT 2020
Thanks for the explanations. Yes they are identical if no preconditioner is applied.
A follow-up question on this: in the case of a changing matrix at every time step, it's necessary for my code to destroy and re-assemble the matrix every time, so I was wondering whether the matrix-free method, even though with no preconditioner the KSP convergence is slower, would have any advantage by saving the matrix assembly step? Or the time saved by that is insignificant compared to the slowdown in KSP with a preconditioned matrix?
Thank you,
Yuyun
获取 Outlook for Android<https://aka.ms/ghei36>
________________________________
From: Mark Adams <mfadams at lbl.gov>
Sent: Saturday, March 28, 2020 10:29:14 PM
To: Jed Brown <jed at jedbrown.org>
Cc: Yuyun Yang <yyang85 at stanford.edu>; petsc-users at mcs.anl.gov <petsc-users at mcs.anl.gov>
Subject: Re: [petsc-users] Speed of KSPSolve using Matshell vs. regular matrix
I think Yuyun is saying "....inevitable to encounter significant slowdown compared to using a fully assembled matrix with a suitable preconditioner? "
You convergence rate will basically always be better with a preconditioner and unless you are solving the identity (mass matrix) then it will often be significant.
Jed is responding to comparing un-preconditioned matrix vs matrix-free and you do want to check that they are identical if you think you have an exact Jacobian of a linear problem.
On Sat, Mar 28, 2020 at 9:54 AM Jed Brown <jed at jedbrown.org<mailto:jed at jedbrown.org>> wrote:
If the number of iterations is (significantly) different, then you'd
have to debug why your code doesn't implement the same linear operator.
You can use MatComputeOperator or -ksp_view_mat_explicit to help reveal
differences.
If the number of iterations is the same but your code is slower, then
you'd have to optimize the performance of your code.
Yuyun Yang <yyang85 at stanford.edu<mailto:yyang85 at stanford.edu>> writes:
> Hello team,
>
> If I use KSPSolve for Ax=b using Matshell (a user-defined stencil equivalent of A) without preconditioning (since the standard PC would need information of the matrix so cannot apply it to matrix-free method), is it possible, or even inevitable to encounter significant slowdown compared to using a fully assembled matrix with a suitable preconditioner? I'm running a small example and it's already taking a long time for Matshell to converge.
>
> Thanks for your help,
> Yuyun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200329/c06a0522/attachment.html>
More information about the petsc-users
mailing list