<div class="gmail_extra">On Mon, Apr 30, 2012 at 7:01 PM, Mohammad Mirzadeh <span dir="ltr"><<a href="mailto:mirzadeh@gmail.com" target="_blank">mirzadeh@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div>Hi,</div><div><br></div>Just a quick question. Following petsc-dev/src/ksp/ksp/examples/tutorials/ex2.c, it seems that I need to call both MatMPIAIJSetPreallocation and MatSeqAIJSetPreallocation to be able to preallocate for both MPI and Seq matrices. Does petsc automatically chose the relevant function when the code is run in serial and parallel? In other words, what is the effect of MatMPIAIJSetPreallocation(MatSeqAIJSetPreallocation) when the code is run in serial(parallel)? <div>
<br></div><div>I like how several functions are abstract and can be used both in serial and parallel (like MatCreate). Is there a similar way to just call a single "MatSetPreallocation" function?</div></div></blockquote>
<div><br></div><div><a href="http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/Mat/MatXAIJSetPreallocation.html">http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/Mat/MatXAIJSetPreallocation.html</a></div><div>
<br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">
<div>Thanks,</div><div>Mohammad<br><br><div class="gmail_quote">On Wed, Apr 25, 2012 at 4:04 PM, Mohammad Mirzadeh <span dir="ltr"><<a href="mailto:mirzadeh@gmail.com" target="_blank">mirzadeh@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"><div class="gmail_extra">Thanks Hong; that fixed the problem.<div><div><br><br><div class="gmail_quote">
On Wed, Apr 25, 2012 at 11:31 AM, Hong Zhang <span dir="ltr"><<a href="mailto:hzhang@mcs.anl.gov" target="_blank">hzhang@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="gmail_extra">Mohammad:<br><div class="gmail_quote"><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div class="gmail_extra"><br></div> MatCreate(comm, &A);<br>
MatSetSizes(A, localRowSize, localColumnSize, globalRowSize, globalColumnSize);<br> MatSetType(A, MATMPIAIJ);<br>
MatMPIAIJSetPreallocation(A, 0, d_nnz, 0, o_nnz);<br> MatSetFromOptions(A);<br>MatGetOwnershipRange(A, &rStart, &rEnd);<div><br></div><div><br></div><div>This (even without MatSetType(A, MATMPIAIJ);) works with 3.2-p6 but not dev. The only difference I can see is 1) the order of MatSetFromOptions and 2) I do not call MatSeqAIJSetPreallocation which I think I do not need anyway. Is there something I'm doing wrong?</div>
</div></blockquote><div> </div></div><div>MatSetFromOptions() must be called before MatMPIAIJSetPreallocation().</div><div>If user set mattype at runtime, MatSetFromOptions() picks it and set the type accordingly. SetPreallocation()</div>
<div>will be called after the type is set.</div><div><br></div><div>Hong</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">
<div><br></div><div>Mohammd</div></div>
</blockquote></div><br></div>
</blockquote></div><br></div></div></div></div>
</blockquote></div><br></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>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<br>
</div>