Hello, I use viennacl cg and bicgstab to solve some stuff (a part of the problem is solved with cg and a part of the problem is solved with bicgstab). Results looks fine and the code solves the problem quite fast.
When comparing with a code for cpu which solves the same problem with trilinos using cg and bicgstab, I notice that the viennacl code use less iterations than the trilinos code. Therefore I look through the trilinos manual and the viennacl cg and bicgstab code to verify that they use the same stop criteria (from what I can tell, they use the same (trilinos have different stop conditions but the condition ||r||_2/||r^(0)||_2 < tolerance is used))
When solving the problem, I have a custom_cg tag and a custom_bicgstab which are set to maxIterations = 1600 and maxResidual = 1e-12. What I find however is that after solving with cg, custom_cg.error() gives error of magnitude 10^-8. Solving with bicgstab, custom_bicgstab.error() gives error of magnitude 10^-12.
Is there an error in the viennacl code that makes the cg solver use tolerance 10^-8 instead of tolerance 1e-12? I notice that when the tolerance is set to 10^-6, the custom_cg.error() have magnitude 1e-5. Is tolerance 10^-8 the limit for the cg solver?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
the return values from the .error() functions are updated residuals from within the CG/BiCGStab iterations and contain an accumulation of round-off errors. An alternative would be to recompute the full residual and continue the iteration if it is above the tolerance, but in many cases there is no need for this and hence we decided not to do this. This is the reason why you get different iteration counts. We may provide an option in the future to monitor the 'true' residual if that is of interest - just let us know.
Best regards,
Karli
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
after looking in the trilinos manual and the cpu code using trilinos I found that the initial guess set for the cg and bicgstab solver was non-zero (in viennacl initial guess is set to zero). Using initial guess zero in trilinos, I get the same number of iterations with trilinos and viennacl.
Kind regards
Geir
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello, I use viennacl cg and bicgstab to solve some stuff (a part of the problem is solved with cg and a part of the problem is solved with bicgstab). Results looks fine and the code solves the problem quite fast.
When comparing with a code for cpu which solves the same problem with trilinos using cg and bicgstab, I notice that the viennacl code use less iterations than the trilinos code. Therefore I look through the trilinos manual and the viennacl cg and bicgstab code to verify that they use the same stop criteria (from what I can tell, they use the same (trilinos have different stop conditions but the condition ||r||_2/||r^(0)||_2 < tolerance is used))
When solving the problem, I have a custom_cg tag and a custom_bicgstab which are set to maxIterations = 1600 and maxResidual = 1e-12. What I find however is that after solving with cg, custom_cg.error() gives error of magnitude 10^-8. Solving with bicgstab, custom_bicgstab.error() gives error of magnitude 10^-12.
Is there an error in the viennacl code that makes the cg solver use tolerance 10^-8 instead of tolerance 1e-12? I notice that when the tolerance is set to 10^-6, the custom_cg.error() have magnitude 1e-5. Is tolerance 10^-8 the limit for the cg solver?
Hi,
the return values from the .error() functions are updated residuals from within the CG/BiCGStab iterations and contain an accumulation of round-off errors. An alternative would be to recompute the full residual and continue the iteration if it is above the tolerance, but in many cases there is no need for this and hence we decided not to do this. This is the reason why you get different iteration counts. We may provide an option in the future to monitor the 'true' residual if that is of interest - just let us know.
Best regards,
Karli
Hi,
after looking in the trilinos manual and the cpu code using trilinos I found that the initial guess set for the cg and bicgstab solver was non-zero (in viennacl initial guess is set to zero). Using initial guess zero in trilinos, I get the same number of iterations with trilinos and viennacl.
Kind regards
Geir
Ah, I see. Thanks for the information, Geir :-)