[petsc-users] MatMatMult size error

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


On Tue, Jan 15, 2013 at 3:05 PM, Jim Fonseca <jefonseca at gmail.com> wrote:

> Hi Jed,
> We didn't see obvious memory corruption with valgrind.


Does this mean it runs without any valgrind errors?


> We printed matrix A and B and they both appear correct.
> We think it may be related to the matrices being non-square. Could it be
> related to that?
>
> Also, if we run outside the debugger, we get the following error, but I'm
> not sure which line that is coming from.
> terminate called after throwing an instance of 'std::runtime_error'
>   what():  [PetscMatrixNemo<cplx>] PETSc gave error with code 73:
>     Object is in wrong state
>

If you have a debug version of PETSc, it should give you a trace. Maybe you
aren't checking error codes?

Are you using MAT_INITIAL_MATRIX in all cases? Nonsquareness shouldn't be a
problem. Can you set a breakpoint in PetscError or use -on_error_abort (or
-on_error_attach_debugger) to get a trace from the place that raises
"Object is in wrong state"?


>
> Thanks,
> Jim
>
> On Tue, Jan 15, 2013 at 1:00 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:
>
>> 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
>>>
>>>
>>>
>>
>
>
> --
> 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/876f25fd/attachment.html>


More information about the petsc-users mailing list