[petsc-users] Speed of KSPSolve using Matshell vs. regular matrix

Mark Adams mfadams at lbl.gov
Sat Mar 28 09:29:14 CDT 2020


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> 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> 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/20200328/841bbedb/attachment.html>


More information about the petsc-users mailing list