<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial"><DIV>Hello,</DIV>
<DIV> I have tried AMG, but there are some problems. I use the command:<BR> mpiexec -n 4 ./ex4f -ksp_type gmres -pc_type gamg -pc_gamg_agg_nsmooths 1 -ksp_gmres_restart 170 -ksp_rtol 1.0e-15 -ksp_converged_reason.<BR> The matrix has a size of 30000. However, compared with -pc_type asm,<BR>the amg need more time:asm needs 4.9s, amg needs 13.7s. I did several tests<BR>and got the same conclusion. When it begins, the screen shows the information: <BR>[0]PCSetData_AGG bs=1 MM=7601. I do not know the meaning. And if there is some<BR>parameters that affect the performance of AMG?<BR> Besides, I want to confirm a conception. In my view, AMG itself can be a solver<BR>like gmres. It can also be used as a preconditioner like jacobi and is used by combining<BR>with other solver. Is it right? If it is right, how use AMG solver?<BR> My codes are attached.<BR> Thanks.<BR>
Jim</DIV>
<DIV><BR>-----------codes------------------------------------------<BR> call MatCreate(PETSC_COMM_WORLD,A,ierr)<BR> call MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,m,n,ierr)<BR> call MatSetType(A, MATMPIAIJ,ierr)<BR> call MatSetFromOptions(A,ierr)<BR>!premalloc<BR> !find the max non-zero numbers of all rows<BR> maxnonzero=0<BR> do 19,II=1,m<BR> !no-zero numbers of this row<BR> maxnonzeroII=NROWIN(II+1)-NROWIN(II)<BR> if (maxnonzeroII>maxnonzero) then<BR> maxnonzero=maxnonzeroII<BR> endif<BR> 19 continue<BR> &nbs
p; call MatMPIAIJSetPreallocation(A,maxnonzero,PETSC_NULL_INTEGER,<BR> & maxnonzero,PETSC_NULL_INTEGER,ierr)</DIV>
<DIV> call MatGetOwnershipRange(A,Istart,Iend,ierr)<BR>!set values per row<BR> do 10,II=Istart+1,Iend<BR> !no-zero numbers of this row<BR> rowNum=NROWIN(II+1)-NROWIN(II)<BR> <BR> allocate(nColPerRow(rowNum))<BR> allocate(valuePerRow(rowNum))<BR> <BR> kValStart=NROWIN(II)+1-1<BR> kValEnd=NROWIN(II)+rowNum-1<BR> <BR> !column index<BR> nColPerRow=NNZIJ(kValStart:kValEnd)-1<BR> valuePerRow=VALUE(kValStart:kValEnd)<BR>&nb
sp; nRow=II-1<BR> call MatSetValues(A,ione,nRow,rowNum,nColPerRow,valuePerRow,<BR> & INSERT_VALUES,ierr)<BR> deallocate(nColPerRow)<BR> deallocate(valuePerRow)<BR> 10 continue<BR> call MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY,ierr)<BR> call MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY,ierr)<BR> call VecCreateMPI(PETSC_COMM_WORLD,PETSC_DECIDE,m,b,ierr)<BR> call VecSetFromOptions(b,ierr)<BR> call VecDuplicate(b,u,ierr)<BR> call VecDuplicate(b,x,ierr)<BR> call KSPCreate(PETSC_COMM_WORLD,ksp,ierr)<BR> call KSPSetOperators(ksp,A,A,DIF
FERENT_NONZERO_PATTERN,ierr)<BR> call PetscOptionsHasName(PETSC_NULL_CHARACTER,'-my_ksp_monitor', &<BR> & flg,ierr)<BR> if (flg) then<BR> call KSPMonitorSet(ksp,MyKSPMonitor,PETSC_NULL_OBJECT, &<BR> & PETSC_NULL_FUNCTION,ierr)<BR> endif<BR> call KSPSetFromOptions(ksp,ierr)<BR> call PetscOptionsHasName(PETSC_NULL_CHARACTER,
&<BR> & '-my_ksp_convergence',flg,ierr)<BR> if (flg) then<BR> call KSPSetConvergenceTest(ksp,MyKSPConverged, &<BR> & PETSC_NULL_OBJECT,PETSC_NULL_FUNCTION,ierr)<BR> endif<BR> !Assing values to 'b'<BR> bTemp=Iend-Istart<BR> ioneb=1<BR> <BR> do 12,II=Istart,Iend-1<BR> voneb=F(II+1)<BR> call VecSetValues(b,ioneb,II,voneb,INSERT_VALUES,ierr)<BR> 12 continue
</DIV>
<DIV> call VecAssemblyBegin(b,ierr)<BR> call VecAssemblyEnd(b,ierr)<BR> call KSPSolve(ksp,b,x,ierr)<BR>------codes-------------------------------------------------</DIV>
<DIV> </DIV>
<DIV><BR><BR><BR><BR><BR><BR> </DIV>
<DIV></DIV>
<DIV id="divNeteaseMailCard"></DIV>
<DIV><BR></DIV>>At 2012-11-01 22:00:28,"Jed Brown" <jedbrown@mcs.anl.gov> wrote:<BR>
<BLOCKQUOTE style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" id="isReplyContent">
<DIV class="gmail_extra">>Yes, it's faster to understand this error message than to have "mysteriously slow performance".</DIV>
<DIV class="gmail_extra"><BR></DIV>
<DIV class="gmail_extra">><EM>* Preallocation routines now automatically set MAT_NEW_NONZERO_ALLOCATION_ERR, if you intentionally preallocate less than necessary then </EM>><EM>use MatSetOption(mat,MAT_NEW_NONZERO_ALLOCATION_ERR,PETSC_FALSE) to disable the error generation.<BR></EM><BR>><A href="http://www.mcs.anl.gov/petsc/documentation/changes/33.html">http://www.mcs.anl.gov/petsc/documentation/changes/33.html</A><BR><BR>
<DIV class="gmail_quote">>On Thu, Nov 1, 2012 at 8:57 AM, w_ang_temp <SPAN dir="ltr"><<A href="mailto:w_ang_temp@163.com" target="_blank">w_ang_temp@163.com</A>></SPAN> wrote:<BR>
<BLOCKQUOTE style="BORDER-LEFT: rgb(204,204,204) 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<DIV>>Do you mean that the two versions have a different in this point? If I use the new version, I have to</DIV>
<DIV>>make some modifications on my codes?</DIV></BLOCKQUOTE></DIV><BR></DIV></BLOCKQUOTE></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>