<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif;font-size:small;color:#073763">Thank you Dave!</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small;color:#073763"><br></div><div class="gmail_default" style="font-family:georgia,serif;font-size:small;color:#073763">Do you have a rough idea of how long a matrix like that should take to assemble?</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small;color:#073763">Not hours. Right? </div><div class="gmail_default" style="font-family:georgia,serif;font-size:small;color:#073763"><br></div><div class="gmail_default" style="font-family:georgia,serif;font-size:small;color:#073763">Regards,</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small;color:#073763">Jose</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div>--</div><div><br></div><div><font face="georgia, serif" size="4">José Abell </font></div><div><font face="georgia, serif"><i>PhD Candidate</i></font></div><div><font face="georgia, serif">Computational Geomechanics Group</font></div><div><font face="georgia, serif"><span style="font-size:12.7272720336914px">Dept. of Civil and Environmental Engineering</span><br></font></div><div><font face="georgia, serif">UC Davis</font></div><div><font face="georgia, serif"><a href="http://www.joseabell.com" target="_blank">www.joseabell.com</a></font></div><div><br></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Thu, Dec 17, 2015 at 12:58 AM, Dave May <span dir="ltr"><<a href="mailto:dave.mayhem23@gmail.com" target="_blank">dave.mayhem23@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On 17 December 2015 at 08:06, Jose A. Abell M. <span dir="ltr"><<a href="mailto:jaabell@ucdavis.edu" target="_blank">jaabell@ucdavis.edu</a>></span> wrote:<br><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 style="font-family:georgia,serif;font-size:small;color:rgb(7,55,99)">Hello dear PETSc users,</div><div style="font-family:georgia,serif;font-size:small;color:rgb(7,55,99)"><br></div><div style="font-family:georgia,serif;font-size:small;color:rgb(7,55,99)">This is a problem that pops up often, from what I see, in the mailing list. My program takes a long time assembling the matrix. </div><div style="font-family:georgia,serif;font-size:small;color:rgb(7,55,99)"><br></div><div style="font-family:georgia,serif;font-size:small;color:rgb(7,55,99)">What I know:</div><div style="font-family:georgia,serif;font-size:small;color:rgb(7,55,99)"><br></div><div style="font-family:georgia,serif;font-size:small;color:rgb(7,55,99)"><ul><li>Matrix Size is (MatMPIAIJ) 2670402<br></li><li>Number of processes running PETSc: 95<br></li><li>Not going to virtual memory (no swapping, used mem well withing each node's capacity)<br></li><li>System is partitioned with ParMETIS for load balancing<br></li><li>I see memory moving around in each node (total used memory changes a bit, grows and then frees)<br></li><li>Matrix is filled in blocks of size 81x81 (FEM code, so this ends up being a sparse matrix)</li><li>I don't do flushes at all. Only MAT_FINAL_ASSEMBLY when all the MatSetValues are done. <br></li></ul></div><div style="font-family:georgia,serif;font-size:small;color:rgb(7,55,99)">Should I do <span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">MAT_FLUSH_ASSEMBLY</span> even though I have enough memory to store the buffers? If so, how often? Every 100 blocks?</div><div style="font-family:georgia,serif;font-size:small;color:rgb(7,55,99)"><br></div><div style="font-family:georgia,serif;font-size:small;color:rgb(7,55,99)">What else could it be? </div><div style="font-family:georgia,serif;font-size:small;color:rgb(7,55,99)"><br></div><div style="font-family:georgia,serif;font-size:small;color:rgb(7,55,99)">Its taking several hours to asseble this matrix. I re-use the sparsity pattern, so subsequent assemblies are fast. Does this mean that my preallocation is wrong?</div></div></blockquote><div><br></div></span><div>The preallocation could be wrong. That is the usual cause of very slow matrix assembly. To confirm this hypothesis, run your code with the command line option -info. You will get an enormous amount of information in stdout. You might consider using -info with a smallish problem size / core count.<br><br></div><div>Inspect the output generated by -info and look for lines like this:<br><br>[1] MatAssemblyEnd_SeqAIJ(): Number of mallocs during MatSetValues() is 0<br><br></div><div>If the number of mallocs during MatSetValues() is not zero, then your preallocation is not exactly correct. A small number of mallocs, say less than 10, might be accepted (performance wise). However if the number of mallocs is > 100, then assembly time will be terribly slow.<br><br></div><div>Thanks,<br></div><div>  Dave <br></div><span class=""><div><br></div><div><br> </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 style="font-family:georgia,serif;font-size:small;color:rgb(7,55,99)"><br></div><div style="font-family:georgia,serif;font-size:small;color:rgb(7,55,99)">Regards,</div><div style="font-family:georgia,serif;font-size:small;color:rgb(7,55,99)"><br></div><div style="font-family:georgia,serif;font-size:small;color:rgb(7,55,99)"><br></div><div style="font-family:georgia,serif;font-size:small;color:rgb(7,55,99)"><br></div><div style="font-family:georgia,serif;font-size:small;color:rgb(7,55,99)"><br></div><div><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div>--</div><div><br></div><div><font face="georgia, serif" size="4">José Abell </font></div><div><font face="georgia, serif"><i>PhD Candidate</i></font></div><div><font face="georgia, serif">Computational Geomechanics Group</font></div><div><font face="georgia, serif"><span style="font-size:12.7273px">Dept. of Civil and Environmental Engineering</span><br></font></div><div><font face="georgia, serif">UC Davis</font></div><div><font face="georgia, serif"><a href="http://www.joseabell.com" target="_blank">www.joseabell.com</a></font></div><div><br></div></div></div></div></div></div></div></div></div>
</div>
</blockquote></span></div><br></div></div>
</blockquote></div><br></div>