[petsc-users] profiling the total time

khalid ashraf khalid_eee at yahoo.com
Tue Jun 21 00:34:47 CDT 2011

```Hi Jed,
In order to find where the extra time is consumed, I started from
ksp/ksp/example/tutorials/ex22.c and changed it one line at a time. I found that
the time is consumed in the call:

ierr =
MatSetValuesStencil(B,7,row,7,col,&val[0][0],INSERT_VALUES);CHKERRQ(ierr);
The same with the
ierr =
MatSetValuesBlockedStencil(B,7,row,7,col,&val[0][0],INSERT_VALUES);CHKERRQ(ierr);

(total time=1e1) (here row is same as col)

Now since
ierr =
MatSetValuesStencil(B,1,&row,7,col,&val[0][0],INSERT_VALUES);CHKERRQ(ierr);
is very fast (total time=1e-2) (here row=(i,j,k))

I tried to call it 7 times
for(l=0;l<7;l++){
ierr =
MatSetValuesBlockedStencil(B,1,&row[l],7,col,&val[0][0],INSERT_VALUES);CHKERRQ(ierr);}

}
is again slow (total time=1e1)

This is because I expected the computation time to be 7*1e-2 by this
repetitive call. However, I find that the execution time is ~1e-2 only for l=3.
For any other value of l, it is ~1e0. I can see that the only speciality of l=3
is that it corresponds to row=(i,j,k). Any other combination like (i+1,j,k)
causes the call to
MatSetValuesBlockedStencil(B,1,&row[l],7,col,&val[0][0],INSERT_VALUES);CHKERRQ(ierr);}

to be slower by 2 orders of magnitude. Could you please suggest why the
performance goes down so drastically.

The difference in performance becomes visible when the matrix size gets closer
to 3000X3000 and becomes worse very fast.

I want to assemble a matrix for FEM application. I started from the example
ksp/ksp/examples/tutorials/ex3.c
This example shows the similar problem stated above when m>=120.

Please let me know what could be done for any/both of the above two problems.

Best regards.

Khalid

On Thu, Jun 16, 2011 at 11:14, khalid ashraf <khalid_eee at yahoo.com> wrote:

> When I look at the breakdown of the stages time required, the total add up
> to ~7s however, the main stage time is ~350s.

Two possibilities:

1. The time is not in PETSc.

2. The matrix is not preallocated correctly.

http://www.mcs.anl.gov/petsc/petsc-as/documentation/faq.html#efficient-assembly
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110616/c512cdaa/attachment-0001.htm>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110620/fe94c79e/attachment.htm>
```