[petsc-users] zero pattern of result of matmatmult

Barry Smith bsmith at mcs.anl.gov
Tue Sep 17 10:04:40 CDT 2013


On Sep 17, 2013, at 8:57 AM, Frederik Treue <frtr at fysik.dtu.dk> wrote:

> On Tue, 2013-09-17 at 08:15 -0500, Barry Smith wrote:
>> When the linear system is fairly easy it is possible for the construction of the matrix to take a significant portion of the total time. Run with -log_summary and send the output, from this we may be able to make suggestions as to what further improvements can be made.
> Attached. 
>> 
>>    Is any part of the matrix constant? If so you can use MatStoreValues() and MatRetrieveValues() so that part does not have to be recomputed each time.
> Not in terms of entries in the matrix. Mathematically, part of the
> operator is constant, but all entries has changing parts added to them.

    If you matrix is   A + B(x)   where A is always the same but requires some non-trivial computation that currently gets repeated each time, you can do the following ONCE

     call MatSetValuesStencil() to put in the parts of A.   Call MatAssemblyBegin/End(). Call MatStoreValues(). 

   Then every time you need the matrix computed don't call MatZeroEntries() instead 

    call MatRetreiveValues(), MatSetValuesStencil(  ADD_VALUES) to put in the parts of B, MatAssemblyBegin/End().  

   If the "constant" part A requires almost no computation then you will not gain by this approach.

   Barry

> 
>> 
>>    Are you calling MatSetValuesStencil() for each single entry or once per row or block row? Row or block row will be faster than for each entry.
> once per entry - this I should definitely improve. What's the logic
> behind row or block rows being faster? The fewer calls to
> MatSetValuesStencil, the better?
> 
>> 
>>    Since you are using MatSetValuesStencil() I assume you are using a DA?
> 
> I am, with one DOF per point. Are there better alternatives?
> 
> PS. FYI: My stencil is essentially a standard 2D, 9-point box stencil,
> but the values in all rows are different (due, among other things, to
> the geometric tensor).
> 
> Thanks for the help...
> 
> /Frederik
> 
> 
> <log_result.txt>



More information about the petsc-users mailing list