[petsc-users] Memory corruption with two-dimensional array and PetscMemzero

Christophe Ortiz christophe.ortiz at ciemat.es
Wed May 21 08:31:47 CDT 2014


On Wed, May 21, 2014 at 3:21 PM, Jed Brown <jed at jedbrown.org> wrote:

> Christophe Ortiz <christophe.ortiz at ciemat.es> writes:
> > I tried and it works. The advantage is that it avoids setting up and
> > using pointers.  However, I found out that it is significantly slower
> > than using explicit pointers of pointers **.
>
> Are you creating and destroying in an inner loop?


In some sense, yes. I create and destroy inside FormIJacobian() (my
Jacobian evaluation routine). Therefore it is called at each timestep. I
guess this takes time. But it is slower than doing the many malloc.

How can I create a global vector that would be passed to FormIJacobian() ?
Creating it only once instead of doing it at each timestep would save time.
I need to use this vector (size dof*dof) with classes and methods inside
FormIJacobian() to calculate the different blocks that are passed to the
Jacobian with MatSetValuesBlocked(). However, I cannot pass it as argument
of FormIJacobian() since there is no room for it in the arguments.



>  What gets set up is
> the same, and it's fewer allocations than what you were doing with many
> calls to malloc.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140521/7d321a01/attachment.html>


More information about the petsc-users mailing list