[petsc-users] Reducing cost of MatSetValues

Jed Brown jed at 59A2.org
Wed Jun 1 15:11:43 CDT 2011


On Wed, Jun 1, 2011 at 21:53, John Fettig <john.fettig at gmail.com> wrote:

> What are the recommendations for reducing the cost of inserting values
> into an AIJ matrix?  In my application (transient finite element
> solution of flow and heat, linear elements), this is accounting for up
> to 20% of overall runtime.  Is this expected?
>

2D or 3D? What kind of elements?


>
> I have double checked that the matrices are preallocated correctly,
> and I have set MAT_NEW_NONZERO_ALLOCATION_ERR and it runs without
> error.
>
> The matrices periodically change size/nonzero pattern, but until then
> the values are zeroed out and MatSetOption( mat,
> MAT_KEEP_NONZERO_PATTERN, PETSC_TRUE); is called.
>
> The call to MatSetValues happens on a per-element basis on the local
> element matrix, so one call per element.  I re-activated the
> MAT_SetValues event and have included a -log_summary from a short run.
>

The overhead of the profiling can be nontrivial for small elements. How does
the run-time change if you deactivate that event?

How much of the overall time is spent in matrix assembly (your code plus
MatSetValues)?

It looks like the linear solve is around 18 iterations. For first order
elements, that is probably too many for matrix-free with a lagged Jacobian
to pay off. The trade-off is much more favorable for higher order elements,
or if the preconditioner is better.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110601/2b0a4995/attachment.htm>


More information about the petsc-users mailing list