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

Marius Buerkle mbuerkle at web.de
Wed Feb 2 18:10:42 CST 2022


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.

> Gesendet: Dienstag, den 01.02.2022 um 16:45 Uhr
> Von: "Patrick Sanan" <patrick.sanan at gmail.com>
> An: "Jed Brown" <jed at jedbrown.org>
> Cc: "Marius Buerkle" <mbuerkle at web.de>, "PETSc users list" <petsc-users at mcs.anl.gov>, petsc-dev <petsc-dev at mcs.anl.gov>
> Betreff: Re: [petsc-dev] [petsc-users] MatPreallocatorPreallocate segfault with PETSC 3.16
>
> That works, as in the attached example - Marius, would that work for your
> case?
>
> Am Di., 1. Feb. 2022 um 16:33 Uhr schrieb Jed Brown <jed at jedbrown.org>:
>
> > Patrick Sanan <patrick.sanan at gmail.com> writes:
> >
> > > Am Di., 1. Feb. 2022 um 16:20 Uhr schrieb Jed Brown <jed at jedbrown.org>:
> > >
> > >> Patrick Sanan <patrick.sanan at gmail.com> writes:
> > >>
> > >> > Sorry about the delay on this. I can reproduce.
> > >> >
> > >> > This regression appears to be a result of this optimization:
> > >> > https://gitlab.com/petsc/petsc/-/merge_requests/4273
> > >>
> > >> Thanks for tracking this down. Is there a reason to prefer preallocating
> > >> twice
> > >>
> > >>    ierr =
> > >> MatPreallocatorPreallocate(preallocator,PETSC_TRUE,A);CHKERRQ(ierr);
> > >>    ierr =
> > >>
> > MatPreallocatorPreallocate(preallocator,PETSC_TRUE,A_duplicate);CHKERRQ(ierr);
> > >>
> > >> versus using MatDuplicate() or MatConvert()?
> > >>
> > >
> > > Maybe if your preallocation is an overestimate for each of two different
> > > post-assembly non-zero structures in A and A_duplicate?
> >
> > Even then, why not preallocate A and duplicate immediately, before
> > compressing out zeros?
> >


More information about the petsc-dev mailing list