root / gcell / src / apps / gen_script.py @ 28361a1b
History | View | Annotate | Download (3 kB)
| 1 | #!/usr/bin/env python
|
|---|---|
| 2 | |
| 3 | import sys |
| 4 | import time |
| 5 | import os |
| 6 | |
| 7 | from optparse import OptionParser |
| 8 | |
| 9 | |
| 10 | def get_svn_rev(): |
| 11 | try:
|
| 12 | f = os.popen("svn info", "r") |
| 13 | lines = f.readlines() |
| 14 | f.close() |
| 15 | except:
|
| 16 | return "unk" |
| 17 | |
| 18 | svn_rev = "unk"
|
| 19 | for l in lines: |
| 20 | if l.startswith('Revision:'): |
| 21 | t = l.rstrip() |
| 22 | svn_rev = t.split()[-1]
|
| 23 | return svn_rev
|
| 24 | |
| 25 | def is_ps3(): |
| 26 | try:
|
| 27 | f = open("/proc/cpuinfo") |
| 28 | s = f.read() |
| 29 | except:
|
| 30 | return False |
| 31 | |
| 32 | return s.find('PS3') != -1 |
| 33 | |
| 34 | |
| 35 | def main(): |
| 36 | |
| 37 | def make_fname(suffix): |
| 38 | return basename + '.' + suffix |
| 39 | |
| 40 | max_spes_default = 16
|
| 41 | if is_ps3():
|
| 42 | max_spes_default = 6
|
| 43 | |
| 44 | parser = OptionParser() |
| 45 | parser.add_option("-m", "--max-spes", type="int", default=max_spes_default, |
| 46 | metavar="NSPES",
|
| 47 | help="maximum number of SPEs to use [default=%default]")
|
| 48 | parser.add_option("", "--min-spes", type="int", default=1, |
| 49 | metavar="NSPES",
|
| 50 | help="minimum number of SPEs to use [default=%default]")
|
| 51 | parser.add_option("-p", "--oprofile", action="store_true", default=False, |
| 52 | help="emit oprofile commands")
|
| 53 | parser.add_option("-t", "--tag", default=None, |
| 54 | help="additional goodie in generated filenames")
|
| 55 | (options, args) = parser.parse_args() |
| 56 | if len(args) != 0: |
| 57 | parser.print_help() |
| 58 | sys.exit(1)
|
| 59 | |
| 60 | svn_rev = get_svn_rev() |
| 61 | |
| 62 | os.environ['TZ'] = 'PST8PDT' # always pacific |
| 63 | time.tzset() |
| 64 | |
| 65 | tag = ''
|
| 66 | if options.tag:
|
| 67 | tag = '-' + options.tag
|
| 68 | |
| 69 | basename = 'R-%s%s-%s' % (svn_rev, tag, time.strftime('%Y%m%d-%H%M')) |
| 70 | |
| 71 | base_njobs = int(500e3) |
| 72 | njobs = {
|
| 73 | 1 : base_njobs,
|
| 74 | 10 : base_njobs,
|
| 75 | 50 : base_njobs,
|
| 76 | 100 : base_njobs,
|
| 77 | 200 : int(base_njobs/2), |
| 78 | 250 : int(base_njobs/2.5), |
| 79 | 300 : int(base_njobs/3), |
| 80 | 400 : int(base_njobs/4), |
| 81 | 500 : int(base_njobs/5) |
| 82 | } |
| 83 | |
| 84 | |
| 85 | f_results = make_fname('results')
|
| 86 | f_opreport = make_fname('opreport')
|
| 87 | f_avg = make_fname('avg')
|
| 88 | f_png = make_fname('png')
|
| 89 | |
| 90 | f = sys.stdout |
| 91 | f.write("#!/bin/bash\n")
|
| 92 | |
| 93 | if options.oprofile:
|
| 94 | f.write("opcontrol --stop\n")
|
| 95 | f.write("opcontrol --reset\n")
|
| 96 | f.write("opcontrol --start\n")
|
| 97 | |
| 98 | f.write("(\n")
|
| 99 | |
| 100 | for udelay in (10, 50, 100, 200, 300): |
| 101 | for nspes in range(options.min_spes, options.max_spes+1): |
| 102 | cmd = "./benchmark_nop -n %d -u %d -N %d\n" % (nspes, udelay, njobs[udelay])
|
| 103 | f.write(cmd) |
| 104 | f.write(cmd) |
| 105 | |
| 106 | f.write(") | tee %s\n" % (f_results,))
|
| 107 | |
| 108 | if options.oprofile:
|
| 109 | f.write("opcontrol --dump\n")
|
| 110 | f.write("opcontrol --stop\n")
|
| 111 | f.write("opreport -l | head -100 > %s\n" % (f_opreport,))
|
| 112 | |
| 113 | f.write("./split_and_avg_results.py %s > %s\n" % (f_results, f_avg))
|
| 114 | f.write("./plot_speedup.py %s -o %s\n" % (f_avg, f_png))
|
| 115 | |
| 116 | |
| 117 | if __name__ == '__main__': |
| 118 | main() |