commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r7700 - gnuradio/branches/developers/eb/gcell/src/apps


From: eb
Subject: [Commit-gnuradio] r7700 - gnuradio/branches/developers/eb/gcell/src/apps
Date: Thu, 14 Feb 2008 23:01:22 -0700 (MST)

Author: eb
Date: 2008-02-14 23:01:22 -0700 (Thu, 14 Feb 2008)
New Revision: 7700

Modified:
   gnuradio/branches/developers/eb/gcell/src/apps/gen_script.py
   gnuradio/branches/developers/eb/gcell/src/apps/plot_speedup.py
Log:
script enhancements

Modified: gnuradio/branches/developers/eb/gcell/src/apps/gen_script.py
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/apps/gen_script.py        
2008-02-15 04:17:58 UTC (rev 7699)
+++ gnuradio/branches/developers/eb/gcell/src/apps/gen_script.py        
2008-02-15 06:01:22 UTC (rev 7700)
@@ -7,12 +7,42 @@
 from optparse import OptionParser
 
 
+def get_svn_rev():
+    try:
+        f = os.popen("svn info", "r")
+        lines = f.readlines()
+        f.close()
+    except:
+        return "unk"
+
+    svn_rev = "unk"
+    for l in lines:
+        if l.startswith('Revision:'):
+            t = l.rstrip()
+            svn_rev = t.split()[-1]
+    return svn_rev
+    
+def is_ps3():
+    try:
+        f = open("/proc/cpuinfo")
+        s = f.read()
+    except:
+        return False
+
+    return s.find('PS3') != -1
+
+
 def main():
+
     def make_fname(suffix):
         return basename + '.' + suffix
 
+    max_spes_default = 16
+    if is_ps3():
+        max_spes_default = 6
+        
     parser = OptionParser()
-    parser.add_option("-m", "--max-spes", type="int", default=6,
+    parser.add_option("-m", "--max-spes", type="int", default=max_spes_default,
                       help="set maximum number of SPEs to use 
[default=%default]")
     parser.add_option("-p", "--oprofile", action="store_true", default=False,
                       help="emit oprofile commands")
@@ -23,13 +53,17 @@
         parser.print_help()
         sys.exit(1)
 
+    svn_rev = get_svn_rev()
+
     os.environ['TZ'] = 'PST8PDT'        # always pacific
     time.tzset()
-    basename = 'R' + time.strftime('%m%d-%H%M')
+
+    tag = ''
     if options.tag:
-        basename = basename + '-' + options.tag
+        tag = '-' + options.tag
+        
+    basename = 'R-%s%s-%s' % (svn_rev, tag, time.strftime('%Y%m%d-%H%M'))
 
-
     base_njobs = int(500e3)
     njobs = {
          1 : base_njobs,
@@ -44,8 +78,11 @@
         }
 
     
+    f_results = make_fname('results')
+    f_opreport = make_fname('opreport')
+    f_avg = make_fname('avg')
+    f_png = make_fname('png')
 
-
     f = sys.stdout
     f.write("#!/bin/bash\n")
 
@@ -56,20 +93,21 @@
 
     f.write("(\n")
 
-    for udelay in (10, 50, 100, 200, 300, 500):
+    for udelay in (10, 50, 100, 200, 300):
         for nspes in range(1, options.max_spes+1):
             cmd = "./benchmark_nop -n %d -u %d -N %d\n" % (nspes, udelay, 
njobs[udelay])
             f.write(cmd)
             f.write(cmd)
 
-    f.write(") | tee %s\n" % (make_fname('results'),))
+    f.write(") | tee %s\n" % (f_results,))
 
     if options.oprofile:
         f.write("opcontrol --dump\n")
         f.write("opcontrol --stop\n")
-        f.write("opreport -l | head -100 > %s\n" % (make_fname('opreport'),))
+        f.write("opreport -l | head -100 > %s\n" % (f_opreport,))
 
-    f.write("./split_and_avg_results.py %s > %s\n" % (make_fname('results'), 
make_fname('summary'),))
+    f.write("./split_and_avg_results.py %s > %s\n" % (f_results, f_avg))
+    f.write("./plot_speedup.py %s -o %s\n" % (f_avg, f_png))
 
 
 if __name__ == '__main__':

Modified: gnuradio/branches/developers/eb/gcell/src/apps/plot_speedup.py
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/apps/plot_speedup.py      
2008-02-15 04:17:58 UTC (rev 7699)
+++ gnuradio/branches/developers/eb/gcell/src/apps/plot_speedup.py      
2008-02-15 06:01:22 UTC (rev 7700)
@@ -25,7 +25,7 @@
 
 
 class plot_data(object):
-    def __init__(self, filenames):
+    def __init__(self, filenames, output_filename):
         self.fig = figure(1, figsize=(8, 6), facecolor='w')
         self.sp = self.fig.add_subplot(1,1,1)
         self.sp.set_xlabel("nspes", fontweight="bold")
@@ -45,14 +45,39 @@
             500 : 'h'
             }
         
-        for f in filenames:
+        if len(filenames) == 1:
+            f = filenames[0]
             d = parse_file(open(f))
-            self.make_plot(d, f, f == filenames[0])
+            self.make_single_plot(d, f)
+            
+        else:
+            for f in filenames:
+                d = parse_file(open(f))
+                self.make_plot(d, f, f == filenames[0])
 
-        show()
+        if output_filename:
+            savefig(output_filename)
+        else:
+            show()
 
 
-        
+    def make_single_plot(self, d, filename):
+        def style(k):
+            return self.markers[k]
+
+        tag, ext = os.path.splitext(os.path.basename(filename))
+        title(tag)
+        keys = d.keys()
+        keys.sort()
+        keys.reverse()
+        for k in keys:
+            vlist = d[k]         # list of 2-tuples
+            xs = [v[0] for v in vlist]
+            ys = [v[1] for v in vlist]
+            plot(xs, ys, style(k), label="%d us" % (k,))
+
+        x = legend(loc=2)
+
     def make_plot(self, d, filename, first):
         def style(k):
             if first:
@@ -63,6 +88,7 @@
         tag, ext = os.path.splitext(os.path.basename(filename))
         keys = d.keys()
         keys.sort()
+        keys.reverse()
         for k in keys:
             vlist = d[k]         # list of 2-tuples
             xs = [v[0] for v in vlist]
@@ -73,16 +99,17 @@
 
 def main():
     usage="%prog: [options] input_filename..."
-    description = "Plots R*.summary files from benchmark_nop.py"
+    description = "Plot R*.avg files from benchmark_nop.py"
     parser = OptionParser(usage=usage, description=description)
-
+    parser.add_option('-o', '--output', default=None,  metavar="FILE",
+                      help="generate .png file")
     (options, args) = parser.parse_args()
     if len(args) < 1:
         parser.print_help()
         raise SystemExit, 1
 
     filenames = args
-    dc = plot_data(filenames)
+    dc = plot_data(filenames, options.output)
 
 
         





reply via email to

[Prev in Thread] Current Thread [Next in Thread]