1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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()
|