Menu

Using custom preconditioners in ViennaCL

J. Dumas
2016-02-05
2016-02-06
  • J. Dumas

    J. Dumas - 2016-02-05

    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?

     
  • Karl Rupp

    Karl Rupp - 2016-02-05

    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

     
  • J. Dumas

    J. Dumas - 2016-02-06

    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.

     

Log in to post a comment.