[petsc-users] Question on matrix assembly

Sajid Ali sajidsyed2021 at u.northwestern.edu
Thu Aug 13 12:52:28 CDT 2020


Hi PETSc-developers,

When assembling a matrix, what would the relative performance of the
following be :
[a] loop over the rows owned by the mpi-rank twice, first to compute the
values and set preallocation for this mpi-rank and then again to fill in
the values (as recommended in the manual)
[b] loop over the rows once, preallocate and set the values for each row.

I'm refactoring an application that follows approach [a] but computes the
elements of the matrix twice (once to fill in the nnz arrays and once to
set the values) and I want to know if computing, preallocating and setting
the elements by row instead would be better (so as to not compute the
matrix entries twice which involves calls to boost-geometry).

I'm attaching a plot that shows (Left) the number of non-zeros per row for
a typical matrix used in this application and (Right) the histogram of the
number of non zeros per row, should this be useful. Note that this matrix
has global dimensions [12800 rows, 65586 columns].

PS : This matrix is used for a TAO optimization problem and generating the
matrix takes between ~10 and ~25% of the time (longer on a smaller number
of nodes).

[image: image.png]

Thank You,
Sajid Ali | PhD Candidate
Applied Physics
Northwestern University
s-sajid-ali.github.io
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200813/c0613e9c/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 247517 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200813/c0613e9c/attachment-0001.png>


More information about the petsc-users mailing list