petsc and matlab

Alejandro Garzon gtg100n at mail.gatech.edu
Tue Aug 21 07:19:05 CDT 2007


Yes, the "A" matrix is the same.
--
Alejandro


Quoting Barry Smith <bsmith at mcs.anl.gov>:

>
>   Is the matrix "A" the same for all groups (and the only thing
> different for each group is b)?
>
>    Barry
>
>
> On Mon, 20 Aug 2007, Alejandro Garzon wrote:
>
> > Hi, I wrote a code for solving a time dependent pde. In each time step
> > I have to solve a linear system. I first wrote a prototype in matlab
> > and then a C version using Petsc. To my surprise for some input
> > parameters the matlab version runs faster than the Petsc code (on the
> > same single processor). I did
> > the performance comparison by timing 20 groups of 40 iterations. The
> > times for Petsc and matlab are shown bellow
> >
> > group        Petsc        matlab
> >
> >     1       0.244981     1.110283
> >     2       0.244995     1.112919
> >     3       0.241305     1.113608
> >     4       0.244542     1.114669
> >     5       7.534417     1.112450
> >     6       0.242212     1.115867
> >     7       0.246327     1.111135
> >     8       0.241105     1.113442
> >     9       0.244468     1.111215
> >    10       0.241113     1.111334
> >    11       0.244541     1.112467
> >    12       0.241400     1.113525
> >    13       0.245020     1.114077
> >    14       0.241303     1.113409
> >    15       0.244380     1.116238
> >    16       0.241372     1.109931
> >    17       0.244108     1.100667
> >    18       0.240419     1.096030
> >    19       0.244337     1.096293
> >    20      17.139999     1.097120
> >            ---------     --------
> > total      29.0523       22.1967
> > time
> >
> > As can be seen in the table, although in most of the groups the time
> > spent by the Petsc code is lower than that of matlab
> > (0.24 compared to 1.1) there are two groups (5 and 20) in the Petsc column
> that
> > take a long time and make the total for the Petsc code bigger than
> > that for matlab.
> >
> > In Petsc and matlab the method used is bicg and the relative residual
> > is the same: 1e-8. The preconditioners are different, though. In petsc
> > I used the default preconditioner and in matlab I used incomplete LU
> > decomposition  with drop tolerance. The code that solves the linear
> > system in matlab is
> >
> > [L,U] = luinc(A,droptol); <---- this is done only once before the
> >                                  first iteration, droptol = 1e-12
> >
> > x = bicg(A,b,relres,maxsteps,L,U);
> >
> > I know incomplete LU decomposition as a preconditioner is available in
> > Petsc but in order to use it one must provide two arguments in
> > addition to the drop tolerance and I didn't know what values to give
> > to them.
> >
> > My question is this: what options should be chosen so that the
> > preconditioner and method use by Petsc are the same as those shown in
> > the two lines of matlab code above? (could you contact the authors of the
> > matlab functions?) A comparison of the performace of Petsc and matlab
> > makes sense only if they are using the exact same methods.
> >
> >
> > Thanks.
> >
> > --
> > Alejandro
> >
> >
> >
> >
> >
>
>




More information about the petsc-users mailing list