Menu

Number of iterations are the same for different sparse iterative solvers.

Kayla Li
2015-11-02
2015-11-02
  • Kayla Li

    Kayla Li - 2015-11-02

    Hi, I am using the iterative.cu under ViennaCL-1.7.0/examples/tutorial to learn how to use the sparse iterative solver and of course the preconditioners combination. I would like to show my appreciation first for such an easy to compile and use package, and of course the very clear documents.

    I have one question about the number of iterations across different sparse iterative solvers. Based on one example in the manual, I set a customized threshold and max iterations as

      viennacl::linalg::cg_tag custom_cg(1e-3, 12000);
    

    I use custom_cg.iters() to get access to the number of iterations the solvers need and then printed out as shown follows.

    vcl_result = viennacl::linalg::solve(vcl_compressed_matrix, vcl_rhs, custom_cg);
    std::cout << "NoP " << custom_cg.iters() << "\t" << custom_cg.error() << std::endl;
    vcl_result = viennacl::linalg::solve(vcl_compressed_matrix, vcl_rhs, custom_cg, vcl_ilut); 
    std::cout << "ILU " << custom_cg.iters() << "\t" << custom_cg.error() << std::endl;
    vcl_result = viennacl::linalg::solve(vcl_compressed_matrix, vcl_rhs, custom_cg, vcl_jacobi);
    std::cout << "Jac " << custom_cg.iters() << "\t" << custom_cg.error() << std::endl;
    

    I did the same code modification for the three different iterative solvers, CG, BiCGSTAB, and GMRES with no preconditioner, ILUT, and Jacobi preconditioners. The results shown shat, the number of iterations are the same no matter what kind of iterative solver I am using as follows. The preconditioners do have a impact though.

    ----- CG Method -----
    NoP 339 0.000931981     
    ILU 60  0.000887377     
    Jac 339 0.000924332     
    ----- BiCGStab Method -----
    NoP 339 0.000931981    
    ILU 60  0.000887377  
    Jac 339 0.000924332  
    ----- GMRES Method -----
    NoP 339 0.000931981     
    ILU 60  0.000887377    
    Jac 339 0.000924332   
    

    However my point is that I am expecting that CG, BiCGSTAB and GMRES should give me different number of iterations. Maybe BiCGSTAB could have similar number of iterations as CG for SPD matrices. I don't expect GMRES can get exact the same number of iterations as CG or CG variations.
    Another point I should mention is that, this observations hold for not only the example system mat65k.mtx, but also for my all other 13 test systems ranging from 200 by 200 to 25000 by 25000. I haven't confirmed that they are positive definite or not.
    I do appreciate any comments or suggestion.

     
  • Karl Rupp

    Karl Rupp - 2015-11-02

    Hi Kayla,

    I agree that you should not see the same iteration counts and residuals for the same solver. Could you please verify that you are using the correct solver tag types? They should be

        viennacl::linalg::cg_tag
        viennacl::linalg::bicgstab_tag
        viennacl::linalg::gmres_tag
    

    Maybe a copy&paste error?

    In terms of preconditioners, you are observing the expected behavior. You matrix is likely to have the same diagonal entries (maybe all 1), hence you see the same iteration counts with 'NoP' and 'Jac'.

    Best regards,
    Karli

     
    • Kayla Li

      Kayla Li - 2015-11-02

      Karli

      Thank you so much for the quick response! I checked my code. Yes you are right. I forget to use different tags for different iterative solvers. I have updated them and now everything makes sense, like 'NoP' uses most iterations; ILUT keeps a stable performance, Jacobi works very well for systems very diagonally dominant.

      Thanks again!
      Kayla

       

Log in to post a comment.