Projet_TRIOU <[email protected]> writes:

> Sorry a typo, it is really MatMPISBAIJSetPreallocation()
>
> Yes, I call MatMPISBAIJSetPreallocation() on ALL processes and
> sometimes a local part of the matrix has zero rows. It worked well
> with Petsc 3.3 and before in this particular case.

I believe this is the relevant conditional:

  if (nz >= 0 || nnz) realalloc = PETSC_TRUE;

Instead of this:

       if (nb_rows==0) // Local matrix is empty
          ierr = MatMPISBAIJSetPreallocation(MatricePetsc, block_size_, 0, 
NULL, 0, NULL);
       else
          ierr = MatMPISBAIJSetPreallocation(MatricePetsc, block_size_, 
PETSC_DEFAULT, d_nnz.addr(), PETSC_DEFAULT, o_nnz.addr());

can you just call the following?

          ierr = MatMPISBAIJSetPreallocation(MatricePetsc, block_size_, 0, 
d_nnz.addr(), 0, o_nnz.addr());

If you are passing an nnz array (can be empty if there are zero rows),
we will trust that.  PETSC_DEFAULT is only intended to be used if you
don't pass an array, though we're currently being tolerant by ignoring
it if the array is non-NULL.  The problem arises because we can't tell
the difference between a zero-length semantically-meaningful array and
an "I'm not passing this argument" NULL.

Is this something we can fix in the documentation or should we guard in
the code?

Attachment: pgpnp0H52ytJD.pgp
Description: PGP signature

Reply via email to