<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7652.24">
<TITLE>RE: Slow MatSetValues</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<BR>
<P><FONT SIZE=2>Hi,<BR>
<BR>
I just want to share my experience with FE assembly.<BR>
I think the problem of preallocation in finite element matrices is that you don't know how many elements are connected to a given node, there can be 5, 20 elements or more. You can build a structure with the number of nodes connected to a node and then preallocate the matrix but this is not very efficient.<BR>
<BR>
I know UMFPACK has a method of forming triplets with the matrix information and then it has routines to add duplicate entries and compress the data in a compressed matrix format. Although I have never used UMFPACK with PETSC. I also don't know if there are similiar functions in PETSC optimized for FE matrix assembly.<BR>
<BR>
Regards,<BR>
<BR>
Billy.<BR>
<BR>
<BR>
<BR>
-----Mensagem original-----<BR>
De: owner-petsc-users@mcs.anl.gov em nome de Barry Smith<BR>
Enviada: qua 28-05-2008 16:03<BR>
Para: petsc-users@mcs.anl.gov<BR>
Assunto: Re: Slow MatSetValues<BR>
<BR>
<BR>
<A HREF="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/manual.pdf#sec_matsparse</A><BR>
<A HREF="http://www-unix.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Mat/MatCreateMPIAIJ.html">http://www-unix.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Mat/MatCreateMPIAIJ.html</A><BR>
<BR>
Also, slightl less important, collapse the 4 MatSetValues() below <BR>
into a single call that does the little two by two block<BR>
<BR>
Barry<BR>
<BR>
On May 28, 2008, at 9:07 AM, Lars Rindorf wrote:<BR>
<BR>
> Hi everybody<BR>
><BR>
> I have a problem with MatSetValues, since the building of my matrix <BR>
> takes much longer (35 s) than its solution (0.2 s). When the number <BR>
> of degrees of freedom is increased, then the problem worsens. The <BR>
> rate of which the elements of the (sparse) matrix is set also seems <BR>
> to decrease with the number of elements already set. That is, it <BR>
> becomes slower near the end.<BR>
><BR>
> The structure of my program is something like:<BR>
><BR>
> for element in finite elements<BR>
> for dof in element<BR>
> for equations in FEM formulation<BR>
> ierr = MatSetValues(M->M,1,&i,1,&j,&tmp,ADD_Values);<BR>
> ierr = MatSetValues(M->M,1,&k,1,&l,&tmp,ADD_Values);<BR>
> ierr = MatSetValues(M->M,1,&i,1,&l,&tmp,ADD_Values);<BR>
> ierr = MatSetValues(M->M,1,&k,1,&j,&tmp,ADD_Values);<BR>
><BR>
><BR>
> where i,j,k,l are appropriate integers and tmp is a double value to <BR>
> be added.<BR>
><BR>
> The code has fine worked with previous version of petsc (not <BR>
> compiled by me). The version of petsc that I use is slightly newer <BR>
> (I think), 2.3.3 vs ~2.3.<BR>
><BR>
> Is it something of an dynamic allocation problem? I have tried using <BR>
> MatSetValuesBlock, but this is only slightly faster. If I monitor <BR>
> the program's CPU and memory consumption then the CPU is 100 % used <BR>
> and the memory consumption is only 20-30 mb.<BR>
><BR>
> My computer is a red hat linux with a xeon quad core processor. I <BR>
> use Intel's MKL blas and lapack.<BR>
><BR>
> What should I do to speed up the petsc?<BR>
><BR>
> Kind regards<BR>
> Lars<BR>
> _____________________________<BR>
><BR>
><BR>
> Lars Rindorf<BR>
> M.Sc., Ph.D.<BR>
><BR>
> <A HREF="http://www.dti.dk">http://www.dti.dk</A><BR>
><BR>
> Danish Technological Institute<BR>
> Gregersensvej<BR>
><BR>
> 2630 Taastrup<BR>
><BR>
> Denmark<BR>
> Phone +45 72 20 20 00<BR>
><BR>
><BR>
<BR>
<BR>
</FONT>
</P>
</BODY>
</HTML>