<div dir="ltr">wow that is news to me. I always assumed that this is normal.<div><br></div><div>I'm pretty certain it's not the preallocation. I'm using MatCreateMPI, and to my knowledge I wouldn't even be able to set the values without crashing if I didn't preallocate. (If I'm not mistaken, the setting values slowly without preallocating is only possible if you create the Mat using MatCreate + MatSetup).</div>
<div><br></div><div>Also, I'm certain that the time is taken on the first solve, not the setting of values, because I use the matrix in a MatMult first to get the RHS before solving, and the MatMult happens before the long first solve. </div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jan 28, 2014 at 5:04 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
On Jan 28, 2014, at 1:36 PM, David Liu <<a href="mailto:daveliu@mit.edu">daveliu@mit.edu</a>> wrote:<br>
<br>
> Hi, I'm writing an application that solves a sparse matrix many times using Pastix. I notice that the first solves takes a very long time,<br>
<br>
</div>  Is it the first “solve” or the first time you put values into that matrix that “takes a long time”? If you are not properly preallocating the matrix then the initial setting of values will be slow and waste memory.  See <a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatXAIJSetPreallocation.html" target="_blank">http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatXAIJSetPreallocation.html</a><br>

<br>
  The symbolic factorization is usually much faster than a numeric factorization so that is not the cause of the slow “first solve”.<br>
<span class="HOEnZb"><font color="#888888"><br>
   Barry<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
<br>
> while the subsequent solves are very fast. I don't fully understand what's going on behind the curtains, but I'm guessing it's because the very first solve has to read in the non-zero structure for the LU factorization, while the subsequent solves are faster because the nonzero structure doesn't change.<br>

><br>
> My question is, is there any way to save the information obtained from the very first solve, so that the next time I run the application, the very first solve can be fast too (provided that I still have the same nonzero structure)?<br>

<br>
</div></div></blockquote></div><br></div>