[petsc-users] choosing MatSetValue or MatSetValues

Jed Brown jed at 59A2.org
Thu Mar 11 10:50:06 CST 2010


On Thu, 11 Mar 2010 11:34:31 -0500, John-Michael Fischer <fischej at umich.edu> wrote:
> I need some help in determining the extent of the benefit when doing dense matrix insertions.
> 
> Essentially, in our software we need every last byte of memory we can get, and I wanted to get some feedback on how much slower it would be when building a dense matrix to use different insertion methods.
> Option A: 
> Use MatSetValue for every datapoint.
> Option B: 
> Store some amount of values locally in an array as they are generated (which would take up extra memory), say 1024, then using MatSetValues to insert them over several sweeps of local generation.

Why is memory so extremely tight?  Is this some sort of embedded
application?  Inserting, a few (say 8) values at a time will give you
most of the benefit of operating in chunks, you don't have to insert
entire rows at once to get a speedup.  Are you working in parallel?  For
sequential dense matrices, it's also reasonable to just get the array
and index directly into it.

Jed


More information about the petsc-users mailing list