[petsc-users] Error message of nnz cannot be greater than block row length from MatSetValues()

Evan Um evanum at gmail.com
Thu Nov 6 18:40:31 CST 2014


Dear Jed,

Thanks for your help many times. These numbers mean the total number of
elements to be added using MatSetValues(). For example, at process 0,
148767+5821 elements are added to matrix B. In other words, the length of
arrays (i.e. mat_b_i_partitioned, mat_b_j_partitioned and
mat_b_val_partitioned)
is 148767+5821. I used "ADD_VALUES" but "INSERT_VALUES" should be the same
for my work.

As you suggested, I explicitly passed the number of local rows to
MatSetSizes as shown below. The number of local rows agrees with a range of
continuous row indices stored at array mat_b_i_partitioned. I also
explicitly set up the number of local column=the matrix size. In this case,
I get error message: "Sum of local lengths 156315 does not equal global
length 52105, my local length 52105". I used 3 processes. I guess
that number 156315 seems to be related with 3*size of my global column
size. In my problem, the matrix is partitioned by rows but not by columns.
In this case, how can I specify the local column size in MatSetSizes()?

Evan

// CODE
MatCreate(PETSC_COMM_WORLD,&B);
MatSetSizes(B, partitioned_row_size, ngedges_internal, ngedges_internal,
ngedges_internal);
MatSetType(B,MATSBAIJ);
MatMPISBAIJSetPreallocation(B,1,0,d_nnz,0,o_nnz);
MatSetValues(B, nentries_mat_b_partitioned, mat_b_i_partitioned,
nentries_mat_b_partitioned, mat_b_j_partitioned, mat_b_val_partitioned,
ADD_VALUES);
MatAssemblyBegin(B,MAT_FINAL_ASSEMBLY);
MatAssemblyEnd(B,MAT_FINAL_ASSEMBLY);


//ERROR:
[0]PETSC ERROR: --------------------- Error Message
--------------------------------------------------------------
[0]PETSC ERROR: Nonconforming object sizes
[0]PETSC ERROR: Sum of local lengths 156315 does not equal global length
52105, my local length 52105
  likely a call to VecSetSizes() or MatSetSizes() is wrong.




On Thu, Nov 6, 2014 at 12:23 PM, Jed Brown <jed at jedbrown.org> wrote:

> Evan Um <evanum at gmail.com> writes:
>
> > Dear PETSC users,
> >
> > I hope that I can have a comment about errors I got during sparse
> symmetric
> > matrix construction. In this example, I used three processes. The size
> of a
> > test matrix is 52105-by-52105. The length of array d_nnz and o_nnz is
> 17461
> > at rank 0, 17111 at rank 1 and 17535 at rank 2. The two arrays exactly
> > describe nnz of the diagonal and off-diagonal part. At rank 0, I tried
> > to add 148767 element for the diagonal part and 5821 for the off-diagonal
> > part. At rank 1, I tried to add 135826 and 19541 for the diagonal and
> > off-diagonal parts, respectively.
>
> Do these numbers mean that the sum of all the entries in the the arrays
> are 148767, 135826, etc?
>
> > At rank 2, I tried to add 138155 and 0 for the diagonal and
> > off-diagonal parts. Rank 0 has matrix rows from 0 to 17460; rank 1
> > from 17460 to 34570 and rank 2 from 34570 to 52104.  During the run, I
> > got an error message: nnz cannot be greater than block row length:
> > local row 17124 value 38762560 rowlength 17368. My d_nnz and o_nnz
> > arrays never have a value such as 38762560.
>
> Use MatGetOwnershipRange() and/or pass the local sizes to MatSetSizes.
> Your arrays are the wrong length, which is why the error refers to local
> row 17124 or rank 1 (which is larger than the array length of 17111).
> Valgrind would have told you this.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20141106/ebe6d9af/attachment-0001.html>


More information about the petsc-users mailing list