Hannes, Do you use petsc-3.3? MatMtMult() might be buggy. We have updated MatMtMult() in petsc-dev. Suggest testing your code using petsc-dev (http://www.mcs.anl.gov/petsc/developers/index.html).
As Jed suggested, you would use MatMatMult() instead of MatMatMultSymbolic() and MatMatMultNumeric(). However, we do have examples using the latter. See petsc-dev/src/mat/examples/tests/ex93.c which I updated to run in parallel. https://bitbucket.org/petsc/petsc-dev/commits/37e8170f9464171541ac1e801921bf58 I tested ex93 with valgrind and got clean output. If your code shows valgrind error with petsc-dev, please let us know. Hong On Tue, Jan 8, 2013 at 4:58 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote: > Typically you would use this, for which there are a few examples (at the > bottom of the page). > > http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/Mat/MatMatMult.html > > If that doesn't fix your problem, please set up a test case or at least give > us verbose diagnostics. > > > > On Tue, Jan 8, 2013 at 8:26 AM, Johannes Huber <johannes.huber at unibas.ch> > wrote: >> >> Hi, >> I have a valgrind "invalid read" in MatGetBrowsOfAoCols_MPIAIJ in the >> lines >> rvalues = gen_from->values; /* holds the length of receiving row */ >> svalues = gen_to->values; /* holds the length of sending row */ >> (and others, but that are the first). This function is called indirectly >> via MatMatMultSymbolic. >> All invalid reads apear in MatGetBrowsOfAoCols_MPIAIJ. >> The calling sequence for the matrix factors are >> MatCreate(PETSC_COMM_WORLD,A); >> MatSetSizes(A,NumLocRows,NumLocCols,PETSC_DETERMINE,PETSC_DETERMINE); >> MatSetType(A,MATMPIAIJ); >> MatMPIAIJSetPreallocation(A,PETSC_NULL,nnz,PETSC_NULL,onz); >> MatSetValues(...); >> MatAssemblyBegin(...) >> MatAssemblyEnd(...) >> and then a call to MatMatMultSymbolic. >> I want the result matrix to be created. In the documentation I see, that >> this happens, if I pass MAT_REUSE_MATRIX as scall, but how can I pass the >> value, I don't the parameter. >> Where can I find an example for MatMatMultSymbolic / MatMatMultNumeric? >> Thanks, >> Hannes > >
