<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 09:16, Pierre Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr">pierre.jolivet@enseeiht.fr</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;"><br><div><blockquote type="cite"><div>On 15 Jan 2019, at 10:01 AM, Dave May <<a href="mailto:dave.mayhem23@gmail.com" target="_blank">dave.mayhem23@gmail.com</a>> wrote:</div><br class="gmail-m_-6163844538290384033Apple-interchange-newline"><div><div dir="ltr"><div dir="ltr"><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 08:50, Pierre Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr" target="_blank">pierre.jolivet@enseeiht.fr</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>OK, I was wrong about MATAIJ, as Jed already pointed out.<div>What about BAIJ or Dense matrices?</div></div></blockquote><div><br></div><div>The preallocation methods for BAIJ and Dense both internally use PetscTryMethod.</div></div></div></div></div></div></div></div></div></blockquote><div><br></div><div>I don’t see any MatDenseSetPreallocation in master, what are you referring to please?</div></div></div></blockquote><div><br></div><div>I was referring to the fact that you can safely call these preallocation routines together</div><div><br></div><div><div>MatSeqBAIJSetPreallocation</div><div>MatMPIBAIJSetPreallocation<br></div></div><div>MatSeqDenseSetPreallocation<br></div><div>MatMPIDenseSetPreallocation<br></div><div><br></div><div>and they will only take effect if the comm size and matrix type matches what the API expects.</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><div><br></div><blockquote type="cite"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><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><div>What about VecCreateMPIWithArray which seems to explicitly call <span>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" target="_blank">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></blockquote><div><br></div><div>That looks problematic. </div><div><br></div><div>Possibly there should either be an if statement in VecCreateMPIWithArray() associated with the comm size, or there should be a new API VecCreateWithArray() with the same args as VecCreateMPIWithArray.</div><div><br></div><div>As a work around, you could add VecCreateWithArray() in your code base which does the right thing. </div></div></div></div></div></div></div></div></div></blockquote><div><br></div><div>Sure, I can find a workaround in my code, but I’m still thinking it is best not to have PETSc segfaults when a user is doing something they are allowed to do :)</div></div></div></blockquote><div><br></div><div>Sure - it was just a pragmatic suggestion to provide a short time fix / hack.</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><div><br></div><div>Thanks,</div><div>Pierre</div><br><blockquote type="cite"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><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><div><br></div><div>Thanks,</div><div>Pierre  </div><div><div><div><br><blockquote type="cite"><div>On 15 Jan 2019, at 9:40 AM, Dave May <<a href="mailto:dave.mayhem23@gmail.com" target="_blank">dave.mayhem23@gmail.com</a>> wrote:</div><br class="gmail-m_-6163844538290384033gmail-m_-1586324046755794593gmail-m_-1952207911949175710Apple-interchange-newline"><div><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" 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"><div>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" target="_blank">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><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_-6163844538290384033gmail-m_-1586324046755794593gmail-m_-1952207911949175710gmail-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>
</div></blockquote></div><br></div></div></div></blockquote></div></div></div></div></div></div></div>
</div></blockquote></div><br></div></blockquote></div></div></div></div></div>