<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial, helvetica, sans-serif;font-size:12pt"><div><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 13px;"><font class="Apple-style-span" size="4"><span class="Apple-style-span" style="font-size: 16px;">Hi Jed,</span></font></span></font></div><div>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: </div><div><br></div><div><div> ierr = MatSetValuesStencil(B,7,row,7,col,&val[0][0],INSERT_VALUES);CHKERRQ(ierr);</div><div>The same with the </div><div> ierr = MatSetValuesBlockedStencil(B,7,row,7,col,&val[0][0],INSERT_VALUES);CHKERRQ(ierr);</div></div><div style="font-family:arial, helvetica, sans-serif;font-size:12pt"><div style="font-family:arial, helvetica,
sans-serif;font-size:10pt">(total time=1e1) (here row is same as col)</div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt"><br></div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt">Now since </div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt"><span class="Apple-style-span" style="font-size: 16px; "> ierr = MatSetValuesStencil(B,1,&row,7,col,&val[0][0],INSERT_VALUES);CHKERRQ(ierr); </span></div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt">is very fast (total time=1e-2) (here row=(i,j,k))</div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt"><br></div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt">I tried to call it 7 times </div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt"><div style="font-family:arial, helvetica, sans-serif;font-size:10pt">for(l=0;l<7;l++){</div><div
style="font-family:arial, helvetica, sans-serif;font-size:10pt"> ierr = MatSetValuesBlockedStencil(B,1,&row[l],7,col,&val[0][0],INSERT_VALUES);CHKERRQ(ierr);}</div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt">}</div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt">is again slow (total time=1e1) </div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt"><br></div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt"> 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</div><div style="font-family:arial, helvetica,
sans-serif;font-size:10pt"> MatSetValuesBlockedStencil(B,1,&row[l],7,col,&val[0][0],INSERT_VALUES);CHKERRQ(ierr);}</div><div>to be slower by 2 orders of magnitude. Could you please suggest why the performance goes down so drastically. </div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt"><br></div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt">The difference in performance becomes visible when the matrix size gets closer to 3000X3000 and becomes worse very fast. </div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt"><br></div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt">I want to assemble a matrix for FEM application. I started from the example ksp/ksp/examples/tutorials/ex3.c</div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt">This example shows the similar problem stated above when m>=120. </div><div
style="font-family:arial, helvetica, sans-serif;font-size:10pt"><br></div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt">Please let me know what could be done for any/both of the above two problems. </div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt"><br></div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt">Best regards.</div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt"><br></div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt">Khalid </div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt"><br></div></div><div style="font-family:arial, helvetica, sans-serif;font-size:10pt">On Thu, Jun 16, 2011 at 11:14, khalid ashraf <<a ymailto="mailto:khalid_eee@yahoo.com" href="mailto:khalid_eee@yahoo.com">khalid_eee@yahoo.com</a>> wrote:<br><br>> When I look at the breakdown of the stages time required, the total add
up<br>> to ~7s however, the main stage time is ~350s.<br><br><br>Two possibilities:<br><br>1. The time is not in PETSc.<br><br>2. The matrix is not preallocated correctly.<br><br><span><a target="_blank" href="http://www.mcs.anl.gov/petsc/petsc-as/documentation/faq.html#efficient-assembly">http://www.mcs.anl.gov/petsc/petsc-as/documentation/faq.html#efficient-assembly</a></span><br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br><span>URL: <<a target="_blank" href="http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110616/c512cdaa/attachment-0001.htm">http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110616/c512cdaa/attachment-0001.htm</a>></span><br><br><br></div></div><div style="position:fixed"></div>
</div></body></html>