> On Aug 1, 2017, at 1:53 AM, Jed Brown <[email protected]> wrote:
>
> Richard Tran Mills <[email protected]> writes:
>
>> Hi Folks,
>>
>> I am still slogging away at debugging my AIJMKL matrix class using the
>> PETSc test suite. In some cases, such as mat/examples/tests/ex160.c, I am
>> seeing a failure of the mkl_sparse_optimize() call inside MatAssembly.
>> Digging into this, it appears that the problem is that the A array (the
>> nonzero values) for the matrix is NULL -- understandably,
>> mkl_sparse_optimize() does not like this. I've verified that this isn't due
>> to some bug my matrix class has introduced, as running the same example
>> with just plain SeqAIJ matrices and stepping through it with the debugger,
>> I still see the same NULL value for A.
>>
>> I am assuming that this is intended behavior, and what one might expect if
>> one, say, calls MatAssemblyBegin/End without ever doing an MatSetValues?
>> Looks like I need to simply check to see if A is NULL and not do the
>> mkl_sparse_optimize() step if so. I already had a check in there for a
>> matrix with no columns, as I believe I encountered that case (but with A
>> pointing to allocated memory).
This is just a matrix with 32 rows and 32 columns and absolutely no nonzero
entries. You should be able to pass this off to mkl_sparse_optimize()
and since there are no entries it should never access the a->j or a->a array
and run correctly. Perhaps they have incorrect error checking that cannot
handle an empty matrix? You should report this as a bug to them (lots of people
forget the empty matrix case and have crashes etc that shouldn't happen).
If they don't handle the empty matrix case problem then Jed is right you
should detect this by using !a->nz
Barry
>> (And maybe I should check for a matrix with
>> no rows?) Are these the things I should be testing for, or is there
>> something nicer that I should be checking to see if the matrix to be
>> "assembled" doesn't actually consist of any matrix?
>
> nnz=0?
>
> I hate to depend on malloc(0) and the like returning NULL.