<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Stefano:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I'm not able to reproduce it with the BDDC example ex59.c in KSP tutorials.<br><div>The error comes from the PetscMalloc1 call  at src/mat/impls/aij/mpi/mpiov.c:<wbr>1082, which allocates with Malloc and not with Calloc.</div></div></blockquote><div><br></div><div>This is a bug. The change</div><div><div>-    ierr  = PetscMalloc1(1,Bin);CHKERRQ(ierr);</div><div>+    ierr  = PetscCalloc1(2,Bin);CHKERRQ(ierr);</div></div><div>fix the bug. </div><div><a href="https://bitbucket.org/petsc/petsc/commits/a27f7bbfc0dabeb54077f66748454576b9565427">https://bitbucket.org/petsc/petsc/commits/a27f7bbfc0dabeb54077f66748454576b9565427</a><br></div><div><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 class="gmail_extra"><div><div class="gmail-h5"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div><div class="gmail-m_-380463900939497846h5"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>I think  what you wrote is conceptually wrong, being in the interface part of the library.</div><div>The extra allocation is not done consistently throughout all the specific implementations that MatCreateSubMatrices can use.</div></div></blockquote></div></div></div></div></div></blockquote></div></div></div></div></blockquote><div><br></div><div>How about adding 'destroysubmatrices' into _MatOps table, then move the extra stuff into MatDestroySubmatrices_xxx()?</div><div><br></div><div>Hong</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 class="gmail_extra"><div><div class="gmail-h5"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div><div class="gmail-m_-380463900939497846h5"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Here is an excerpt of a valgrind error I'm getting</div><div><br></div><div><div>==37303== Conditional jump or move depends on uninitialised value(s)</div><div>==37303==    at 0xA94B0D7: MatDestroySubMatrices (/home/szampini/src/petsc/src/<wbr>mat/interface/matrix.c:6890)</div><div>==37303==    by 0xAFA0400: PCBDDCSubSchursSetUp (/home/szampini/src/petsc/src/<wbr>ksp/pc/impls/bddc/bddcschurs.c<wbr>:1545)</div></div><div><div>.....</div><div>==37303==  Uninitialised value was created by a heap allocation</div><div>==37303==    at 0x4C2FF83: memalign (/builddir/build/BUILD/valgrin<wbr>d-3.12.0/coregrind/m_replacema<wbr>lloc/vg_replace_malloc.c:858)</div><div>==37303==    by 0x9FA172C: PetscMallocAlign (/home/szampini/src/petsc/src/<wbr>sys/memory/mal.c:39)</div><div>==37303==    by 0x9FA4044: PetscTrMallocDefault (/home/szampini/src/petsc/src/<wbr>sys/memory/mtr.c:183)</div><div>==37303==    by 0xA87BE20: MatCreateSubMatrix_MPIAIJ_All (/home/szampini/src/petsc/src/<wbr>mat/impls/aij/mpi/mpiov.c:1082<wbr>)</div><div>==37303==    by 0xA8852F1: MatCreateSubMatrices_MPIAIJ (/home/szampini/src/petsc/src/<wbr>mat/impls/aij/mpi/mpiov.c:2024<wbr>)</div><div>==37303==    by 0xA9490C3: MatCreateSubMatrices (/home/szampini/src/petsc/src/<wbr>mat/interface/matrix.c:6742)</div><div>==37303==    by 0xAF9F401: PCBDDCSubSchursSetUp (/home/szampini/src/petsc/src/<wbr>ksp/pc/impls/bddc/bddcschurs.c<wbr>:1506)</div></div><div><br></div><div>You can see the calling sequence, so that maybe I'm doing something wrong in bddcschurs.c.</div><div><br></div><div>Thanks,</div><div>Stefano</div><div><br></div></div><div class="gmail_extra"><div><div class="gmail-m_-380463900939497846m_-6005209296008089805h5"><br><div class="gmail_quote">2017-07-12 22:20 GMT+03:00 Hong <span dir="ltr"><<a href="mailto:hzhang@mcs.anl.gov" target="_blank">hzhang@mcs.anl.gov</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">MatCreateSubMatrices_xxx() calloc an array of size n+1, n=ismax and submat[n]=null as default.<div><br><div>For MatCreateSubMatrices_MPIAI<wbr>J(), I calloc ismax+nstages and use </div><div>submat[n] ... to store some datastructures for reuse.</div><div><br></div><div>When submat[n] != null, these data structures are destroyed.</div><span class="gmail-m_-380463900939497846m_-6005209296008089805m_4275649797395842593HOEnZb"><font color="#888888"><div><br></div></font></span><div><span class="gmail-m_-380463900939497846m_-6005209296008089805m_4275649797395842593HOEnZb"><font color="#888888">Hong</font></span><div><div class="gmail-m_-380463900939497846m_-6005209296008089805m_4275649797395842593h5"><br><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 12, 2017 at 11:29 AM, Stefano Zampini <span dir="ltr"><<a href="mailto:stefano.zampini@gmail.com" target="_blank">stefano.zampini@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Is line number 6890 of matrix.c correct???<div><br></div><div><a href="https://bitbucket.org/petsc/petsc/src/b02a13eda23b9fabea7dbfcadcfb98e3258ee49d/src/mat/interface/matrix.c?at=master&fileviewer=file-view-default#matrix.c-6890" target="_blank">https://bitbucket.org/petsc/pe<wbr>tsc/src/b02a13eda23b9fabea7dbf<wbr>cadcfb98e3258ee49d/src/mat/int<wbr>erface/matrix.c?at=master&file<wbr>viewer=file-view-default#matri<wbr>x.c-6890</a><span class="gmail-m_-380463900939497846m_-6005209296008089805m_4275649797395842593m_-9002348180672752337gmail-HOEnZb"><font color="#888888"><br clear="all"><div><br></div>-- <br><div class="gmail-m_-380463900939497846m_-6005209296008089805m_4275649797395842593m_-9002348180672752337gmail-m_4119919259534487923gmail_signature">Stefano</div>
</font></span></div></div>
</blockquote></div><br></div></div></div></div></div></div></div>
</blockquote></div><br><br clear="all"><div><br></div></div></div><span class="gmail-m_-380463900939497846m_-6005209296008089805HOEnZb"><font color="#888888">-- <br><div class="gmail-m_-380463900939497846m_-6005209296008089805m_4275649797395842593gmail_signature">Stefano</div>
</font></span></div>
</blockquote></div><br></div></div></div></div>
</blockquote></div><br><br clear="all"><div><br></div></div></div><span class="gmail-HOEnZb"><font color="#888888">-- <br><div class="gmail-m_-380463900939497846gmail_signature">Stefano</div>
</font></span></div>
</blockquote></div><br></div></div>