[petsc-users] efficiency of MatSetValues
Jed Brown
jedbrown at mcs.anl.gov
Fri Feb 3 16:41:39 CST 2012
On Sat, Feb 4, 2012 at 01:35, Margarita Satraki <margarita.satraki at gmail.com
> wrote:
> It seems that only the 1st case gives good results in the sense that by
> increasing the size of the matrix you increase the time needed by
> MatSetValues linearly. Both the 2nd and the 3rd case give similar results,
> much worse than the 1st. I understand that the 1st case has the advantage
> because of accurate memory allocation but shouldn't the 2ndcase be better
> than the 3rd since it at least defines the number of nonzeros per row so it
> again allocates memory more accurately?
Those nonzeros are in the wrong place and PETSc does not know that you want
to "delete" the old entries.
Just preallocate the correct number of nonzeros and it will be fast, don't
bother with copying in a "similar" matrix.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120204/d3c4cb11/attachment.htm>
More information about the petsc-users
mailing list