[cig-commits] r20052 - short/3D/PyLith/benchmarks/trunk/static/performance/solvertest

brad at geodynamics.org brad at geodynamics.org
Tue May 8 11:16:01 PDT 2012


Author: brad
Date: 2012-05-08 11:16:01 -0700 (Tue, 08 May 2012)
New Revision: 20052

Modified:
   short/3D/PyLith/benchmarks/trunk/static/performance/solvertest/plot_scaling.py
Log:
Updated plotting script for scaling.

Modified: short/3D/PyLith/benchmarks/trunk/static/performance/solvertest/plot_scaling.py
===================================================================
--- short/3D/PyLith/benchmarks/trunk/static/performance/solvertest/plot_scaling.py	2012-05-07 20:55:23 UTC (rev 20051)
+++ short/3D/PyLith/benchmarks/trunk/static/performance/solvertest/plot_scaling.py	2012-05-08 18:16:01 UTC (rev 20052)
@@ -9,20 +9,23 @@
 #
 # PREREQUISITES: matplotlib, numpy
 #
-# Create subdirectory 'logs' with python log summaries.
+# Create subdirectory 'logs' with ASCII and python log summaries.
 
 import matplotlib.pyplot as pyplot
 import numpy
 import sys
 import os
+import re
 
 sys.path.append("../../../figures")
 import matplotlibext
 
-header = 0.25 
+header = 0.35
+logsDir = "logs_asm"
 
 nprocs = [1,2,4,8,16,32,64,128]
 stages = ["Solve",
+          "MG Apply",
           "Reform Jacobian",
           "Reform Residual",
           ]
@@ -33,12 +36,12 @@
 symdict = {'Hex8': 's',
            'Tet4': '^',
            }
-styledict = {'Setup': ('orange', (None,None)),
-             'Prestep': ('green', (None, None)),
-             'Reform Jacobian': ('blue', (3,1.5)),
+styledict = {'Reform Jacobian': ('blue', (3,1.5)),
              'Reform Residual': ('purple', (6,1.5)),
              'Solve': ('red', (None, None)),
-             'Poststep': ('ltblue', (None, None)),
+             'MG Apply': ('ltblue', (1.5, 1.5)),
+             'Setup': ('orange', (None,None)),
+             'Prestep': ('green', (None, None)),
              }
              
 
@@ -51,42 +54,49 @@
 
 # Get stats
 niters = {}
+sys.path.append(logsDir)
 for c in cells:
     niters[c] = numpy.zeros(len(nprocs), dtype=numpy.float32)
     for ip in xrange(len(nprocs)):
-        # Get number of iterations from ASCII log
-        logname = "logs/%s_np%03d.log" % (c.lower(), nprocs[ip])
-        with open(filename, "r") as fin:
-            for line in fin:
-                refields = re.search("Linear solve converged due to \w+ iterations ([0-9]+)", line)
-                if refields:
-                    niters[c][ip] = refields.group(1)
-                    break
-
-        # Get timing info from Python log
-        sys.path.append("logs")
         modname = "%s_np%03d" % (c.lower(), nprocs[ip])
-        if not os.path.exists("logs/%s.py" % modname):
+        if not os.path.exists("%s/%s.py" % (logsDir, modname)):
             print "Skipping stats for cell %s and %d procs. Log not found." %\
                 (c, nprocs[ip])
             niters[c][ip] = None
             data[c][s][ip] = None
             continue
 
+        # Get timing info from Python log
         log = __import__(modname)
-        niters[c][ip] = log.Solve.event['VecMDot'].Count[0]
         for s in stages:
-            
             total = 0.0
             sattr = s.replace(' ','_')
             assert(nprocs[ip] == log.__getattribute__('Nproc'))
-            data[c][s][ip] = log.__getattribute__(sattr).time / nprocs[ip]
+            try:
+                data[c][s][ip] = log.__getattribute__(sattr).time / nprocs[ip]
+            except AttributeError:
+                data[c][s][ip] = 0
 
+        # Get number of iterations from ASCII log
+        logname = "%s/%s_np%03d.log" % (logsDir, c.lower(), nprocs[ip])
+        with open(logname, "r") as fin:
+            for line in fin:
+                refields = re.search("Linear solve converged due to \w+ iterations ([0-9]+)", line)
+                if refields:
+                    niters[c][ip] = refields.group(1)
+                    break
+
 figure = matplotlibext.Figure()
-figure.open(3.0, 5.25, margins=[[0.5, 0, 0.1], [0.42, 0.4, 0.05]], dpi=150)
+figure.open(3.0, 5.25, margins=[[0.5, 0.35, 0.1], [0.42, 0.4, 0.05]], dpi=150)
 
-ax = figure.axes(2.0+header, 1, 1.0+header, 1)
+ncols = 1
+nrows = 2
 
+icol = 0
+irow = 0
+
+ax = figure.axes(nrows+header, ncols, irow+1+header, icol+1)
+
 for c in cells:
     for s in stages:
         ax.loglog(nprocs, data[c][s], 
@@ -95,7 +105,7 @@
                   linewidth=1,
                   dashes=styledict[s][1])
         ax.hold(True)
-        if s == 'Solve':
+        if s == 'Solve' and False:
             ax.loglog(nprocs, data[c][s]/(niters[c]/niters[c][0]), 
                       marker=symdict[c], 
                       color='gray',
@@ -105,44 +115,57 @@
 ax.set_xlim((1, 128))
 #ax.set_xlabel("# Processors")
 
-ax.set_ylim((0.01, 1000))
-ax.set_ylabel("Time (s)")
+ax.set_ylim((0.1, 400))
+if icol == 0:
+    ax.set_ylabel("Time (s)")
+else:
+    ax.set_yticklabels([])
+    ax.set_ylabel("")
 
-import matplotlib.lines as lines
-proxies = []
-for c in cells:
-    proxies.append(lines.Line2D((0,0),(1,1), 
-                                marker=symdict[c], 
-                                color=styledict['Solve'][0],
-                                linewidth=0))
-l1 = ax.legend(proxies, cells, 
-          loc='lower left', bbox_to_anchor=(0,1.05), borderaxespad=0)
+if icol == 0:
+    import matplotlib.lines as lines
+    proxies = []
+    for c in cells:
+        proxies.append(lines.Line2D((0,0),(1,1), 
+                                    marker=symdict[c], 
+                                    color=styledict['Solve'][0],
+                                    linewidth=0))
+    l1 = ax.legend(proxies, cells, 
+                   loc='lower left', 
+                   bbox_to_anchor=(0,1.05), 
+                   borderaxespad=0)
 
-proxies = []
-for s in stages:
-    proxies.append(lines.Line2D((0,0),(1,1), 
-                                marker=None, 
-                                color=styledict[s][0],
-                                dashes=styledict[s][1]))
-ax.legend(proxies, stages, 
-          loc='lower right', bbox_to_anchor=(1,1.05), borderaxespad=0)
-ax.add_artist(l1)
+    proxies = []
+    for s in stages:
+        proxies.append(lines.Line2D((0,0),(1,1), 
+                                    marker=None, 
+                                    color=styledict[s][0],
+                                    dashes=styledict[s][1]))
+    ax.legend(proxies, stages, 
+              loc='lower right', 
+              bbox_to_anchor=(1,1.05), 
+              borderaxespad=0)
+    ax.add_artist(l1)
 
-ax = figure.axes(2.0+header, 1, 2.0+header, 1)
+irow += 1
+ax = figure.axes(nrows+header, ncols, irow+1+header, icol+1)
 
 for c in cells:
     ax.semilogx(nprocs, niters[c], 
-            marker=symdict[c], 
-            color='red', 
-            linewidth=1)
+                marker=symdict[c], 
+                color='red', 
+                linewidth=1)
     ax.hold(True)
 
 ax.set_xlim((1, 128))
 ax.set_xlabel("# Processors")
 
-#ax.set_ylim((0, 150))
-ax.set_ylabel("# Iterations")
+#ax.set_ylim((0, 100))
+if icol == 0:
+    ax.set_ylabel("# Iterations")
+else:
+    ax.set_yticklabels([])
+    ax.set_ylabel("")
 
-
 pyplot.show()
 pyplot.savefig('solvertest_scaling')



More information about the CIG-COMMITS mailing list