<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr">On Tue, 15 Jan 2019 at 05:18, Pierre Jolivet via petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov">petsc-dev@mcs.anl.gov</a>> wrote:<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 style="overflow-wrap: break-word;">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>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><br></div><div>Actually this is not the case.</div><div><br></div><div>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>MatSeqAIJSetPreallocation()<br></div><div>and</div><div>MatMPIAIJSetPreallocation()</div><div>If the matrix type matches that expected by the API, then it gets executed. Otherwise nothing happens.</div><div><br></div><div>This is done all over the place to enable the matrix type to be a run-time choice.</div><div><br></div><div>For example, see here</div><div><a href="https://www.mcs.anl.gov/petsc/petsc-current/src/dm/impls/da/fdda.c.html#DMCreateMatrix_DA_3d_MPIAIJ">https://www.mcs.anl.gov/petsc/petsc-current/src/dm/impls/da/fdda.c.html#DMCreateMatrix_DA_3d_MPIAIJ</a><br></div><div>and look at lines 1511 and 1512. </div><div><br></div><div>Thanks,</div><div>  Dave</div><div><br></div><div><br></div><div><br></div><div> </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;"><div><br></div><div>Thanks,</div><div>Pierre</div><div><div><br><blockquote type="cite"><div>On 14 Jan 2019, at 10:30 PM, Zhang, Hong <<a href="mailto:hzhang@mcs.anl.gov" target="_blank">hzhang@mcs.anl.gov</a>> wrote:</div><br class="gmail-m_-5374603561378769609Apple-interchange-newline"><div>



<div>
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">Replace 
<div>ierr = MatSetType(A, MATMPIAIJ);CHKERRQ(ierr);<br>
</div>
<div>to</div>
<div>ierr = MatSetType(A, MATAIJ);CHKERRQ(ierr);<br>
</div>
<div><br>
</div>
<div>Replace <br>
</div>
<div>ierr = MatSetType(B, MATMPIDENSE)i;CHKERRQ(ierr);</div>
<div>to</div>
<div>ierr = MatSetType(B, MATDENSE)i;CHKERRQ(ierr);<br>
</div>
<div><br>
</div>
<div>Then add</div>
<div>MatSeqAIJSetPreallocation()<br>
</div>
<div>MatSeqDenseSetPreallocation()<br>
</div>
<div><br>
</div>
<div>Hong</div>
</div>
</div>
</div>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">On Mon, Jan 14, 2019 at 2:51 PM Pierre Jolivet via petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov" target="_blank">petsc-dev@mcs.anl.gov</a>> wrote:<br>
</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>
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>
<br>
Thanks in advance,<br>
Pierre<br>
<br>
</blockquote>
</div>
</div>

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