[petsc-dev] Meaning of PETSc matrices with zero rows but nonzero columns?

Stefano Zampini stefano.zampini at gmail.com
Sat May 30 16:59:02 CDT 2020


And MKL has the same issues for dense , see for example here https://gitlab.com/petsc/petsc/-/blob/master/src/mat/impls/dense/seq/dense.c#L2186 <https://gitlab.com/petsc/petsc/-/blob/master/src/mat/impls/dense/seq/dense.c#L2186>
If A is 0x8 and B is 8x5 then C is correct to be of size 0x5. The rows and columns of the resulting matrix have to follow the rules.


> On May 31, 2020, at 12:54 AM, Mark Adams <mfadams at lbl.gov> wrote:
> 
> Failing for empty matrices sucks of MKL.
> I don't know of any reason that we care how many columns are in a matrix with no rows. I see no reason not to let it stay the way it is, that is with the number of columns that it should have if it had rows.
> I would vote for just doing what you need to do to get the test suite to pass and have a MKL test with zero rows. 
> A GAMG test should give you an empty local marix on the coarse grid on rank != 0.
> 
> On Sat, May 30, 2020 at 2:07 PM Mills, Richard Tran via petsc-dev <petsc-dev at mcs.anl.gov <mailto:petsc-dev at mcs.anl.gov>> wrote:
> All,
> 
> I'm working on adding support for matrix products to AIJMKL, and I'm uncertain about some issues surrounding empty matrices. PETSc will happily let me multiply an empty matrix with another (and this arises in the sequential matrix-matrix multiplication routines when running with multiple MPI ranks and using MPIAIJ), but MKL does not like empty matrices (or matrices with no nonzeros), so I've got code in various places in the existing AIJMKL routines to handle these cases without calling MKL.
> 
> I'm not quite sure what needs to be done in, say, MatMatMultSymbolic_SeqAIJMKL_SeqAIJMKL(). In the SeqAIJ version, if a matrix A is passed in that has zero rows (that is, A->rmap->N = 0), and matrix B has N columns (B->cmap->N = N), then a matrix C with zero rows and N columns is created. My question boils down to "Does it mean anything in PETSc to have a matrix with 0 rows but a nonzero number of columns"? It is less complicated if I handle the empty matrix cases by creating a matrix with 0 rows and 0 columns, but I am not sure if this breaks something. (I'm also not sure what a "matrix" with 0 rows even means.) Also not sure if there is any other info that I need to preserve in the result matrix C, of if it is OK to handle the case of any empty A or B by always producing the same empty matrix C.
> 
> --Richard

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20200531/a879480a/attachment.html>


More information about the petsc-dev mailing list