[petsc-users] Unreproducible number of iterations for consecutives solves (GCR + ML)

Jed Brown jedbrown at mcs.anl.gov
Thu Jun 27 11:13:44 CDT 2013


Karl Rupp <rupp at mcs.anl.gov> writes:

> Thus, it seems that there is a little share of randomness involved, 
> which may only be significant when the solver needs to run a large 
> number of iterations. So, the fluctuation of iterations when using ML 
> does not seem to be something you need to be worried about.

Yes, ML has some randomness.  It sets a deterministic seed so the first
solve is reproducible, but multiple solves will vary some:

diff --git i/src/ksp/ksp/examples/tutorials/ex56.c w/src/ksp/ksp/examples/tutorials/ex56.c
index 91fad9d..fa8860c 100644
--- i/src/ksp/ksp/examples/tutorials/ex56.c
+++ w/src/ksp/ksp/examples/tutorials/ex56.c
@@ -284,7 +284,7 @@ int main(int argc,char **args)
     PetscReal emax, emin;
     ierr = MaybeLogStagePush(stage[2]);CHKERRQ(ierr);
     /* PC setup basically */
-    ierr = MatScale(Amat, 100000.0);CHKERRQ(ierr);
+    //ierr = MatScale(Amat, 100000.0);CHKERRQ(ierr);
     ierr = KSPSetOperators(ksp, Amat, Amat, SAME_NONZERO_PATTERN);CHKERRQ(ierr);
     ierr = KSPSetUp(ksp);CHKERRQ(ierr);
 
@@ -297,7 +297,7 @@ int main(int argc,char **args)
     ierr = MaybeLogStagePush(stage[4]);CHKERRQ(ierr);
 
     /* 3rd solve */
-    ierr = MatScale(Amat, 100000.0);CHKERRQ(ierr);
+    //ierr = MatScale(Amat, 100000.0);CHKERRQ(ierr);
     ierr = KSPSetOperators(ksp, Amat, Amat, SAME_NONZERO_PATTERN);CHKERRQ(ierr);
     ierr = KSPSetUp(ksp);CHKERRQ(ierr);
 
$ mpiexec -n 8 ./ex56 -ne 19 -alpha 1.e-3 -ksp_monitor -ksp_type cg -ksp_max_it 50 -pc_type ml -ksp_converged_reason -mg_levels_ksp_type chebyshev -mg_levels_ksp_chebyshev_estimate_eigenvalues 0,0.05,0,1.05 -mg_levels_pc_type jacobi -two_solves -ksp_norm_type unpreconditioned
  0 KSP Residual norm 3.916254888964e+00 
  1 KSP Residual norm 2.881812838115e+01 
  2 KSP Residual norm 1.275966743250e+01 
  3 KSP Residual norm 4.773599170045e+00 
  4 KSP Residual norm 1.935268484585e+00 
  5 KSP Residual norm 4.209580628708e-01 
  6 KSP Residual norm 8.134351555855e-02 
  7 KSP Residual norm 2.105221695641e-02 
  8 KSP Residual norm 6.251570402725e-03 
  9 KSP Residual norm 1.693062086081e-03 
 10 KSP Residual norm 4.088111376292e-04 
 11 KSP Residual norm 8.282470497154e-05 
 12 KSP Residual norm 2.910468516666e-05 
Linear solve converged due to CONVERGED_RTOL iterations 12
  0 KSP Residual norm 3.916254888964e+00 
  1 KSP Residual norm 2.884447434423e+01 
  2 KSP Residual norm 1.279637972963e+01 
  3 KSP Residual norm 4.778606784425e+00 
  4 KSP Residual norm 1.945306501447e+00 
  5 KSP Residual norm 4.252458287438e-01 
  6 KSP Residual norm 8.200469618341e-02 
  7 KSP Residual norm 2.128564125382e-02 
  8 KSP Residual norm 6.325422255484e-03 
  9 KSP Residual norm 1.722774707230e-03 
 10 KSP Residual norm 4.155306725796e-04 
 11 KSP Residual norm 8.432468795266e-05 
 12 KSP Residual norm 2.965043662043e-05 
Linear solve converged due to CONVERGED_RTOL iterations 12
  0 KSP Residual norm 3.916254888964e+00 
  1 KSP Residual norm 2.884581541125e+01 
  2 KSP Residual norm 1.281469034767e+01 
  3 KSP Residual norm 4.787719947229e+00 
  4 KSP Residual norm 1.954021039200e+00 
  5 KSP Residual norm 4.286214813381e-01 
  6 KSP Residual norm 8.267288000027e-02 
  7 KSP Residual norm 2.150072898753e-02 
  8 KSP Residual norm 6.392547836067e-03 
  9 KSP Residual norm 1.749098960784e-03 
 10 KSP Residual norm 4.214004987050e-04 
 11 KSP Residual norm 8.561869518870e-05 
 12 KSP Residual norm 3.013123608130e-05 
Linear solve converged due to CONVERGED_RTOL iterations 12
[0]main |b-Ax|/|b|=7.693890e-06, |b|=3.916255e+00, emax=9.962246e-01
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130627/f97fbaff/attachment-0001.pgp>


More information about the petsc-users mailing list