[petsc-users] question about MatXAIJSetPreallocation

Jed Brown jedbrown at mcs.anl.gov
Tue Oct 2 21:12:14 CDT 2012


Oh noes, that's not what I ever intended. That code is creating an array
that is much longer than it should be.

The logic for setting block size was also changed in the spring and
evidently not propagated to this routine so I added the PetscLayoutSetUp()
calls that ensure local size is divisible by block size.

I think this patch fixes both issues:

http://petsc.cs.iit.edu/petsc/releases/petsc-3.3/rev/4e499e21f7a2

On Tue, Oct 2, 2012 at 7:57 PM, Geoffrey Irving <irving at naml.us> wrote:

> On Tue, Oct 2, 2012 at 4:48 PM, Geoffrey Irving <irving at naml.us> wrote:
> > The dnnz argument to MatXAIJSetPreallocation is described as
> >
> >     dnnz - number of nonzero blocks per block row of diagonal part of
> > parallel matrix
> >
> > To me, this implies that if the matrix has size m and the block size
> > is bs, dnnz should have size m/bs.  However, the loop inside the
> > routine looks like
> >
> >      for (i=0; i<m*bs; i++) {
> >         if (dnnz) sdnnz[i] = dnnz[i/bs] * bs;
> >         if (onnz) sonnz[i] = onnz[i/bs] * bs;
> >       }
> >
> > which implies that dnnz should have m entries.  Is this a bug, or am I
> > misinterpreting the meaning of dnnz?
>
> It looks like the loop hasn't changed since the beginning of
> MatXAIJSetPreallocation, but the comment changed from
>
>     dnnz - number of nonzeros per row of diagonal block of parallel matrix
>
> to
>
>     dnnz - number of nonzero blocks per block row of diagonal part of
> parallel matrix
>
> in
>
>     commit abccccb5e4359792067c7bef9b175a0511adf626
>     Author: Jed Brown <jed at 59A2.org>
>     Date:   Thu Mar 1 11:51:58 2012 -0600
>
>         Remove the maximum nonzero arguments from MatXAIJSetPreallocation()
>
> I'll change my code to match the first comment and see if it works.
>
> Geoffrey
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20121002/33c6e1ae/attachment.html>


More information about the petsc-users mailing list