[petsc-dev] [petsc-users] MatPreallocatorPreallocate segfault with PETSC 3.16

Patrick Sanan patrick.sanan at gmail.com
Mon Feb 7 03:15:40 CST 2022


This makes that change to improve the behavior of the release branch:
https://gitlab.com/petsc/petsc/-/merge_requests/4818

For reference in the future, also see this related issue:
https://gitlab.com/petsc/petsc/-/issues/852

Am Fr., 4. Feb. 2022 um 12:03 Uhr schrieb Patrick Sanan <
patrick.sanan at gmail.com>:

> So, seems like a fix we should make at this point is to make
> MatPreallocator explicitly single use, throwing an error if
> MatPreallocatorPreallocate is called a second time. (Still open for further
> debate as to what to do in general but this quick patch to release to
> replace the crash with an error message seems justified in any case).
>
> Am Fr., 4. Feb. 2022 um 02:02 Uhr schrieb Jed Brown <jed at jedbrown.org>:
>
>> MatPreallocator stores "the nonzero structure" in a hash table so it can
>> be easily updated. A normal Mat stores it in a compressed (CSR) format that
>> is expensive to update.
>>
>> Marius Buerkle <mbuerkle at web.de> writes:
>>
>> > Ok. I did not know that. I was under the impression that
>> MatPreallocator does actually not allocate the nonzeros and just stores the
>> nonzero structure. But if this is not the case then of course I just
>> duplicate the matrix.
>> >
>> > Thanks for the feedback.
>> >
>> >> Gesendet: Donnerstag, den 03.02.2022 um 03:09 Uhr
>> >> Von: "Jed Brown" <jed at jedbrown.org>
>> >> An: "Marius Buerkle" <mbuerkle at web.de>, "Patrick Sanan" <
>> patrick.sanan at gmail.com>
>> >> Cc: "PETSc users list" <petsc-users at mcs.anl.gov>, petsc-dev <
>> petsc-dev at mcs.anl.gov>
>> >> Betreff: Re: Aw: Re: [petsc-dev] [petsc-users]
>> MatPreallocatorPreallocate segfault with PETSC 3.16
>> >>
>> >> Marius Buerkle <mbuerkle at web.de> writes:
>> >>
>> >> > Thanks for they reply. Yes the example works, this is how I was
>> doing it before. But the matrix is rather big and i need a matrix with the
>> same structure at various points in my code. So it was convenient to create
>> the matrix with preallocate, destroy it after using it to free the memory
>> and creating it again later with the same preallocate.
>> >> > Anyway it works with MatDuplicate for now.
>> >>
>> >> I think it should take *less* memory to destroy the preallocator and
>> duplicate the actual matrix than to destroy the matrix and persist the
>> preallocator. If that is not the case (or close enough), we can make it so.
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20220207/a094bcf1/attachment.html>


More information about the petsc-dev mailing list