SV: Slow MatSetValues

Jed Brown jed at
Fri May 30 07:31:09 CDT 2008

On Fri 2008-05-30 13:44, Lars Rindorf wrote:
> Hi everybody
> Thanks for all the suggestions and help. The problem is of a bit different nature. I use only direct solvers, so I give the options "-ksp_type preonly -pc_type lu" to make a standard LU factorization. This works fine without any problems. If I additionally set "-mat_type umfpack" to use umfpack then MatSetValues is very, very slow (about 50 times slower). If, as a test, I call MatAssemblyBegin and MatAssemblyEnd before MatSetValues, and only use the lu (no umfpack) then the performance is very similarly slow.

I've seen this problem when preallocation information is lost by changing the
matrix type.  Try putting MatSeqAIJSetPreallocation() and/or (it doesn't hurt to
do both) MatMPIAIJSetPreallocation() after MatSetFromOptions().  This will
preallocate for any matrix type that inherits from these two types (which I
think is anything you might use).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <>

More information about the petsc-users mailing list