Slow MatSetValues

Barry Smith bsmith at mcs.anl.gov
Wed May 28 10:03:57 CDT 2008


http://www-unix.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manual.pdf#sec_matsparse
http://www-unix.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Mat/MatCreateMPIAIJ.html

Also, slightl less important,  collapse the 4 MatSetValues() below  
into a single call that does the little two by two block

    Barry

On May 28, 2008, at 9:07 AM, Lars Rindorf wrote:

> Hi everybody
>
> I have a problem with MatSetValues, since the building of my matrix  
> takes much longer (35 s) than its solution (0.2 s). When the number  
> of degrees of freedom is increased, then the problem worsens. The  
> rate of which the elements of the (sparse) matrix is set also seems  
> to decrease with the number of elements already set. That is, it  
> becomes slower near the end.
>
> The structure of my program is something like:
>
> for element in finite elements
>     for dof in element
>         for equations in FEM formulation
>             ierr = MatSetValues(M->M,1,&i,1,&j,&tmp,ADD_Values);
>             ierr = MatSetValues(M->M,1,&k,1,&l,&tmp,ADD_Values);
>             ierr = MatSetValues(M->M,1,&i,1,&l,&tmp,ADD_Values);
>             ierr = MatSetValues(M->M,1,&k,1,&j,&tmp,ADD_Values);
>
>
> where i,j,k,l are appropriate integers and tmp is a double value to  
> be added.
>
> The code has fine worked with previous version of petsc (not  
> compiled by me). The version of petsc that I use is slightly newer  
> (I think), 2.3.3 vs ~2.3.
>
> Is it something of an dynamic allocation problem? I have tried using  
> MatSetValuesBlock, but this is only slightly faster. If I monitor  
> the program's CPU and memory consumption then the CPU is 100 % used  
> and the memory consumption is only 20-30 mb.
>
> My computer is a red hat linux with a xeon quad core processor. I  
> use Intel's MKL blas and lapack.
>
> What should I do to speed up the petsc?
>
> Kind regards
> Lars
> _____________________________
>
>
> Lars Rindorf
> M.Sc., Ph.D.
>
> http://www.dti.dk
>
> Danish Technological Institute
> Gregersensvej
>
> 2630 Taastrup
>
> Denmark
> Phone +45 72 20 20 00
>
>




More information about the petsc-users mailing list