<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">OK, I was wrong about MATAIJ, as Jed already pointed out.<div class="">What about BAIJ or Dense matrices?</div><div style="orphans: 2; widows: 2;" class="">What about VecCreateMPIWithArray which seems to explicitly call <span style="orphans: 2; widows: 2;" class="">VecCreate_MPI_Private which </span>explicitly sets the type to VECMPI <a href="https://www.mcs.anl.gov/petsc/petsc-current/src/vec/vec/impls/mpi/pbvec.c.html#line522" class="">https://www.mcs.anl.gov/petsc/petsc-current/src/vec/vec/impls/mpi/pbvec.c.html#line522</a> so that I cannot do a MatMult with a MATAIJ with a communicator of size 1?</div><div style="orphans: 2; widows: 2;" class=""><br class=""></div><div style="orphans: 2; widows: 2;" class="">Thanks,</div><div style="orphans: 2; widows: 2;" class="">Pierre  </div><div class=""><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 15 Jan 2019, at 9:40 AM, Dave May <<a href="mailto:dave.mayhem23@gmail.com" class="">dave.mayhem23@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><br class=""></div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Tue, 15 Jan 2019 at 05:18, Pierre Jolivet via petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov" class="">petsc-dev@mcs.anl.gov</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;" class="">Cf. the end of my sentence: "(I know, I could switch to SeqAIJ_SeqDense, but that is not an option I have right now)”<div class="">All my Mat are of type MATMPIX. Switching to MATX here as you suggested would mean that I need to add a bunch of if(comm_size == 1) MatSeqXSetPreallocation else MatMPIXSetPreallocation in the rest of my code, which is something I would rather avoid.</div></div></blockquote><div class=""><br class=""></div><div class="">Actually this is not the case.</div><div class=""><br class=""></div><div class="">If you do as Hong suggests and use MATAIJ then the switch for comm_size for Seq or MPI is done internally to MatCreate and is not required in the user code. Additionally, in your preallocation routine, you can call safely both (without your comm_size if statement)</div><div class="">MatSeqAIJSetPreallocation()<br class=""></div><div class="">and</div><div class="">MatMPIAIJSetPreallocation()</div><div class="">If the matrix type matches that expected by the API, then it gets executed. Otherwise nothing happens.</div><div class=""><br class=""></div><div class="">This is done all over the place to enable the matrix type to be a run-time choice.</div><div class=""><br class=""></div><div class="">For example, see here</div><div class=""><a href="https://www.mcs.anl.gov/petsc/petsc-current/src/dm/impls/da/fdda.c.html#DMCreateMatrix_DA_3d_MPIAIJ" class="">https://www.mcs.anl.gov/petsc/petsc-current/src/dm/impls/da/fdda.c.html#DMCreateMatrix_DA_3d_MPIAIJ</a><br class=""></div><div class="">and look at lines 1511 and 1512. </div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">  Dave</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;" class=""><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Pierre</div><div class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On 14 Jan 2019, at 10:30 PM, Zhang, Hong <<a href="mailto:hzhang@mcs.anl.gov" target="_blank" class="">hzhang@mcs.anl.gov</a>> wrote:</div><br class="gmail-m_-5374603561378769609Apple-interchange-newline"><div class="">



<div class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">Replace 
<div class="">ierr = MatSetType(A, MATMPIAIJ);CHKERRQ(ierr);<br class="">
</div>
<div class="">to</div>
<div class="">ierr = MatSetType(A, MATAIJ);CHKERRQ(ierr);<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Replace <br class="">
</div>
<div class="">ierr = MatSetType(B, MATMPIDENSE)i;CHKERRQ(ierr);</div>
<div class="">to</div>
<div class="">ierr = MatSetType(B, MATDENSE)i;CHKERRQ(ierr);<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Then add</div>
<div class="">MatSeqAIJSetPreallocation()<br class="">
</div>
<div class="">MatSeqDenseSetPreallocation()<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Hong</div>
</div>
</div>
</div>
</div>
</div>
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="">On Mon, Jan 14, 2019 at 2:51 PM Pierre Jolivet via petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov" target="_blank" class="">petsc-dev@mcs.anl.gov</a>> wrote:<br class="">
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Hello,<br class="">
Is there any chance to get MatMatMult_MPIAIJ_MPIDense  and MatTransposeMatMult_MPIAIJ_MPIDense fixed so that the attached program could run _with a single_ process? (I know, I could switch to SeqAIJ_SeqDense, but that is not an option I have right now)<br class="">
<br class="">
Thanks in advance,<br class="">
Pierre<br class="">
<br class="">
</blockquote>
</div>
</div>

</div></blockquote></div><br class=""></div></div></blockquote></div></div></div></div></div>
</div></blockquote></div><br class=""></div></div></body></html>