Count Iteration Vectors

From ScorecWiki

Jump to: navigation, search

This is a tutorial on how to count number of vector iterations (CG & GMRES) for a given PHASTA simulation. Basically you need the histor.dat file or the output log file (file_name.o*) if running on a parallel computer. An example histor.dat file looks like this:

    1 8.868E+00 1.012E+00  (   0)   7.940E+01   2.860E+28  <   145-  35|  18> [ 331 -  75]
    1 1.063E+01 2.221E+00  (   3)   4.257E-01   4.688E-01  <   400-  43|  16> [ 183 -  15]
    1 1.143E+01 1.224E+00  (   0)   1.163E-01   1.220E-01  <   413-  43|  17> [  44 -  12]
    1 1.238E+01 8.711E-01  (   0)   4.206E-02   3.971E-02  <   189-  48|  17> [  63 -  16]
    1 1.377E+01 3.202E-01  (  -4)   1.792E-02   1.284E-02  <   460-  48|  16> [ 128 -  20]
    2 1.478E+01 2.331E+02  (  23)   1.045E-01   1.132E+00  <    58-  48|  11> [  67 -  10]
    2 1.577E+01 6.989E+00  (   8)   2.628E-02   1.466E-01  <    58-  48|  15> [  46 -  10]
    2 1.678E+01 7.657E-01  (  -1)   1.032E-02   8.964E-02  <   413-  43|  16> [  75 -  10]
    2 1.751E+01 2.928E-01  (  -5)   4.848E-03   4.569E-02  <   413-  43|  18> [  48 -  12]
    2 1.872E+01 1.270E-01  (  -9)   2.098E-03   2.176E-02  <   400-  43|  16> [  61 -  13]
    3 1.952E+01 4.506E+01  (  16)   7.446E-02   1.945E+00  <    58-  48|  13> [  47 -  10]
    3 2.050E+01 1.661E+00  (   2)   8.796E-03   4.309E-02  <    58-  48|  16> [  49 -  10]
    3 2.164E+01 3.216E-01  (  -4)   3.061E-03   4.613E-03  <   112-  48|  15> [  63 -  10]
    3 2.232E+01 1.211E-01  (  -9)   1.512E-03   1.860E-03  <   460-  48|  16> [  30 -  10]
    3 2.316E+01 5.370E-02  ( -12)   7.529E-04   1.030E-03  <   460-  48|  16> [  44 -  10]
    4 2.438E+01 1.310E+01  (  11)   6.281E-02   1.097E-01  <   569-  43|  13> [  45 -  10]
    4 2.494E+01 5.189E-01  (  -2)   5.964E-03   1.755E-02  <   413-  43|  16> [  40 -  10]
    4 2.591E+01 1.764E-01  (  -7)   2.277E-03   7.076E-03  <   413-  43|  15> [  35 -  10]
    4 2.641E+01 6.626E-02  ( -11)   1.044E-03   2.870E-03  <    83-  48|  16> [  38 -  13]
    4 2.752E+01 2.497E-02  ( -16)   4.370E-04   8.437E-04  <   109-  48|  15> [  35 -  14]
    5 2.853E+01 1.252E+01  (  10)   5.325E-02   8.391E-02  <   100-  14|  11> [  40 -  10]
    5 2.927E+01 3.578E-01  (  -4)   5.062E-03   3.268E-02  <   249-  48|  15> [  35 -  11]
    5 3.020E+01 1.169E-01  (  -9)   1.797E-03   1.177E-02  <   413-  43|  16> [  26 -  11]
    5 3.074E+01 4.546E-02  ( -13)   7.936E-04   4.972E-03  <    83-  48|  17> [  33 -  12]
    5 3.176E+01 1.911E-02  ( -17)   3.773E-04   1.683E-03  <   109-  48|  15> [  41 -  13]

The last two rows represent the GS & GMRES vector iterations. In order to calculate the total amount of iterations for a given run do the following:

awk '{print $13, $15}' histor.dat |sed -e 's/\]//g' |awk '{s+=$1}{t+=$2}{print s,t}'

For this example the output of the command above is

331 75
514 90
558 102
621 118
749 138
816 148
862 158
937 168
985 180
1046 193
1093 203
1142 213
1205 223
1235 233
1279 243
1324 253
1364 263
1399 273
1437 286
1472 300
1512 310
1547 321
1573 332 
1606 344
1647 357
1647 357

The last line shows the total GS & GMRES iterations. Therefore, for this example the total GS & GMRES iterations are 1647 and 357 respectively.

If you decide to use the output log file (file_name.o*) from running on parallel, it contains certain information (ex. solver.inp) above the output from PHASTA. An example file can look like this:

Time derivative of solution is set to zero (SAFE)                                                                        
                                                                               
Element block size =           64
Domain size (x,y,z):     7.6697319335   8.2397687480  23.3514959233
Total number of modes =        45175
necessary bct timing: from   0.000000000000000E+000  to 
  3.81063500000000     
opening bct.dat
myrank=          34  and I found          100  nodes.
myrank=          33  and I found           84  nodes.
myrank=          35  and I found          100  nodes.
Number of global nonzeros       684155
    1 8.868E+00 1.012E+00  (   0)   7.940E+01   2.860E+28  <   145-  35|  18> [ 331 -  75]
    1 1.063E+01 2.221E+00  (   3)   4.257E-01   4.688E-01  <   400-  43|  16> [ 183 -  15]
    1 1.143E+01 1.224E+00  (   0)   1.163E-01   1.220E-01  <   413-  43|  17> [  44 -  12]
    1 1.238E+01 8.711E-01  (   0)   4.206E-02   3.971E-02  <   189-  48|  17> [  63 -  16]
    1 1.377E+01 3.202E-01  (  -4)   1.792E-02   1.284E-02  <   460-  48|  16> [ 128 -  20]
    2 1.478E+01 2.331E+02  (  23)   1.045E-01   1.132E+00  <    58-  48|  11> [  67 -  10]
    2 1.577E+01 6.989E+00  (   8)   2.628E-02   1.466E-01  <    58-  48|  15> [  46 -  10]
    2 1.678E+01 7.657E-01  (  -1)   1.032E-02   8.964E-02  <   413-  43|  16> [  75 -  10]
    2 1.751E+01 2.928E-01  (  -5)   4.848E-03   4.569E-02  <   413-  43|  18> [  48 -  12]
    2 1.872E+01 1.270E-01  (  -9)   2.098E-03   2.176E-02  <   400-  43|  16> [  61 -  13]
    3 1.952E+01 4.506E+01  (  16)   7.446E-02   1.945E+00  <    58-  48|  13> [  47 -  10]
    3 2.050E+01 1.661E+00  (   2)   8.796E-03   4.309E-02  <    58-  48|  16> [  49 -  10]
    3 2.164E+01 3.216E-01  (  -4)   3.061E-03   4.613E-03  <   112-  48|  15> [  63 -  10]
    3 2.232E+01 1.211E-01  (  -9)   1.512E-03   1.860E-03  <   460-  48|  16> [  30 -  10]
    3 2.316E+01 5.370E-02  ( -12)   7.529E-04   1.030E-03  <   460-  48|  16> [  44 -  10]
    4 2.438E+01 1.310E+01  (  11)   6.281E-02   1.097E-01  <   569-  43|  13> [  45 -  10]
    4 2.494E+01 5.189E-01  (  -2)   5.964E-03   1.755E-02  <   413-  43|  16> [  40 -  10]
    4 2.591E+01 1.764E-01  (  -7)   2.277E-03   7.076E-03  <   413-  43|  15> [  35 -  10]
    4 2.641E+01 6.626E-02  ( -11)   1.044E-03   2.870E-03  <    83-  48|  16> [  38 -  13]
    4 2.752E+01 2.497E-02  ( -16)   4.370E-04   8.437E-04  <   109-  48|  15> [  35 -  14]
    5 2.853E+01 1.252E+01  (  10)   5.325E-02   8.391E-02  <   100-  14|  11> [  40 -  10]
    5 2.927E+01 3.578E-01  (  -4)   5.062E-03   3.268E-02  <   249-  48|  15> [  35 -  11]
    5 3.020E+01 1.169E-01  (  -9)   1.797E-03   1.177E-02  <   413-  43|  16> [  26 -  11]
    5 3.074E+01 4.546E-02  ( -13)   7.936E-04   4.972E-03  <    83-  48|  17> [  33 -  12]
    5 3.176E+01 1.911E-02  ( -17)   3.773E-04   1.683E-03  <   109-  48|  15> [  41 -  13]

For this case you can do the following:

grep '\[' file_name.o* | awk '{print $13, $15}' |sed -e 's/\]//g' |awk '{s+=$1}{t+=$2}{print s,t}'

What this does is to consider only the lines that contains the bracket '['. The output of the command is

331 75
514 90
558 102
621 118
749 138
816 148
862 158
937 168
985 180
1046 193
1093 203
1142 213
1205 223
1235 233
1279 243
1324 253
1364 263
1399 273
1437 286
1472 300
1512 310
1547 321
1573 332
1606 344
1647 357

Again, the last line shows the total GS & GMRES iterations. Therefore, the total GS & GMRES iterations are 1647 and 357 respectively.

Personal tools