[petsc-users] MatSolve in CG

Stefano Zampini stefano.zampini at kaust.edu.sa
Sun Nov 16 00:45:39 CST 2014


Vincent,

PCBDDC has three nested solvers in it (Dirichlet, Neumann and Coarse solver), each of them calling MatSolve if you are using direct solvers for them (which is the default).
When used in conjunction with conjugate gradients, BDDC can take advantage of that and just use one dirichlet solve per iteration (this is a well known trick for hybrid Schwarz algorithms); if the KSP is not of the CG type, PCBDDC will instead need 2 Dirichlet solvers per iteration
 Thus the difference in the number of MatSolve per iteration: in your PCG implementation, your CG kernel is not aware of this and does not propagate the information to PCBDDC..
Regarding the additional solve you report somewhere-in-between KSPSolve and KSPSolve_CG: the above trick for hybrid Shwarz algorithms come at a cost, and this cost is an additional Dirichlet solve inside PCPresolve_BDDC.

Stefano
________________________________________
Da: Jed Brown [jed at jedbrown.org]
Inviato: domenica 16 novembre 2014 0.30
A: De Groof, Vincent Frans Maria; petsc-users at mcs.anl.gov
Cc: Stefano Zampini
Oggetto: Re: [petsc-users] MatSolve in CG

"De Groof, Vincent Frans Maria" <Vincent.De-Groof at uibk.ac.at> writes:

> Dear all,
>
>
> I am writing a few variations on the PCG algorithm. Starting with my own PCG implementation, I noticed that my routine is quite a bit slower (~20%). I think I tracked it down to the MatSolve calls in PCApply. I am using BDDC as the preconditioner.
>
> In the Petsc PCG function, each PCApply calls the MatSolve 3 times. It also calls MatSolve once somewhere between calling KSPSolve and KSPSolve_CG (KSP_SetUp has been called before). So MatSolve is called 1+3*(# iterations) per KSPSolve. In my own PCG variation, the initial MatSolve is not called. But MatSolve is called 4 times in each iteration, so in total 4*(# iterations).
>
> Where does this MatSolve in between KSPSolve and KSPSolve_CG come from? And how can I make my function use less MatSolve's?

I recommend running in a debugger to get the stack trace.  I don't know
what is different between your Krylov implementation and CG, but it
should be obvious when you compare.

________________________________

This message and its contents including attachments are intended solely for the original recipient. If you are not the intended recipient or have received this message in error, please notify me immediately and delete this message from your computer system. Any unauthorized use or distribution is prohibited. Please consider the environment before printing this email.


More information about the petsc-users mailing list