<div><div><div class="gmail_quote"><div>On Fri, 7 Jul 2017 at 11:31, Florian Lindner <<a href="mailto:mailinglists@xgm.de" target="_blank">mailinglists@xgm.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I'm having some struggle understanding the preallocation for MPIAIJ matrices, especially when a value is in off-diagonal<br>
vs. diagonal block.<br>
<br>
The small example program is at <a href="https://pastebin.com/67dXnGm3" rel="noreferrer" target="_blank">https://pastebin.com/67dXnGm3</a><br>
<br>
In general it should be parallel, but right now I just run it in serial.</blockquote><div><br></div></div></div></div><div><div><div class="gmail_quote"><div>When you run this code in serial, the mat type will be MATSEQAIJ. Hence, the call to MatMPIAIJSetPreallocation() will have no effect because the mat type does not match MPIAIJ. As a result, your code doesn't perform any preallocation for SEQAIJ matrices.</div><div><br></div><div>In addition to calling MatMPIAIJSetPreallocation(), add a call to MatSEQAIJSetPreallocation.</div><div><br></div><div>Thanks,</div><div> Dave</div></div></div></div><div><div><div class="gmail_quote"><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
According to my understanding of<br>
<br>
<a href="http://www.mcs.anl.gov/petsc/petsc-3.7/docs/manualpages/Mat/MatMPIAIJSetPreallocation.html" rel="noreferrer" target="_blank">http://www.mcs.anl.gov/petsc/petsc-3.7/docs/manualpages/Mat/MatMPIAIJSetPreallocation.html</a><br>
<br>
a entry is in the diagonal submatrix, if its row is in the OwnershipRange and its column is in OwnershipRangeColumn.<br>
That also means that in a serial run, there is only a diagonal submatrix.<br>
<br>
However, having MAT_NEW_NONZERO_ALLOCATION_ERR set, I get an error when<br>
<br>
Inserting 6 elements in row 2, though I have exactly<br>
<br>
2 o_nnz = 0, d_nnz = 6 (means 6 elements allocated in the diagonal submatrix of row 2)<br>
<br>
Error is:<br>
<br>
[0]PETSC ERROR: Argument out of range<br>
[0]PETSC ERROR: New nonzero at (2,5) caused a malloc<br>
Use MatSetOption(A, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE) to turn off this check<br>
<br>
<br>
What is wrong with my understanding?<br>
<br>
Thanks,<br>
Florian<br>
</blockquote></div></div></div>