I was wondering if it was possible to use custom preconditioners when solving a sparse linear system on the GPU with ViennaCL (using for e.g. the OpenCL backend). In the documentation I saw examples of a custom matrix-free operator, a custom monitor for iterative solvers, but it doesn't seem possible to write your own preconditoner yet.
Any advice?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
yes, you can pass your own preconditioner object. The only interface requirement is that it provides a non-static, const member function .apply() which takes the input vector and applies the preconditioner to it.
Have a look at viennacl/linalg/jacobi_precond.hpp for a possible implementation (lines 104-130 for ViennaCL-types). The init() function could also be merged into the CTOR and is not necessary. Please let me know if you encounter problems.
Best regards,
Karli
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for the swift answer. I didn't realize you could pass your own precond object instead of a class (just like you pass a matrix class instead of an actual matrix for matrix-free computation). This is actually pretty nice, I think I should be able to get around with it =)
Best,
J.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I was wondering if it was possible to use custom preconditioners when solving a sparse linear system on the GPU with ViennaCL (using for e.g. the OpenCL backend). In the documentation I saw examples of a custom matrix-free operator, a custom monitor for iterative solvers, but it doesn't seem possible to write your own preconditoner yet.
Any advice?
Hi Jean,
yes, you can pass your own preconditioner object. The only interface requirement is that it provides a non-static, const member function .apply() which takes the input vector and applies the preconditioner to it.
Have a look at viennacl/linalg/jacobi_precond.hpp for a possible implementation (lines 104-130 for ViennaCL-types). The init() function could also be merged into the CTOR and is not necessary. Please let me know if you encounter problems.
Best regards,
Karli
Hi Karl,
Thank you for the swift answer. I didn't realize you could pass your own precond object instead of a class (just like you pass a matrix class instead of an actual matrix for matrix-free computation). This is actually pretty nice, I think I should be able to get around with it =)
Best,
J.