[petsc-dev] Strange array indexing in MatDestroySubMatrices

Stefano Zampini stefano.zampini at gmail.com
Thu Jul 13 03:42:53 CDT 2017


Hong,

I think  what you wrote is conceptually wrong, being in the interface part
of the library.
The extra allocation is not done consistently throughout all the specific
implementations that MatCreateSubMatrices can use.
Here is an excerpt of a valgrind error I'm getting

==37303== Conditional jump or move depends on uninitialised value(s)
==37303==    at 0xA94B0D7: MatDestroySubMatrices
(/home/szampini/src/petsc/src/mat/interface/matrix.c:6890)
==37303==    by 0xAFA0400: PCBDDCSubSchursSetUp
(/home/szampini/src/petsc/src/ksp/pc/impls/bddc/bddcschurs.c:1545)
.....
==37303==  Uninitialised value was created by a heap allocation
==37303==    at 0x4C2FF83: memalign
(/builddir/build/BUILD/valgrind-3.12.0/coregrind/m_replacemalloc/vg_replace_malloc.c:858)
==37303==    by 0x9FA172C: PetscMallocAlign
(/home/szampini/src/petsc/src/sys/memory/mal.c:39)
==37303==    by 0x9FA4044: PetscTrMallocDefault
(/home/szampini/src/petsc/src/sys/memory/mtr.c:183)
==37303==    by 0xA87BE20: MatCreateSubMatrix_MPIAIJ_All
(/home/szampini/src/petsc/src/mat/impls/aij/mpi/mpiov.c:1082)
==37303==    by 0xA8852F1: MatCreateSubMatrices_MPIAIJ
(/home/szampini/src/petsc/src/mat/impls/aij/mpi/mpiov.c:2024)
==37303==    by 0xA9490C3: MatCreateSubMatrices
(/home/szampini/src/petsc/src/mat/interface/matrix.c:6742)
==37303==    by 0xAF9F401: PCBDDCSubSchursSetUp
(/home/szampini/src/petsc/src/ksp/pc/impls/bddc/bddcschurs.c:1506)

You can see the calling sequence, so that maybe I'm doing something wrong
in bddcschurs.c.

Thanks,
Stefano


2017-07-12 22:20 GMT+03:00 Hong <hzhang at mcs.anl.gov>:

> MatCreateSubMatrices_xxx() calloc an array of size n+1, n=ismax and
> submat[n]=null as default.
>
> For MatCreateSubMatrices_MPIAIJ(), I calloc ismax+nstages and use
> submat[n] ... to store some datastructures for reuse.
>
> When submat[n] != null, these data structures are destroyed.
>
> Hong
>
>
> On Wed, Jul 12, 2017 at 11:29 AM, Stefano Zampini <
> stefano.zampini at gmail.com> wrote:
>
>> Is line number 6890 of matrix.c correct???
>>
>> https://bitbucket.org/petsc/petsc/src/b02a13eda23b9fabea7dbf
>> cadcfb98e3258ee49d/src/mat/interface/matrix.c?at=master&
>> fileviewer=file-view-default#matrix.c-6890
>>
>> --
>> Stefano
>>
>
>


-- 
Stefano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20170713/761925e0/attachment.html>


More information about the petsc-dev mailing list