[petsc-users] efficiency of MatSetValues
Margarita Satraki
margarita.satraki at gmail.com
Fri Feb 3 16:41:12 CST 2012
Hello,
I'm a bit confused regarding the efficiency of MatSetValues in Petsc and I
was hoping for some help. I'm using Petsc 3.2-p6 on Fedora11.
I'm attaching a simple code that displays the time needed for some simple
cases using MatSetValues.
1st case: The matrix is composed by copying a different matrix and then
MatSetValues is used to insert elements at the same nonzero pattern
(diagonal) as the initial matrix (with defining the number of nonzeros per
row).
2nd case: The matrix is composed by copying a different matrix and then
MatSetValues is used to insert elements at a different nonzero pattern than
the initial matrix (diagonal-1st off diagonal) (with defining the number of
nonzeros per row).
3rd case: Same as 2nd but without defining the number of nonzeros per row.
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?
Many thanks for any help,
Margarita
///////////////////////////////////////////////////////
DPhil candidate
University of Oxford
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120203/86feb24f/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: time.cpp
Type: text/x-c++src
Size: 3665 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120203/86feb24f/attachment.cpp>
More information about the petsc-users
mailing list