[petsc-users] MatMatMult size error

Jed Brown jedbrown at mcs.anl.gov
Tue Jan 15 12:00:30 CST 2013


This looks like memory corruption. Can you run in valgrind?


On Tue, Jan 15, 2013 at 11:54 AM, Jim Fonseca <jefonseca at gmail.com> wrote:

> Hi,
> We are in the process of upgrading from Petsc 3.2 to 3.3p5.
>
> We are creating  matrices A and B in this way.
>       petsc_matrix = new Mat;
>       ierr = MatCreateDense(comm, m, num_cols ,num_rows,num_cols,data,A);
>
> Elsewhere, we have this. It gets called a few times, and on the 4th time,
> the size of matrix is C is wrong. Please see the output below. What could
> be the problem?
>      C = new Mat;
>      double fill = PETSC_DEFAULT;
>      MatMatMult(A,B,MAT_INITIAL_MATRIX, fill, C);
>      {
>        int m,n;
>        MatGetOwnershipRange(A, &m, &n);
>        cerr << "A.m = " <<  m << "\n";
>        cerr << "A.n = " <<  n << "\n";
>        MatGetSize(A,&m,&n);
>        cerr << "A global rows = " <<  m << "\n";
>        cerr << "A global cols = " <<  n << "\n";
>
>        MatGetOwnershipRange(B, &m, &n);
>        cerr << "B.m = " <<  m << "\n";
>        cerr << "B.n = " <<  n << "\n";
>        MatGetSize(B,&m,&n);
>        cerr << "B global rows = " <<  m << "\n";
>        cerr << "B global cols = " <<  n << "\n";
>
>        MatGetOwnershipRange(*C, &m, &n);
>        cerr << "C.m = " <<  m << "\n";
>        cerr << "C.n = " <<  n << "\n";
>
>        MatGetSize(*C,&m,&n);
>        cerr << "C global rows = " <<  m << "\n";
>        cerr << "C global cols = " <<  n << "\n";
>
>      }
>
> A.m = 0
> A.n = 59
> A global rows = 59
> A global cols = 320
> B.m = 0
> B.n = 320
> B global rows = 320
> B global cols = 320
> C.m = 0
> C.n = 59
> C global rows = 59
> C global cols = 320
> A.m = 0
> A.n = 59
> A global rows = 59
> A global cols = 320
> B.m = 0
> B.n = 320
> B global rows = 320
> B global cols = 59
> C.m = 10922
> C.n = -1389327096
> C global rows = -1389327112
> C global cols = -1389327112
>
>
> Thanks,
> Jim
> --
> Jim Fonseca, PhD
> Research Scientist
> Network for Computational Nanotechnology
> Purdue University
> 765-496-6495
> www.jimfonseca.com
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130115/b0bc398b/attachment.html>


More information about the petsc-users mailing list