[petsc-users] re. AIJ preallocation man page

Matthew Knepley knepley at gmail.com
Mon May 23 07:04:31 CDT 2016

On Mon, May 23, 2016 at 6:39 AM, Karl Rupp <rupp at iue.tuwien.ac.at> wrote:

> Hi Marco,
> > I'm struggling with this statement:
>> "It is recommended that you call both of the above preallocation
>> routines [MatSeqAIJSetPreallocation and MatMPIAIJSetPreallocation] for
>> simplicity."
>> (source:
>> https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MATAIJ.html
>> )
>> I saw that, even on a single-processor communicator,
>> MatMPIAIJSetPreallocation works fine (at least, it gives no errors,
>> but I don't know about efficiency drops).
>> What's the effect of the recommended double preallocation?
> It allows you to quickly switch between a serial run and a parallel run.
> If something doesn't work as expected, it's much easier to debug (if
> possible) on a single rank, hence MatSeqAIJSetPreallocation. However,
> ultimately you are looking for parallel runs, for which you need
> MatMPIAIJSetPreallocation. Changing your code back and forth is
> non-productive, hence it's recommended to call both and you get full
> flexibility :-)

PETSc uses a system for dispatch that ignores functions which do not apply
to that concrete type. This
allows you to call a variety of specialization functions without

  a) constantly checking the type

  b) failure where a downcast might fail



> Best regards,
> Karli

What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160523/f712f0aa/attachment.html>

More information about the petsc-users mailing list