SV: Slow MatSetValues

Barry Smith bsmith at
Fri May 30 22:09:17 CDT 2008

     This is a serious flaw in our user interface, I'm fixing it now  
and our next release will vastly simplify the
handling of external direct solvers and make this problem impossible.


On May 30, 2008, at 7:31 AM, Jed Brown wrote:

> 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).
> Jed

More information about the petsc-users mailing list