Slow MatSetValues

Lars Rindorf Lars.Rindorf at teknologisk.dk
Wed May 28 09:07:05 CDT 2008


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 <http://www.teknologisk.dk/> 

Danish Technological Institute
Gregersensvej

2630 Taastrup

Denmark
Phone +45 72 20 20 00

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20080528/68524b85/attachment.htm>


More information about the petsc-users mailing list