about Jed's changes to MatGetSubMatrix

Jed Brown jed at 59A2.org
Fri Jun 5 05:18:30 CDT 2009

Lisandro Dalcin wrote:
> On Thu, Jun 4, 2009 at 8:16 PM, Jed Brown <jed at 59a2.org> wrote:

>> We could create a new one if it doesn't exist, even with
>> MAT_REUSE_MATRIX, but that feels wrong to me.
> Why do you have such feeling?

Suppose I run with -log_summary and see that most of my memory usage is
for matrices (typical).  I want to know how many "big" matrices are
around and I don't expect MAT_REUSE_MATRIX to be allocating memory of
the same size as the matrices I can see.  So I'd rather see an error
than confusing space usage, but I could be convinced otherwise
particularly if you have a use case where it is important/useful.

>> Implementation is trivial, but I think it's likely to be confusing
>> and it becomes more difficult to give meaningful error messages.
>> What do you think?
> Why do you think it is confusing?

Confusing only when trying to account for space usage.  It takes some
work to determine that the matrix to be reused is correctly preallocated
so we either have to do this or accept a less useful error message.

> As long as the reuse submat has a proper parallel layout (after a fast
> look, it seems you do not even have constraints on nonzero pattern),
> the call would work.

MatZeroEntries doesn't reset the column indices so we are expecting the
same nonzero pattern.  That could be done too, but since we're creating
a whole new intermediate matrix anyway, why not remove this limitation
and preallocate all over again?

I see two meanings for MAT_REUSE_MATRIX:

1. Everything "big" is preallocated, use these data structures.  Total
memory use will not change much in this call.

2. All manner of allocation is okay, but references to the original
matrix remain valid.

The distinction is purely a matter of operational semantics.  In HLLs,
it is natural to only consider denotational semantics (until forced
otherwise).  I think there is value in having the stronger (1) but I
understand that this could be surprising from a HLL.  Should MatReuse
have purely denotational meaning?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20090605/07e36599/attachment.sig>

More information about the petsc-dev mailing list