Menu

tag.iters() and tag.error() show zero.

p ding
2017-08-11
2017-08-11
  • p ding

    p ding - 2017-08-11

    Dear friends:
    I do not know why tag.iters() and tag.error() both give "0". that means it performed 0 iteration. But the results is changing.
    I am solve the diffusion problem with 250,000 3D unstructured mesh with GTX 650 card. the speedup is only 2 compared with one cpu core. I think the speed is too slow. Need i to improve the card to obtain futher improvement.

    Could you please provide me some suggestions.
    Regards

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    void Temperature::SolveGPU()
    {
    
    Mesh* RefMesh=VarBox->aMesh;
    int nRow=RefMesh->CellsNumber;
    
    std::vector< std::map< unsigned int, double> > cpumatrix(nRow);
    std::vector<double> temp(nRow);
    
     for(int i=0;i<nRow;i++){
          int row1=RefMesh->CsrRow[i];
          int row2=RefMesh->CsrRow[i+1];
          for (int jj=row1; jj<row2; jj++)
            cpumatrix[i][RefMesh->CsrColumn[jj]]=A[jj];     
    }
    
    viennacl::compressed_matrix<double> vclmatrix(nRow,nRow);
    viennacl::vector<double> x(nRow);
    viennacl::vector<double> b(nRow);
    
    fast_copy(Source.begin(), Source.end(), b.begin());
    fast_copy(VarBox->T->Field.begin(), VarBox->T->Field.end(), x.begin());
    
    copy(cpumatrix, vclmatrix);
    
    viennacl::linalg::ilu0_precond< viennacl::compressed_matrix<double> > vcl_ilu0(vclmatrix, viennacl::linalg::ilu0_tag());
    viennacl::linalg::jacobi_precond< viennacl::compressed_matrix<double> > vcl_jacobi(vclmatrix, viennacl::linalg::jacobi_tag()); 
    viennacl::linalg::chow_patel_ilu_precond< viennacl::compressed_matrix<double> >ilu(vclmatrix,viennacl::linalg::chow_patel_tag());
    
    viennacl::linalg::bicgstab_tag  tag(1e-10, 50);
    viennacl::linalg::bicgstab_solver<viennacl::vector<double>> Solver(tag);
    Solver.set_initial_guess(x);
    
         x = Solver(vclmatrix, b);
        std::cout <<std::endl<< "No. of iters: " << tag.iters() << std::endl;
        std::cout << std::endl<<"Est. error: " << tag.error() << std::endl;
    
    fast_copy(x.begin(), x.end(), VarBox->T->Field.begin());
    
    }
    
     

    Last edit: p ding 2017-08-11
  • Karl Rupp

    Karl Rupp - 2017-08-11

    Hi Ding,

    pass the solver to viennacl::linalg::solve(), i.e.

     x = viennacl::linalg::solve(vclmatrix, b, Solver);
    

    See here for an example:
    https://github.com/viennacl/viennacl-dev/blob/master/examples/tutorial/iterative.cpp#L198

    I'm surprised that your code line x = Solver(vclmatrix,b) even compiled...

    Best regards,
    Karli

     
  • p ding

    p ding - 2017-08-11

    Dear Karli:
    It compiled and worked . I follow the "CG" section in onlin tutorial .

     

Log in to post a comment.