<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I made a change: ierr = MatCreateSeqAIJ(PETSC_COMM_SELF,N,N,5,PETSC_NULL,&amp;J);CHKERRQ(ierr);<div><br></div><div>Time of the code did not change much, and got the info:</div><div><div>Matrix Object:</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;type=seqaij, rows=1830, cols=1830</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;total: nonzeros=1830, allocated nonzeros=36600</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;total number of mallocs used during MatSetValues calls =1830</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;not using I-node routines</div><div><br></div></div><div><br></div><div><br><div><div>On Jul 7, 2010, at 12:51 PM, Satish Balay wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;total: nonzeros=1830, allocated nonzeros=29280<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;total number of mallocs used during MatSetValues calls =1830<br></blockquote><br>There is something wrong with your preallocation or matrix<br>assembly. You should see zero mallocs for efficient assembly.<br><br><a 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><br><br>satish<br><br><br>On Wed, 7 Jul 2010, Xuan YU wrote:<br><br><blockquote type="cite">Hi,<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I finite difference Jacobian approximation for my TS model. The size of the<br></blockquote><blockquote type="cite">vector is 1830. I got the following info with(-ts_view):<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">type: beuler<br></blockquote><blockquote type="cite"> maximum steps=50<br></blockquote><blockquote type="cite"> maximum time=50<br></blockquote><blockquote type="cite"> total number of nonlinear solver iterations=647<br></blockquote><blockquote type="cite"> total number of linear solver iterations=647<br></blockquote><blockquote type="cite"> SNES Object:<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;type: ls<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;line search variant: SNESLineSearchCubic<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;alpha=0.0001, maxstep=1e+08, minlambda=1e-12<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;maximum iterations=50, maximum function evaluations=10000<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;tolerances: relative=1e-08, absolute=1e-50, solution=1e-08<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;total number of linear solver iterations=50<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;total number of function evaluations=51<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;KSP Object:<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;type: gmres<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GMRES: restart=30, using Classical (unmodified) Gram-Schmidt<br></blockquote><blockquote type="cite">Orthogonalization with no iterative refinement<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GMRES: happy breakdown tolerance 1e-30<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;maximum iterations=10000, initial guess is zero<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;tolerances: &nbsp;relative=1e-05, absolute=1e-50, divergence=10000<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;left preconditioning<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;using PRECONDITIONED norm type for convergence test<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;PC Object:<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;type: ilu<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ILU: out-of-place factorization<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0 levels of fill<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tolerance for zero pivot 1e-12<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;using diagonal shift to prevent zero pivot<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;matrix ordering: natural<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;factor fill ratio given 1, needed 1<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Factored matrix follows:<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Matrix Object:<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type=seqaij, rows=1830, cols=1830<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;package used to perform factorization: petsc<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;total: nonzeros=1830, allocated nonzeros=1830<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;total number of mallocs used during MatSetValues calls =0<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;not using I-node routines<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;linear system matrix = precond matrix:<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;Matrix Object:<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type=seqaij, rows=1830, cols=1830<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;total: nonzeros=1830, allocated nonzeros=29280<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;total number of mallocs used during MatSetValues calls =1830<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;not using I-node routines<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">50 output time step takes me 11.877s. So I guess there is something not<br></blockquote><blockquote type="cite">appropriate with my Jacobian Matrix. Could you please tell me how to speed up<br></blockquote><blockquote type="cite">my code?<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Thanks!<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Xuan YU<br></blockquote><blockquote type="cite">xxy113@psu.edu<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><br><br></div></blockquote></div><br><div apple-content-edited="true"> <div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Xuan YU (<span class="Apple-style-span" style="font-family: arial; font-size: 16px; white-space: pre; ">俞烜<span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; white-space: normal; ">)</span></span></div><div><a href="mailto:xxy113@psu.edu">xxy113@psu.edu</a></div><div><br></div></div><br class="Apple-interchange-newline"></div><br class="Apple-interchange-newline"> </div><br></div></body></html>