<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,&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> type=seqaij, rows=1830, cols=1830</div><div> total: nonzeros=1830, allocated nonzeros=36600</div><div> total number of mallocs used during MatSetValues calls =1830</div><div> 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"> total: nonzeros=1830, allocated nonzeros=29280<br></blockquote><blockquote type="cite"> 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"> type: ls<br></blockquote><blockquote type="cite"> line search variant: SNESLineSearchCubic<br></blockquote><blockquote type="cite"> alpha=0.0001, maxstep=1e+08, minlambda=1e-12<br></blockquote><blockquote type="cite"> maximum iterations=50, maximum function evaluations=10000<br></blockquote><blockquote type="cite"> tolerances: relative=1e-08, absolute=1e-50, solution=1e-08<br></blockquote><blockquote type="cite"> total number of linear solver iterations=50<br></blockquote><blockquote type="cite"> total number of function evaluations=51<br></blockquote><blockquote type="cite"> KSP Object:<br></blockquote><blockquote type="cite"> type: gmres<br></blockquote><blockquote type="cite"> GMRES: restart=30, using Classical (unmodified) Gram-Schmidt<br></blockquote><blockquote type="cite">Orthogonalization with no iterative refinement<br></blockquote><blockquote type="cite"> GMRES: happy breakdown tolerance 1e-30<br></blockquote><blockquote type="cite"> maximum iterations=10000, initial guess is zero<br></blockquote><blockquote type="cite"> tolerances: relative=1e-05, absolute=1e-50, divergence=10000<br></blockquote><blockquote type="cite"> left preconditioning<br></blockquote><blockquote type="cite"> using PRECONDITIONED norm type for convergence test<br></blockquote><blockquote type="cite"> PC Object:<br></blockquote><blockquote type="cite"> type: ilu<br></blockquote><blockquote type="cite"> ILU: out-of-place factorization<br></blockquote><blockquote type="cite"> 0 levels of fill<br></blockquote><blockquote type="cite"> tolerance for zero pivot 1e-12<br></blockquote><blockquote type="cite"> using diagonal shift to prevent zero pivot<br></blockquote><blockquote type="cite"> matrix ordering: natural<br></blockquote><blockquote type="cite"> factor fill ratio given 1, needed 1<br></blockquote><blockquote type="cite"> Factored matrix follows:<br></blockquote><blockquote type="cite"> Matrix Object:<br></blockquote><blockquote type="cite"> type=seqaij, rows=1830, cols=1830<br></blockquote><blockquote type="cite"> package used to perform factorization: petsc<br></blockquote><blockquote type="cite"> total: nonzeros=1830, allocated nonzeros=1830<br></blockquote><blockquote type="cite"> total number of mallocs used during MatSetValues calls =0<br></blockquote><blockquote type="cite"> not using I-node routines<br></blockquote><blockquote type="cite"> linear system matrix = precond matrix:<br></blockquote><blockquote type="cite"> Matrix Object:<br></blockquote><blockquote type="cite"> type=seqaij, rows=1830, cols=1830<br></blockquote><blockquote type="cite"> total: nonzeros=1830, allocated nonzeros=29280<br></blockquote><blockquote type="cite"> total number of mallocs used during MatSetValues calls =1830<br></blockquote><blockquote type="cite"> 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>