1. <b>Always</b> send -log_summary when asking about performance.<div>2. AMG setup costs more, the solve should be faster, especially for large problems.</div><div>3. 30k degrees of freedom is not large.</div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Sat, Nov 3, 2012 at 10:27 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 class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="line-height:1.7;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></div>
<div><br></div>>At 2012-11-01 22:00:28,"Jed Brown" <<a href="mailto:jedbrown@mcs.anl.gov" target="_blank">jedbrown@mcs.anl.gov</a>> wrote:<br>
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex">
<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" target="_blank">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></span></span></blockquote></div><br></div>