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

brad at geodynamics.org brad at geodynamics.org
Tue Aug 14 08:45:35 PDT 2012


Author: brad
Date: 2012-08-14 08:45:35 -0700 (Tue, 14 Aug 2012)
New Revision: 20568

Added:
   short/3D/PyLith/benchmarks/trunk/static/performance/solvertest/table_scaling.py
Modified:
   short/3D/PyLith/benchmarks/trunk/static/performance/solvertest/plot_scaling.py
   short/3D/PyLith/benchmarks/trunk/static/performance/solvertest/table_pctests.py
Log:
Added script to construct tables for preconditioner 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-08-14 03:23:41 UTC (rev 20567)
+++ short/3D/PyLith/benchmarks/trunk/static/performance/solvertest/plot_scaling.py	2012-08-14 15:45:35 UTC (rev 20568)
@@ -20,12 +20,11 @@
 sys.path.append("../../../figures")
 import matplotlibext
 
-header = 0.35
-logsDir = "logs"
+header = 0.3
+logsDir = "logs_jun26"
 
-nprocs = [1,2,4,8,16,32,64,128]
+nprocs = [1,2,4,8,16,32,64]
 stages = ["Solve",
-          "MG Apply",
           "Reform Jacobian",
           "Reform Residual",
           ]
@@ -58,10 +57,10 @@
 for c in cells:
     niters[c] = numpy.zeros(len(nprocs), dtype=numpy.float32)
     for ip in xrange(len(nprocs)):
-        modname = "%s_np%03d" % (c.lower(), nprocs[ip])
+        modname = "%s_cube_amg_np%03d" % (c.lower(), nprocs[ip])
         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])
+            print "Skipping stats for cell %s and %d procs (%s). Log not found." %\
+                (c, nprocs[ip], modname)
             niters[c][ip] = None
             data[c][s][ip] = None
             continue
@@ -78,7 +77,7 @@
                 data[c][s][ip] = 0
 
         # Get number of iterations from ASCII log
-        logname = "%s/%s_np%03d.log" % (logsDir, c.lower(), nprocs[ip])
+        logname = "%s/%s_cube_amg_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)
@@ -87,7 +86,7 @@
                     break
 
 figure = matplotlibext.Figure()
-figure.open(3.0, 5.25, margins=[[0.5, 0.35, 0.1], [0.42, 0.4, 0.05]], dpi=150)
+figure.open(3.0, 5.25, margins=[[0.5, 0.35, 0.15], [0.42, 0.4, 0.05]], dpi=150)
 
 ncols = 1
 nrows = 2
@@ -105,14 +104,14 @@
                   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',
                       linewidth=1,
                       dashes=styledict[s][1])
 
-ax.set_xlim((1, 128))
+ax.set_xlim((1, 100))
 #ax.set_xlabel("# Processors")
 
 ax.set_ylim((0.1, 400))
@@ -157,7 +156,7 @@
                 linewidth=1)
     ax.hold(True)
 
-ax.set_xlim((1, 128))
+ax.set_xlim((1, 100))
 ax.set_xlabel("# Processors")
 
 ax.set_ylim((1, 100))

Modified: short/3D/PyLith/benchmarks/trunk/static/performance/solvertest/table_pctests.py
===================================================================
--- short/3D/PyLith/benchmarks/trunk/static/performance/solvertest/table_pctests.py	2012-08-14 03:23:41 UTC (rev 20567)
+++ short/3D/PyLith/benchmarks/trunk/static/performance/solvertest/table_pctests.py	2012-08-14 15:45:35 UTC (rev 20568)
@@ -7,7 +7,7 @@
 #
 # Tabulate performance of preconditioners.
 #
-# Uses subdirectory 'logs' with python log summaries.
+# Uses subdirectory 'logs_pctest' with iteration counts in .log files.
 
 import os
 import sys
@@ -17,7 +17,7 @@
 
 style = "latex"
 if len(sys.argv) > 2:
-    raise ValueError("usage: table_pc.py [text | latex (default)]")
+    raise ValueError("usage: table_pctest.py [text | latex (default)]")
 if len(sys.argv) == 2:
     style = sys.argv[1]
 
@@ -29,11 +29,10 @@
 
 preconditioners = [('asm', 'ASM'),
                    ('schur_full', 'Schur (full)'),
-                   ('schur_lower', 'Schur (lower)'),
                    ('schur_upper', 'Schur (upper)'),
                    ('fieldsplit_add', 'FieldSplit (add)'),
                    ('fieldsplit_mult', 'FieldSplit (mult)'),
-                   ('fieldsplit_mult_custompc', 'FieldSplit (mult,custom)'),
+                   ('fieldsplit_mult_custom', 'FieldSplit (mult,custom)'),
                    ]
 cells = ['Tet4',
          'Hex8']
@@ -55,7 +54,7 @@
     for c in cells:
         ip = 0
         for p in problems:
-            filename = "logs/%s_%s_%s.log" % (c.lower(), pc[0], p[0])
+            filename = "logs_pctest/%s_%s_%s.log" % (c.lower(), pc[0], p[0])
             with open(filename, "r") as fin:
                 for line in fin:
                     refields = re.search("Linear solve converged due to \w+ iterations ([0-9]+)", line)

Added: short/3D/PyLith/benchmarks/trunk/static/performance/solvertest/table_scaling.py
===================================================================
--- short/3D/PyLith/benchmarks/trunk/static/performance/solvertest/table_scaling.py	                        (rev 0)
+++ short/3D/PyLith/benchmarks/trunk/static/performance/solvertest/table_scaling.py	2012-08-14 15:45:35 UTC (rev 20568)
@@ -0,0 +1,169 @@
+#!/usr/bin/env python
+# ----------------------------------------------------------------------
+#
+# Brad T. Aagaard, U.S. Geological Survey
+#
+# ----------------------------------------------------------------------
+#
+# Tabulate parallel scalability performance.
+#
+# Uses subdirectory 'logs' with python log summaries.
+
+logsDir = 'logs_jun26'
+cells = 'hex8'
+
+# ======================================================================
+import os
+import sys
+import numpy
+import re
+
+style = "latex"
+if len(sys.argv) > 2:
+    raise ValueError("usage: table_scalability.py [text | latex (default)]")
+if len(sys.argv) == 2:
+    style = sys.argv[1]
+
+if not style in ["text", 
+               "latex", 
+               ]:
+    raise ValueError("Unknown format (%s) requested." % style)
+
+
+sys.path.append(logsDir)
+
+
+# ----------------------------------------------------------------------
+def eval_memory():
+    nprocs = [1,2,4,8,16,32,64]
+    events = ["VecMDot", "VecAXPY", "VecMAXPY"]
+            
+    # Allocate storage for stats
+    flops = {}
+    imbalance = {}
+    for e in events:
+        flops[e] = numpy.zeros((len(nprocs),), dtype=numpy.float32)
+        imbalance[e] = numpy.zeros((len(nprocs),), dtype=numpy.float32)
+
+    # Get stats
+    ip = 0
+    for p in nprocs:
+        modname = "%s_cube_amg_np%03d" % (cells.lower(), nprocs[ip])
+        if not os.path.exists("%s/%s.py" % (logsDir, modname)):
+            print "Skipping stats for %d procs (%s). Log not found." % (p, modname)
+            for e in events:
+                flops[event][ip] = None
+                imbalance[event][ip] = None
+            continue
+
+        # Get timing info from Python log
+        log = __import__(modname)
+        for e in events:
+            elog = log.__getattribute__('Solve').event[e]
+            eflops = elog.Flops
+            etime = elog.Time
+            flops[e][ip] = 1.0e-6*numpy.sum(eflops)/numpy.max(etime)
+            imbalance[e][ip] = numpy.max(eflops)/numpy.min(eflops)
+
+        ip += 1
+
+    if style == "text":
+        print "Event     #Cores  Load Imbalance  MFlops/s"
+        for e in events:
+            ip = 0
+            line = "%-10s" % e
+            while ip < len(nprocs):
+                line += "%6d  %14.1f  %8.0f" % (nprocs[ip], imbalance[e][ip], flops[e][ip])
+                print line
+                line = " "*10
+                ip += 1
+
+    else:
+        print "\\begin{tabular}{lrrr}"
+        print "  \hline"
+        print "  Event & \# Cores & Load Imbalance & MFlops/s \\\\"
+        for e in events:
+            print "  \hline"
+            ip = 0
+            line = e
+            while ip < len(nprocs):
+                line += " & %4d & %3.1f & %6.0f" % (nprocs[ip], imbalance[e][ip], flops[e][ip])
+                print line + " \\\\"
+                line = "    "
+                ip += 1
+        print "  \hline"
+        print "\\end{tabular}"
+
+
+# ----------------------------------------------------------------------
+def eval_solver():
+    nprocs = [8,16,32,64]
+    events = ["MatMult", "PCSetUp", "PCApply", "KSPSolve"]
+
+    # Allocate storage for stats
+    flops = {}
+    time = {}
+    calls = {}
+    for e in events:
+        flops[e] = numpy.zeros((len(nprocs),), dtype=numpy.float32)
+        time[e] = numpy.zeros((len(nprocs),), dtype=numpy.float32)
+        calls[e] = numpy.zeros((len(nprocs),), dtype=numpy.float32)
+
+    # Get stats
+    ip = 0
+    for p in nprocs:
+        modname = "%s_cube_amg_np%03d" % (cells.lower(), nprocs[ip])
+        if not os.path.exists("%s/%s.py" % (logsDir, modname)):
+            print "Skipping stats for %d procs (%s). Log not found." % (p, modname)
+            for e in events:
+                flops[event][ip] = None
+                time[event][ip] = None
+                calls[event][ip] = None
+            continue
+
+        # Get timing info from Python log
+        log = __import__(modname)
+        for e in events:
+            elog = log.__getattribute__('Solve').event[e]
+            eflops = elog.Flops
+            etime = elog.Time
+            ecalls = elog.Count
+            flops[e][ip] = 1.0e-6*numpy.sum(eflops)/numpy.max(etime)
+            time[e][ip] = numpy.max(etime)
+            calls[e][ip] = numpy.mean(ecalls)
+
+        ip += 1
+
+    if style == "text":
+        print "\n\n"
+        print "Event         Calls  Time (s)  MFlops/s"
+
+        ip = 0
+        while ip < len(nprocs):
+            print "p = %d" % nprocs[ip]
+            for e in events:
+                line = "  %-10s  %5d  %8.1f  %8.0f" % (e, calls[e][ip], time[e][ip], flops[e][ip])
+                print line
+            ip += 1
+
+    else:
+        print "\\begin{tabular}{lrrr}"
+        print "  \hline"
+        print "  Event & \# Calls & Time (s) & MFlops/s \\\\"
+        print "  \hline"
+
+        ip = 0
+        while ip < len(nprocs):
+            print "\multicolumn{4}{c}{p = %d} \\\\" % nprocs[ip]
+            for e in events:
+                line = "  %s & %3d & %8.1f & %8.0f \\\\" % (e, calls[e][ip], time[e][ip], flops[e][ip])
+                print line
+            print "\hline"
+            ip += 1
+        print "\\end{tabular}"
+
+
+            
+# ----------------------------------------------------------------------
+eval_memory()
+eval_solver()


Property changes on: short/3D/PyLith/benchmarks/trunk/static/performance/solvertest/table_scaling.py
___________________________________________________________________
Name: svn:executable
   + *



More information about the CIG-COMMITS mailing list