summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/examples/mp-sched/plot_flops.py
diff options
context:
space:
mode:
authorManoj Gudi2013-10-07 20:19:55 +0530
committerManoj Gudi2013-10-07 20:20:35 +0530
commit1826d0763c8595997f5f4af1fdb0354e9c0998ad (patch)
treeacbd852cd5a1bf17241b1038b5e37a0e72e64612 /gnuradio-core/src/examples/mp-sched/plot_flops.py
parent452defdb4a78e9e826740ddf4b9673e926c568a4 (diff)
parent24b640997ba7fee0c725e65f401f5cbebdab8d08 (diff)
downloadgnuradio-1826d0763c8595997f5f4af1fdb0354e9c0998ad.tar.gz
gnuradio-1826d0763c8595997f5f4af1fdb0354e9c0998ad.tar.bz2
gnuradio-1826d0763c8595997f5f4af1fdb0354e9c0998ad.zip
README change
Diffstat (limited to 'gnuradio-core/src/examples/mp-sched/plot_flops.py')
-rwxr-xr-xgnuradio-core/src/examples/mp-sched/plot_flops.py98
1 files changed, 98 insertions, 0 deletions
diff --git a/gnuradio-core/src/examples/mp-sched/plot_flops.py b/gnuradio-core/src/examples/mp-sched/plot_flops.py
new file mode 100755
index 000000000..d9d810ae2
--- /dev/null
+++ b/gnuradio-core/src/examples/mp-sched/plot_flops.py
@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+"""
+Reads output from run_synthetic.py and runs gnuplot showing
+GFLOPS as f(npipes, nstages)
+"""
+
+import re
+import sys
+import os
+import tempfile
+from optparse import OptionParser
+
+
+def parse_file(input_filename, output):
+ last = None
+ desc = ''
+ for line in open(input_filename, 'r'):
+ s = line.strip()
+ if s.startswith('>>>'): # ignore ">>> using SSE cruft"
+ continue
+
+ if s.startswith('#D'): # machine description
+ desc = s[2:].strip()
+ continue
+
+ fields = s.split()
+ npipes, nstages, flops = fields[0], fields[1], fields[8]
+
+ if last is not None and npipes != last:
+ output.write('\n')
+ last = npipes
+
+ output.write(' '.join((npipes, nstages, flops)))
+ output.write('\n')
+
+ output.flush()
+ return desc
+
+
+def handle_file(input_filename):
+ cmd_file = tempfile.NamedTemporaryFile(mode='w+', prefix='pf', suffix='.cmd')
+ cmd_file_name = cmd_file.name
+ data_file = tempfile.NamedTemporaryFile(mode='w+', prefix='pf', suffix='.dat')
+ data_file_name = data_file.name
+ desc = parse_file(input_filename, data_file)
+ if len(desc) > 0:
+ cmd_file.write("set title '%s'\n" % (desc,))
+ cmd_file.write("set xlabel 'N pipes'\n")
+ cmd_file.write("set ylabel 'N stages'\n")
+ cmd_file.write("set zlabel 'GFLOPS'\n")
+ cmd_file.write("set key off\n")
+ cmd_file.write("set view 60, 312\n")
+ cmd_file.write("set pm3d\n")
+ cmd_file.write("splot '%s' using 1:2:($3*1e-9) with pm3d at b, '%s' using 1:2:($3*1e-9) with pm3d\n" % (
+ data_file_name, data_file_name))
+
+ cmd_file.flush()
+ data_file.flush()
+
+ os.system("gnuplot " + cmd_file_name + " -")
+
+ #sys.stdout.write(open(cmd_file_name,'r').read())
+ #sys.stdout.write(open(data_file_name,'r').read())
+
+
+def main():
+ usage = "usage: %prog [options] file.dat"
+ parser = OptionParser(usage=usage)
+ (options, args) = parser.parse_args()
+ if len(args) != 1:
+ parser.print_help()
+ raise SystemExit, 1
+
+ handle_file(args[0])
+
+
+if __name__ == '__main__':
+ main()