<div dir="ltr"><div dir="ltr">On Thu, Aug 13, 2020 at 1:54 PM Sajid Ali <<a href="mailto:sajidsyed2021@u.northwestern.edu">sajidsyed2021@u.northwestern.edu</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div>Hi PETSc-developers, <br><br></div>When assembling a matrix, what would the relative performance of the following be :<br>[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)<br></div>[b] loop over the rows once, preallocate and set the values for each row.<br clear="all"><div><div><div><br>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). <br></div></div></div></div></blockquote><div><br></div><div>I am not sure what you mean by [b]. I do not believe the obvious interpretation is possible in PETSc. We allocate the</div><div>matrix once, not row-by-row, so you could not preallocate just a few rows.</div><div><br></div><div>However, why not have a flag so that on the first pass you do not compute entries, just the indices?</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div></div><div>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].<br><br></div><div>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).<br></div><div><br><div><img src="cid:ii_kdt3858t0" alt="image.png" width="453" height="184"><br><br></div></div><div>Thank You, <br></div><div><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div style="font-size:12.8px">Sajid Ali | PhD Candidate<br></div><div style="font-size:12.8px">Applied Physics<br></div><div style="font-size:12.8px">Northwestern University</div><div style="font-size:12.8px"><a href="http://s-sajid-ali.github.io" target="_blank">s-sajid-ali.github.io</a></div></div></div></div></div></div></div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>