Menu

issues using preconditioners

suchismit
2014-09-15
2014-09-15
  • suchismit

    suchismit - 2014-09-15

    hi folks,
    i am currently having issues running the ViennaCL preconditioners.
    the standard cg solve goes through fine without the preconditioner.

    typedef double T;
    typedef viennacl::compressed_matrix<T> VCMat;
    ...

    VCMat JM;
    viennacl::linalg::jacobi_precond< VCMat > jacobi_p(JM, viennacl::linalg::jacobi_tag());
    viennacl::linalg::cg_tag cg(CG_TOLERANCE, CG_MAX_ITERATIONS);

    VCMat VZ(N, N); VVec VYN(N); VVec VX(N);
    viennacl::copy(Z, VZ); viennacl::copy(YN, VYN);

    VX = viennacl::linalg::solve(VZ, VYN, cg, jacobi_p);
    viennacl::copy(VX, X);

    the above snippet throws this error below :-
    Z calculation took 8 seconds
    terminate called after throwing an instance of 'viennacl::memory_exception'
    what(): ViennaCL: Internal memory error: not initialised!
    Abort (core dumped)


    typedef viennacl::linalg::ilut_precond< VCMat > VC_ILUT_P;
    ...

    VCMat ILUTM;
    viennacl::linalg::ilut_tag ilut_config(10, 1e-5);
    VC_ILUT_P ilut_p(ILUTM, ilut_config);
    viennacl::linalg::cg_tag cg(CG_TOLERANCE, CG_MAX_ITERATIONS);

    VCMat VZ(N, N); VVec VYN(N); VVec VX(N);
    viennacl::copy(Z, VZ); viennacl::copy(YN, VYN);

    VX = viennacl::linalg::solve(VZ, VYN, cg, ilut_p);
    viennacl::copy(VX, X);

    the above snippet throws this error below :-
    Z calculation took 8 seconds
    cpred: /fry1/data/users/suchismi/ViennaCL-1.5.1/viennacl/compressed_matrix.hpp:572: void viennacl::compressed_matrix<SCALARTYPE, ALIGNMENT="">::set(const void, const void, const SCALARTYPE*, viennacl::vcl_size_t, viennacl::vcl_size_t, viennacl::vcl_size_t) [with SCALARTYPE = double, unsigned int ALIGNMENT = 1u]: Assertion `(rows > 0) && bool("Error in compressed_matrix::set(): Number of rows must be larger than zero!")' failed.
    Abort (core dumped)


    when i try using the row scaling preconditioner, i get the same error as jacobi preconditioner case above. i was inclined to use the ilut preconditioner since [1] suggests ilut + bicgstab combination is the best. i do not know if it is indeed true. any suggestions/comments would be welcome regarding which preconditioner is the best in which scenario (my belief is that there is no best preconditioner for every situation).

    both the above code snippets are from tutorials and hence i thought they would be good to go. i am clueless regarding what exactly is going wrong. the standard cg solve goes through fine without any issues which confounds me even more.

    warm regards,
    suchismit

    [1] https://sourceforge.net/p/viennacl/discussion/1143678/thread/8e2906c2/

     
  • Karl Rupp

    Karl Rupp - 2014-09-15

    Hi Suchismit,

    you need to create the preconditioner from the initialized matrix, i.e. after the calls to viennacl::copy(). In other words, move the instantiation of jacobi_p and ilut_p to the line right before the respective solve() calls and it should work.

    Best regards,
    Karli

     

Log in to post a comment.