stats.py revision 1318:57d49cdb92a5
16657Snate@binkert.org#!/usr/bin/env python 26657Snate@binkert.orgfrom __future__ import division 36657Snate@binkert.orgimport re, sys, math 46657Snate@binkert.org 56657Snate@binkert.orgdef usage(): 66657Snate@binkert.org print '''\ 76657Snate@binkert.orgUsage: %s [-E] [-F] [-d <db> ] [-g <get> ] [-h <host>] [-p] 86657Snate@binkert.org [-s <system>] [-r <runs> ] [-u <username>] <command> [command args] 96657Snate@binkert.org''' % sys.argv[0] 106657Snate@binkert.org sys.exit(1) 116657Snate@binkert.org 126657Snate@binkert.orgdef getopts(list, flags): 136657Snate@binkert.org import getopt 146657Snate@binkert.org try: 156657Snate@binkert.org opts, args = getopt.getopt(list, flags) 166657Snate@binkert.org except getopt.GetoptError: 176657Snate@binkert.org usage() 186657Snate@binkert.org 196657Snate@binkert.org return opts, args 206657Snate@binkert.org 216657Snate@binkert.orgdef printval(name, value, invert = False): 226657Snate@binkert.org if invert and value != 0.0: 236657Snate@binkert.org value = 1 / value 246657Snate@binkert.org 256657Snate@binkert.org if value == (1e300*1e300): 266657Snate@binkert.org return 276657Snate@binkert.org 286999Snate@binkert.org if printval.mode == 'G': 296657Snate@binkert.org print '%s: %g' % (name, value) 306657Snate@binkert.org elif printval.mode != 'F' and value > 1e6: 316657Snate@binkert.org print '%s: %0.5e' % (name, value) 326657Snate@binkert.org else: 338189SLisa.Hsu@amd.com print '%s: %f' % (name, value) 346657Snate@binkert.org 356882SBrad.Beckmann@amd.comprintval.mode = 'G' 367055Snate@binkert.org 376882SBrad.Beckmann@amd.comdef unique(list): 386882SBrad.Beckmann@amd.com set = {} 398191SLisa.Hsu@amd.com map(set.__setitem__, list, []) 406882SBrad.Beckmann@amd.com return set.keys() 416882SBrad.Beckmann@amd.com 426882SBrad.Beckmann@amd.comdef graphdata68(runs, options, tag, label, value): 436888SBrad.Beckmann@amd.com import info 446882SBrad.Beckmann@amd.com configs = ['ste', 'hte', 'htd', 'ocm', 'occ', 'ocp' ] 456882SBrad.Beckmann@amd.com benchmarks = [ 'm', 's', 'snt', 'nb1', 'w1', 'w2', 'w3', 'w4', 'nm', 'ns', 'nw1', 'nw2', 'nw3' ] 466657Snate@binkert.org dmas = [ 'x' ] 476657Snate@binkert.org caches = [ '2', '4' ] 486657Snate@binkert.org 496657Snate@binkert.org names = [] 506657Snate@binkert.org 517839Snilay@cs.wisc.edu bench_system = { 526657Snate@binkert.org 'm' : 'client', 536882SBrad.Beckmann@amd.com 's' : 'client', 546882SBrad.Beckmann@amd.com 'snt' : 'client', 556882SBrad.Beckmann@amd.com 'nb1' : 'server', 566882SBrad.Beckmann@amd.com 'nb2' : 'server', 576882SBrad.Beckmann@amd.com 'nt1' : 'server', 586882SBrad.Beckmann@amd.com 'nt2' : 'server', 596657Snate@binkert.org 'w1' : 'server', 606657Snate@binkert.org 'w2' : 'server', 616657Snate@binkert.org 'w3' : 'server', 626657Snate@binkert.org 'w4' : 'server', 636657Snate@binkert.org 'w1s' : 'server', 646657Snate@binkert.org 'w2s' : 'server', 656657Snate@binkert.org 'w3s' : 'server', 666657Snate@binkert.org 'ns' : 'natbox', 676657Snate@binkert.org 'nm' : 'natbox', 687839Snilay@cs.wisc.edu 'nw1' : 'natbox', 697839Snilay@cs.wisc.edu 'nw2' : 'natbox', 706657Snate@binkert.org 'nw3' : 'natbox' 716657Snate@binkert.org } 726657Snate@binkert.org 736657Snate@binkert.org for bench in benchmarks: 746657Snate@binkert.org if bench_system[bench] != options.system: 756657Snate@binkert.org continue 766657Snate@binkert.org 776657Snate@binkert.org for dma in dmas: 786657Snate@binkert.org for cache in caches: 796657Snate@binkert.org names.append([bench, dma, cache]) 806657Snate@binkert.org 816657Snate@binkert.org for bench,dma,cache in names: 826657Snate@binkert.org base = '%s.%s.%s' % (bench, dma, cache) 836657Snate@binkert.org fname = 'data/%s.%s.68.dat' % (tag, base) 846657Snate@binkert.org f = open(fname, 'w') 856657Snate@binkert.org print >>f, '#set TITLE = ' 866657Snate@binkert.org print >>f, '#set ylbl = %s' % label 876657Snate@binkert.org #print >>f, '#set sublabels = %s' % ' '.join(configs) 886657Snate@binkert.org print >>f, '#set sublabels = ste hte htd ocm occ ocs' 896657Snate@binkert.org 906779SBrad.Beckmann@amd.com for speed,freq in zip(['s', '6', '8', 'q'],['4GHz', '6GHz','8GHz', '10GHz']): 916657Snate@binkert.org print >>f, '"%s"' % freq, 926657Snate@binkert.org for conf in configs: 936657Snate@binkert.org name = '%s.%s.%s.%s.%s' % (conf, bench, dma, cache, speed) 946657Snate@binkert.org run = info.source.allRunNames[name] 956657Snate@binkert.org info.display_run = run.run; 966657Snate@binkert.org val = float(value) 976657Snate@binkert.org if val == 1e300*1e300: 986657Snate@binkert.org print >>f, 0.0, 996657Snate@binkert.org else: 1006657Snate@binkert.org print >>f, "%f" % val, 1016657Snate@binkert.org print >>f 1026657Snate@binkert.org f.close() 1036657Snate@binkert.org 1046657Snate@binkert.orgdef graphdata(runs, options, tag, label, value): 1056657Snate@binkert.org if options.graph68: 1066657Snate@binkert.org graphdata68(runs, options, tag, label, value) 1076657Snate@binkert.org return 1086657Snate@binkert.org 1096657Snate@binkert.org import info 1106657Snate@binkert.org configs = ['ste', 'hte', 'htd', 'ocm', 'occ', 'ocp' ] 1116657Snate@binkert.org #benchmarks = [ 'm', 's', 'nb1', 'nb2', 'nt1', 'nt2', 'w1', 'w2', 'w3', 'w4', 'ns', 'nm', 'nw1', 'nw2', 'nw3' ] 1126657Snate@binkert.org #benchmarks = [ 'm', 's', 'nb1', 'nb2', 'nt1', 'w1', 'w2', 'w3', 'ns', 'nm', 'w1s' ] 1136657Snate@binkert.org benchmarks = [ 'm', 's', 'nb1', 'nb2', 'w1', 'w2', 'w3', 'w4', 'ns', 'nm', 'nw1', 'snt' ] 1146657Snate@binkert.org #dmas = [ 'x', 'd', 'b' ] 1157839Snilay@cs.wisc.edu dmas = [ 'x' ] 1167839Snilay@cs.wisc.edu caches = [ '2', '4' ] 1177839Snilay@cs.wisc.edu 1187839Snilay@cs.wisc.edu names = [] 1197839Snilay@cs.wisc.edu 1207839Snilay@cs.wisc.edu bench_system = { 1217839Snilay@cs.wisc.edu 'm' : 'client', 1227839Snilay@cs.wisc.edu 's' : 'client', 1237839Snilay@cs.wisc.edu 'snt' : 'client', 1247839Snilay@cs.wisc.edu 'nb1' : 'server', 1257839Snilay@cs.wisc.edu 'nb2' : 'server', 1267839Snilay@cs.wisc.edu 'nt1' : 'server', 1277839Snilay@cs.wisc.edu 'nt2' : 'server', 1287839Snilay@cs.wisc.edu 'w1' : 'server', 1297839Snilay@cs.wisc.edu 'w2' : 'server', 1306657Snate@binkert.org 'w3' : 'server', 1316657Snate@binkert.org 'w4' : 'server', 1326657Snate@binkert.org 'w1s' : 'server', 1336657Snate@binkert.org 'w2s' : 'server', 1346657Snate@binkert.org 'w3s' : 'server', 1356657Snate@binkert.org 'ns' : 'natbox', 1366657Snate@binkert.org 'nm' : 'natbox', 1376657Snate@binkert.org 'nw1' : 'natbox', 1386657Snate@binkert.org 'nw2' : 'natbox', 1396657Snate@binkert.org 'nw3' : 'natbox' 1406657Snate@binkert.org } 1416657Snate@binkert.org 1426657Snate@binkert.org for bench in benchmarks: 1436657Snate@binkert.org if bench_system[bench] != options.system: 1446657Snate@binkert.org continue 1456657Snate@binkert.org 1466657Snate@binkert.org for dma in dmas: 1476657Snate@binkert.org for cache in caches: 1486657Snate@binkert.org names.append([bench, dma, cache]) 1496657Snate@binkert.org 1506657Snate@binkert.org for bench,dma,cache in names: 1516657Snate@binkert.org base = '%s.%s.%s' % (bench, dma, cache) 1526657Snate@binkert.org fname = 'data/%s.%s.dat' % (tag, base) 1536657Snate@binkert.org f = open(fname, 'w') 1546657Snate@binkert.org print >>f, '#set TITLE = ' 1556657Snate@binkert.org print >>f, '#set ylbl = %s' % label 1566657Snate@binkert.org #print >>f, '#set sublabels = %s' % ' '.join(configs) 1576657Snate@binkert.org print >>f, '#set sublabels = ste hte htd ocm occ ocs' 1586657Snate@binkert.org 1596657Snate@binkert.org for speed,freq in zip(['s', 'q'],['4GHz','10GHz']): 1606657Snate@binkert.org print >>f, '"%s"' % freq, 1616877Ssteve.reinhardt@amd.com for conf in configs: 1626657Snate@binkert.org name = '%s.%s.%s.%s.%s' % (conf, bench, dma, cache, speed) 1636657Snate@binkert.org run = info.source.allRunNames[name] 1646657Snate@binkert.org info.display_run = run.run; 1656657Snate@binkert.org val = float(value) 1666657Snate@binkert.org if val == 1e300*1e300: 1676657Snate@binkert.org print >>f, 0.0, 1687542SBrad.Beckmann@amd.com else: 1697542SBrad.Beckmann@amd.com print >>f, "%f" % val, 1706657Snate@binkert.org print >>f 1716877Ssteve.reinhardt@amd.com f.close() 1726999Snate@binkert.org 1736877Ssteve.reinhardt@amd.comdef printdata(runs, value, invert = False): 1746877Ssteve.reinhardt@amd.com import info 1756877Ssteve.reinhardt@amd.com for run in runs: 1766877Ssteve.reinhardt@amd.com info.display_run = run.run; 1776877Ssteve.reinhardt@amd.com val = float(value) 1786877Ssteve.reinhardt@amd.com printval(run.name, val) 1796877Ssteve.reinhardt@amd.com 1806877Ssteve.reinhardt@amd.comclass CommandException(Exception): 1816877Ssteve.reinhardt@amd.com pass 1826877Ssteve.reinhardt@amd.com 1836877Ssteve.reinhardt@amd.comdef commands(options, command, args): 1846877Ssteve.reinhardt@amd.com if command == 'database': 1856877Ssteve.reinhardt@amd.com if len(args) == 0: raise CommandException 1866877Ssteve.reinhardt@amd.com 1876877Ssteve.reinhardt@amd.com import dbinit 1886877Ssteve.reinhardt@amd.com mydb = dbinit.MyDB(options) 1896882SBrad.Beckmann@amd.com 1906882SBrad.Beckmann@amd.com if args[0] == 'drop': 1916882SBrad.Beckmann@amd.com if len(args) > 2: raise CommandException 1926882SBrad.Beckmann@amd.com mydb.admin() 1936882SBrad.Beckmann@amd.com mydb.drop() 1946882SBrad.Beckmann@amd.com if len(args) == 2 and args[1] == 'init': 1956882SBrad.Beckmann@amd.com mydb.create() 1966877Ssteve.reinhardt@amd.com mydb.connect() 1976877Ssteve.reinhardt@amd.com mydb.populate() 1986877Ssteve.reinhardt@amd.com mydb.close() 1996877Ssteve.reinhardt@amd.com return 2006657Snate@binkert.org 2016657Snate@binkert.org if args[0] == 'init': 2026999Snate@binkert.org if len(args) > 1: raise CommandException 2036657Snate@binkert.org mydb.admin() 2046657Snate@binkert.org mydb.create() 2056657Snate@binkert.org mydb.connect() 2066657Snate@binkert.org mydb.populate() 2076657Snate@binkert.org mydb.close() 2086657Snate@binkert.org return 2097007Snate@binkert.org 2106657Snate@binkert.org if args[0] == 'clean': 2116657Snate@binkert.org if len(args) > 1: raise CommandException 2126657Snate@binkert.org mydb.connect() 2136657Snate@binkert.org mydb.clean() 2146657Snate@binkert.org return 2157007Snate@binkert.org 2167007Snate@binkert.org raise CommandException 2176657Snate@binkert.org 2187002Snate@binkert.org import db, info 2197002Snate@binkert.org info.source = db.Database() 2207002Snate@binkert.org info.source.host = options.host 2217002Snate@binkert.org info.source.db = options.db 2228229Snate@binkert.org info.source.passwd = options.passwd 2238229Snate@binkert.org info.source.user = options.user 2246657Snate@binkert.org info.source.connect() 2256657Snate@binkert.org info.source.update_dict(globals()) 2268229Snate@binkert.org 2278229Snate@binkert.org if type(options.get) is str: 2288229Snate@binkert.org info.source.get = options.get 2298229Snate@binkert.org 2306657Snate@binkert.org if options.runs is None: 2316657Snate@binkert.org runs = info.source.allRuns 2326657Snate@binkert.org else: 2336657Snate@binkert.org rx = re.compile(options.runs) 2346793SBrad.Beckmann@amd.com runs = [] 2356657Snate@binkert.org for run in info.source.allRuns: 2366657Snate@binkert.org if rx.match(run.name): 2376657Snate@binkert.org runs.append(run) 2386657Snate@binkert.org 2396657Snate@binkert.org info.display_run = runs[0].run 2407002Snate@binkert.org 2416657Snate@binkert.org if command == 'runs': 2427007Snate@binkert.org user = None 2437007Snate@binkert.org opts, args = getopts(args, '-u') 2447007Snate@binkert.org if len(args): 2457007Snate@binkert.org raise CommandException 2467007Snate@binkert.org for o,a in opts: 2476657Snate@binkert.org if o == '-u': 2486877Ssteve.reinhardt@amd.com user = a 2496877Ssteve.reinhardt@amd.com info.source.listRuns(user) 2506657Snate@binkert.org return 2516877Ssteve.reinhardt@amd.com 2526657Snate@binkert.org if command == 'stability': 2536657Snate@binkert.org stats = info.source.getStat(args[0]) 2547002Snate@binkert.org info.source.get = "avg" 2557002Snate@binkert.org 2566657Snate@binkert.org #loop through all the stats selected 2577567SBrad.Beckmann@amd.com for stat in stats: 2587567SBrad.Beckmann@amd.com 2597922SBrad.Beckmann@amd.com print "%s:" % stat.name 2606881SBrad.Beckmann@amd.com print "%-30s %12s %12s %4s %5s %5s %5s" % \ 2617002Snate@binkert.org ("run name", "average", "stdev", ">10%", ">1SDV", ">2SDV", "SAMP") 2627002Snate@binkert.org print "%-30s %12s %12s %4s %5s %5s %5s" % \ 2636657Snate@binkert.org ("------------------------------", "------------", 2647002Snate@binkert.org "------------", "----", "-----", "-----", "-----") 2656902SBrad.Beckmann@amd.com #loop through all the selected runs 2666863Sdrh5@cs.wisc.edu for run in runs: 2676863Sdrh5@cs.wisc.edu info.display_run = run.run; 2687007Snate@binkert.org runTicks = info.source.retTicks([ run ]) 2696657Snate@binkert.org #throw away the first one, it's 0 2706657Snate@binkert.org runTicks.pop(0) 2716657Snate@binkert.org stat.ticks = runTicks 2726657Snate@binkert.org avg = float(stat) 2736657Snate@binkert.org stdev = 0 2746657Snate@binkert.org numoutsideavg = 0 2756882SBrad.Beckmann@amd.com numoutside1std = 0 2766882SBrad.Beckmann@amd.com numoutside2std = 0 2776882SBrad.Beckmann@amd.com 2786882SBrad.Beckmann@amd.com #loop through all the various ticks for each run 2796657Snate@binkert.org for tick in runTicks: 2806657Snate@binkert.org stat.ticks = str(tick) 2816657Snate@binkert.org val = float(stat) 2826657Snate@binkert.org if (val < (avg * .9)) or (val > (avg * 1.1)): 2837007Snate@binkert.org numoutsideavg += 1 2847839Snilay@cs.wisc.edu stdev += pow((val-avg),2) 2857839Snilay@cs.wisc.edu 2867839Snilay@cs.wisc.edu stdev = math.sqrt(stdev / len(runTicks)) 2877839Snilay@cs.wisc.edu for tick in runTicks: 2887839Snilay@cs.wisc.edu stat.ticks = str(tick) 2897839Snilay@cs.wisc.edu val = float(stat) 2907839Snilay@cs.wisc.edu if (val < (avg - stdev)) or (val > (avg + stdev)): 2917839Snilay@cs.wisc.edu numoutside1std += 1 2927839Snilay@cs.wisc.edu if (val < (avg - (2*stdev))) or (val > (avg + (2*stdev))): 2937839Snilay@cs.wisc.edu numoutside2std += 1 2947839Snilay@cs.wisc.edu 2957839Snilay@cs.wisc.edu print "%-30s %12s %12s %4s %5s %5s %5s" % \ 2967007Snate@binkert.org (run.name, "%.1f" % avg, "%.1f" % stdev, 2977007Snate@binkert.org "%d" % numoutsideavg, "%d" % numoutside1std, 2987007Snate@binkert.org "%d" % numoutside2std, "%d" % len(runTicks)) 2997007Snate@binkert.org return 3007007Snate@binkert.org 3017839Snilay@cs.wisc.edu 3027839Snilay@cs.wisc.edu if command == 'stats': 3037839Snilay@cs.wisc.edu if len(args) == 0: 3047839Snilay@cs.wisc.edu info.source.listStats() 3057839Snilay@cs.wisc.edu elif len(args) == 1: 3067839Snilay@cs.wisc.edu info.source.listStats(args[0]) 3077839Snilay@cs.wisc.edu else: 3087839Snilay@cs.wisc.edu raise CommandException 3097839Snilay@cs.wisc.edu 3107839Snilay@cs.wisc.edu return 3117839Snilay@cs.wisc.edu 3127839Snilay@cs.wisc.edu if command == 'stat': 3137007Snate@binkert.org if len(args) != 1: 3147007Snate@binkert.org raise CommandException 3157002Snate@binkert.org 3166657Snate@binkert.org stats = info.source.getStat(args[0]) 3176657Snate@binkert.org for stat in stats: 3186657Snate@binkert.org if options.graph: 3197055Snate@binkert.org graphdata(runs, options, stat.name, stat.name, stat) 3206657Snate@binkert.org else: 3216657Snate@binkert.org if options.ticks: 3226657Snate@binkert.org print 'only displaying sample %s' % options.ticks 3236863Sdrh5@cs.wisc.edu stat.ticks = options.ticks 3247055Snate@binkert.org 3257567SBrad.Beckmann@amd.com if options.binned: 3267567SBrad.Beckmann@amd.com print 'kernel ticks' 3277567SBrad.Beckmann@amd.com stat.bins = 'kernel' 3287567SBrad.Beckmann@amd.com printdata(runs, stat) 3297567SBrad.Beckmann@amd.com 3307542SBrad.Beckmann@amd.com print 'idle ticks' 3317542SBrad.Beckmann@amd.com stat.bins = 'idle' 3326657Snate@binkert.org printdata(runs, stat) 3337007Snate@binkert.org 3346657Snate@binkert.org print 'user ticks' 3356657Snate@binkert.org stat.bins = 'user' 3366657Snate@binkert.org printdata(runs, stat) 3376657Snate@binkert.org 3386657Snate@binkert.org print 'interrupt ticks' 3396657Snate@binkert.org stat.bins = 'interrupt' 3406657Snate@binkert.org printdata(runs, stat) 3416657Snate@binkert.org 3427839Snilay@cs.wisc.edu print 'total ticks' 3437839Snilay@cs.wisc.edu 3447839Snilay@cs.wisc.edu stat.bins = None 3457839Snilay@cs.wisc.edu print stat.name 3467839Snilay@cs.wisc.edu printdata(runs, stat) 3477839Snilay@cs.wisc.edu return 3487839Snilay@cs.wisc.edu 3497839Snilay@cs.wisc.edu if command == 'formula': 3507839Snilay@cs.wisc.edu if len(args) != 1: 3517839Snilay@cs.wisc.edu raise CommandException 3527839Snilay@cs.wisc.edu 3537839Snilay@cs.wisc.edu stats = eval(args[0]) 3547839Snilay@cs.wisc.edu for stat in stats: 3557839Snilay@cs.wisc.edu if options.graph: 3567839Snilay@cs.wisc.edu graphdata(runs, options, stat.name, stat.name, stat) 3577839Snilay@cs.wisc.edu else: 3586657Snate@binkert.org if options.binned: 3596657Snate@binkert.org print 'kernel ticks' 3606657Snate@binkert.org stat.bins = 'kernel' 3616657Snate@binkert.org printdata(runs, stat) 3627839Snilay@cs.wisc.edu 3637839Snilay@cs.wisc.edu print 'idle ticks' 3647839Snilay@cs.wisc.edu stat.bins = 'idle' 3657839Snilay@cs.wisc.edu printdata(runs, stat) 3667839Snilay@cs.wisc.edu 3677839Snilay@cs.wisc.edu print 'user ticks' 3687839Snilay@cs.wisc.edu stat.bins = 'user' 3697839Snilay@cs.wisc.edu printdata(runs, stat) 3707839Snilay@cs.wisc.edu 3717839Snilay@cs.wisc.edu print 'interrupt ticks' 3727839Snilay@cs.wisc.edu stat.bins = 'interrupt' 3737839Snilay@cs.wisc.edu printdata(runs, stat) 3747839Snilay@cs.wisc.edu 3757839Snilay@cs.wisc.edu print 'total ticks' 3767839Snilay@cs.wisc.edu 3777839Snilay@cs.wisc.edu stat.bins = None 3786657Snate@binkert.org print args[0] 3796657Snate@binkert.org printdata(runs, stat) 3806657Snate@binkert.org return 3816657Snate@binkert.org 3827007Snate@binkert.org if command == 'bins': 3836657Snate@binkert.org if len(args) == 0: 3846657Snate@binkert.org info.source.listBins() 3856657Snate@binkert.org elif len(args) == 1: 3866657Snate@binkert.org info.source.listBins(args[0]) 3876657Snate@binkert.org else: 3886657Snate@binkert.org raise CommandException 3896657Snate@binkert.org 3906657Snate@binkert.org return 3916657Snate@binkert.org 3926657Snate@binkert.org if command == 'formulas': 3937007Snate@binkert.org if len(args) == 0: 3946657Snate@binkert.org info.source.listFormulas() 3956657Snate@binkert.org elif len(args) == 1: 3966657Snate@binkert.org info.source.listFormulas(args[0]) 3976657Snate@binkert.org else: 3986657Snate@binkert.org raise CommandException 3996999Snate@binkert.org 4006657Snate@binkert.org return 4016657Snate@binkert.org 4026657Snate@binkert.org if command == 'samples': 4036657Snate@binkert.org if len(args): 4047007Snate@binkert.org raise CommandException 4056657Snate@binkert.org 4066657Snate@binkert.org info.source.listTicks(runs) 4076657Snate@binkert.org return 4086657Snate@binkert.org 4096657Snate@binkert.org if len(args): 4107832Snate@binkert.org raise CommandException 4117002Snate@binkert.org 4127002Snate@binkert.org system = info.source.__dict__[options.system] 4137002Snate@binkert.org 4148641Snate@binkert.org if command == 'usertime': 4157056Snate@binkert.org import copy 4168232Snate@binkert.org kernel = copy.copy(system.full_cpu.numCycles) 4178232Snate@binkert.org kernel.bins = 'kernel' 4186657Snate@binkert.org 4198229Snate@binkert.org user = copy.copy(system.full_cpu.numCycles) 4206657Snate@binkert.org user.bins = 'user' 4216657Snate@binkert.org 4227056Snate@binkert.org if options.graph: 4237056Snate@binkert.org graphdata(runs, options, 'usertime', 'User Fraction', 4246657Snate@binkert.org user / system.full_cpu.numCycles) 4257002Snate@binkert.org else: 4267002Snate@binkert.org printdata(runs, user / system.full_cpu.numCycles) 4276657Snate@binkert.org return 4286657Snate@binkert.org 4296657Snate@binkert.org if command == 'ticks': 4306657Snate@binkert.org if options.binned: 4316657Snate@binkert.org print 'kernel ticks' 4326793SBrad.Beckmann@amd.com system.full_cpu.numCycles.bins = 'kernel' 4336657Snate@binkert.org printdata(runs, system.full_cpu.numCycles) 4346657Snate@binkert.org 4356657Snate@binkert.org print 'idle ticks' 4366657Snate@binkert.org system.full_cpu.numCycles.bins = 'idle' 4376877Ssteve.reinhardt@amd.com printdata(runs, system.full_cpu.numCycles) 4386877Ssteve.reinhardt@amd.com 4396877Ssteve.reinhardt@amd.com print 'user ticks' 4406877Ssteve.reinhardt@amd.com system.full_cpu.numCycles.bins = 'user' 4416877Ssteve.reinhardt@amd.com printdata(runs, system.full_cpu.numCycles) 4426877Ssteve.reinhardt@amd.com 4436657Snate@binkert.org print 'total ticks' 4447542SBrad.Beckmann@amd.com 4456657Snate@binkert.org system.full_cpu.numCycles.bins = None 4467007Snate@binkert.org printdata(runs, system.full_cpu.numCycles) 4476657Snate@binkert.org return 4486657Snate@binkert.org 4497007Snate@binkert.org if command == 'packets': 4506657Snate@binkert.org packets = system.tsunami.etherdev.rxPackets 4516877Ssteve.reinhardt@amd.com if options.graph: 4526877Ssteve.reinhardt@amd.com graphdata(runs, options, 'packets', 'Packets', packets) 4536657Snate@binkert.org else: 4546877Ssteve.reinhardt@amd.com printdata(runs, packets) 4556877Ssteve.reinhardt@amd.com return 4566877Ssteve.reinhardt@amd.com 4576877Ssteve.reinhardt@amd.com if command == 'ppt' or command == 'tpp': 4586877Ssteve.reinhardt@amd.com ppt = system.tsunami.etherdev.rxPackets / sim_ticks 4596969SBrad.Beckmann@amd.com printdata(runs, ppt, command == 'tpp') 4608532SLisa.Hsu@amd.com return 4616657Snate@binkert.org 4627567SBrad.Beckmann@amd.com if command == 'pps': 4637567SBrad.Beckmann@amd.com pps = system.tsunami.etherdev.rxPackets / sim_seconds 4647567SBrad.Beckmann@amd.com if options.graph: 4657567SBrad.Beckmann@amd.com graphdata(runs, options, 'pps', 'Packets/s', pps) 4667567SBrad.Beckmann@amd.com else: 4677567SBrad.Beckmann@amd.com printdata(runs, pps) 4686657Snate@binkert.org return 4696882SBrad.Beckmann@amd.com 4706882SBrad.Beckmann@amd.com if command == 'bpt' or command == 'tpb': 4716882SBrad.Beckmann@amd.com bytes = system.tsunami.etherdev.rxBytes + system.tsunami.etherdev.txBytes 4726882SBrad.Beckmann@amd.com bpt = bytes / sim_ticks * 8 4736882SBrad.Beckmann@amd.com if options.graph: 4746882SBrad.Beckmann@amd.com graphdata(runs, options, 'bpt', 'bps / Hz', bpt) 4756882SBrad.Beckmann@amd.com else: 4768189SLisa.Hsu@amd.com printdata(runs, bpt, command == 'tpb') 4778189SLisa.Hsu@amd.com return 4786877Ssteve.reinhardt@amd.com 4798189SLisa.Hsu@amd.com if command == 'bptb' or command == 'tpbb': 4808189SLisa.Hsu@amd.com bytes = system.tsunami.etherdev.rxBytes + system.tsunami.etherdev.txBytes 4818189SLisa.Hsu@amd.com 4828189SLisa.Hsu@amd.com print 'kernel stats' 4836882SBrad.Beckmann@amd.com bytes.bins = 'kernel' 4846882SBrad.Beckmann@amd.com printdata(runs, bytes / ticks) 4856882SBrad.Beckmann@amd.com 4866882SBrad.Beckmann@amd.com print 'idle stats' 4876882SBrad.Beckmann@amd.com bytes.bins = 'idle' 4886882SBrad.Beckmann@amd.com printdata(runs, bytes / ticks) 4896882SBrad.Beckmann@amd.com 4906882SBrad.Beckmann@amd.com print 'user stats' 4916882SBrad.Beckmann@amd.com bytes.bins = 'user' 4926882SBrad.Beckmann@amd.com printdata(runs, bytes / ticks) 4938189SLisa.Hsu@amd.com 4946882SBrad.Beckmann@amd.com return 4956882SBrad.Beckmann@amd.com 4966882SBrad.Beckmann@amd.com if command == 'bytes': 4978189SLisa.Hsu@amd.com stat = system.tsunami.etherdev.rxBytes + system.tsunami.etherdev.txBytes 4988189SLisa.Hsu@amd.com 4998189SLisa.Hsu@amd.com if options.binned: 5008189SLisa.Hsu@amd.com print '%s kernel stats' % stat.name 5016888SBrad.Beckmann@amd.com stat.bins = 'kernel' 5026888SBrad.Beckmann@amd.com printdata(runs, stat) 5036888SBrad.Beckmann@amd.com 5046888SBrad.Beckmann@amd.com print '%s idle stats' % stat.name 5056888SBrad.Beckmann@amd.com stat.bins = 'idle' 5068189SLisa.Hsu@amd.com printdata(runs, stat) 5076888SBrad.Beckmann@amd.com 5086888SBrad.Beckmann@amd.com print '%s user stats' % stat.name 5096657Snate@binkert.org stat.bins = 'user' 5106888SBrad.Beckmann@amd.com printdata(runs, stat) 5116888SBrad.Beckmann@amd.com 5126888SBrad.Beckmann@amd.com print '%s total stats' % stat.name 5136888SBrad.Beckmann@amd.com stat.bins = None 5146657Snate@binkert.org 5156657Snate@binkert.org printdata(runs, stat) 5166657Snate@binkert.org return 5176657Snate@binkert.org 5186657Snate@binkert.org if command == 'rxbps': 5196657Snate@binkert.org gbps = system.tsunami.etherdev.rxBandwidth / 1e9 5206657Snate@binkert.org if options.graph: 5216657Snate@binkert.org graphdata(runs, options, 'rxbps', 'Bandwidth (Gbps)', gbps) 5226657Snate@binkert.org else: 5237007Snate@binkert.org printdata(runs, gbps) 5247007Snate@binkert.org return 5256657Snate@binkert.org 5267007Snate@binkert.org if command == 'txbps': 5277007Snate@binkert.org gbps = system.tsunami.etherdev.txBandwidth / 1e9 5287007Snate@binkert.org if options.graph: 5296657Snate@binkert.org graphdata(runs, options, 'txbps', 'Bandwidth (Gbps)', gbps) 5306657Snate@binkert.org else: 5316657Snate@binkert.org printdata(runs, gbps) 5327007Snate@binkert.org return 5337542SBrad.Beckmann@amd.com 5347542SBrad.Beckmann@amd.com if command == 'bps': 5357007Snate@binkert.org rxbps = system.tsunami.etherdev.rxBandwidth 5366657Snate@binkert.org txbps = system.tsunami.etherdev.txBandwidth 5376657Snate@binkert.org gbps = (rxbps + txbps) / 1e9 5386657Snate@binkert.org if options.graph: 5396657Snate@binkert.org graphdata(runs, options, 'bps', 'Bandwidth (Gbps)', gbps) 5406657Snate@binkert.org else: 5416657Snate@binkert.org printdata(runs, gbps) 5426657Snate@binkert.org return 5436657Snate@binkert.org 5446657Snate@binkert.org if command == 'misses': 5456657Snate@binkert.org stat = system.L2.overall_mshr_misses 5466657Snate@binkert.org if options.binned: 5476657Snate@binkert.org print '%s kernel stats' % stat.name 5486657Snate@binkert.org stat.bins = 'kernel' 5496657Snate@binkert.org printdata(runs, stat) 5506657Snate@binkert.org 5516657Snate@binkert.org print '%s idle stats' % stat.name 5526657Snate@binkert.org stat.bins = 'idle' 5536657Snate@binkert.org printdata(runs, stat) 5546657Snate@binkert.org 5556657Snate@binkert.org print '%s user stats' % stat.name 5566657Snate@binkert.org stat.bins = 'user' 5576657Snate@binkert.org printdata(runs, stat) 5586657Snate@binkert.org 5596657Snate@binkert.org print '%s total stats' % stat.name 5606657Snate@binkert.org 5616657Snate@binkert.org stat.bins = None 5626657Snate@binkert.org if options.graph: 5636657Snate@binkert.org graphdata(runs, options, 'misses', 'Overall MSHR Misses', stat) 5647007Snate@binkert.org else: 5656657Snate@binkert.org printdata(runs, stat) 5666657Snate@binkert.org return 5676657Snate@binkert.org 5686657Snate@binkert.org if command == 'mpkb': 5697007Snate@binkert.org misses = system.L2.overall_mshr_misses 5706657Snate@binkert.org rxbytes = system.tsunami.etherdev.rxBytes 5717007Snate@binkert.org txbytes = system.tsunami.etherdev.txBytes 5727007Snate@binkert.org 5736657Snate@binkert.org if options.binned: 5746657Snate@binkert.org print 'mpkb kernel stats' 5756657Snate@binkert.org misses.bins = 'kernel' 5766657Snate@binkert.org mpkb = misses / ((rxbytes + txbytes) / 1024) 5776657Snate@binkert.org printdata(runs, mpkb) 5786657Snate@binkert.org 5796657Snate@binkert.org print 'mpkb idle stats' 5806657Snate@binkert.org misses.bins = 'idle' 5816657Snate@binkert.org mpkb = misses / ((rxbytes + txbytes) / 1024) 5826657Snate@binkert.org printdata(runs, mpkb) 5836657Snate@binkert.org 5846657Snate@binkert.org print 'mpkb user stats' 5856657Snate@binkert.org misses.bins = 'user' 5866657Snate@binkert.org mpkb = misses / ((rxbytes + txbytes) / 1024) 5876657Snate@binkert.org printdata(runs, mpkb) 5887566SBrad.Beckmann@amd.com 5896657Snate@binkert.org print 'mpkb total stats' 5906657Snate@binkert.org 5916657Snate@binkert.org mpkb = misses / ((rxbytes + txbytes) / 1024) 5926657Snate@binkert.org misses.bins = None 5936657Snate@binkert.org if options.graph: 5948308Stushar@csail.mit.edu graphdata(runs, options, 'mpkb', 'Misses / KB', mpkb) 5956657Snate@binkert.org else: 5966657Snate@binkert.org printdata(runs, mpkb) 5976657Snate@binkert.org return 5987007Snate@binkert.org 5997007Snate@binkert.org if command == 'ipkb': 6008308Stushar@csail.mit.edu interrupts = system.full_cpu.kern.faults[4] 6016657Snate@binkert.org rxbytes = system.tsunami.etherdev.rxBytes 6026657Snate@binkert.org txbytes = system.tsunami.etherdev.txBytes 6036657Snate@binkert.org 6046657Snate@binkert.org if options.binned: 6056657Snate@binkert.org print 'ipkb kernel stats' 6066657Snate@binkert.org interrupts.bins = 'kernel' 6076657Snate@binkert.org ipkb = interrupts / ((rxbytes + txbytes) / 1024) 6086657Snate@binkert.org printdata(runs, ipkb) 6096657Snate@binkert.org 6106657Snate@binkert.org print 'ipkb idle stats' 6116657Snate@binkert.org interrupts.bins = 'idle' 6126657Snate@binkert.org ipkb = interrupts / ((rxbytes + txbytes) / 1024) 6138187SLisa.Hsu@amd.com printdata(runs, ipkb) 6146657Snate@binkert.org 6156657Snate@binkert.org print 'ipkb user stats' 6166657Snate@binkert.org interrupts.bins = 'user' 6176657Snate@binkert.org ipkb = interrupts / ((rxbytes + txbytes) / 1024) 6186657Snate@binkert.org printdata(runs, ipkb) 6196657Snate@binkert.org 6206657Snate@binkert.org print 'ipkb total stats' 6216657Snate@binkert.org 6226657Snate@binkert.org ipkb = interrupts / ((rxbytes + txbytes) / 1024) 6237454Snate@binkert.org interrupts.bins = None 6246657Snate@binkert.org if options.graph: 6256657Snate@binkert.org graphdata(runs, options, 'ipkb', 'Interrupts / KB', ipkb) 6266657Snate@binkert.org else: 6276657Snate@binkert.org printdata(runs, ipkb) 6287007Snate@binkert.org return 6297056Snate@binkert.org 6307007Snate@binkert.org if command == 'execute': 6317007Snate@binkert.org printdata(runs, system.full_cpu.ISSUE__count) 6326657Snate@binkert.org return 6337566SBrad.Beckmann@amd.com 6347566SBrad.Beckmann@amd.com if command == 'commit': 6357566SBrad.Beckmann@amd.com printdata(runs, system.full_cpu.COM__count) 6367566SBrad.Beckmann@amd.com return 6377566SBrad.Beckmann@amd.com 6387566SBrad.Beckmann@amd.com if command == 'fetch': 6397566SBrad.Beckmann@amd.com printdata(runs, system.full_cpu.FETCH__count) 6406657Snate@binkert.org return 6417672Snate@binkert.org 6426657Snate@binkert.org if command == 'bpp': 6436657Snate@binkert.org ed = system.tsunami.etherdev 6446657Snate@binkert.org bpp = (ed.rxBytes + ed.txBytes) / (ed.rxPackets + ed.txPackets) 6456657Snate@binkert.org if options.graph: 6467672Snate@binkert.org graphdata(runs, options, 'bpp', 'Bytes / Packet', bpp) 6476657Snate@binkert.org else: 6487056Snate@binkert.org printdata(runs, bpp) 6496657Snate@binkert.org return 6506657Snate@binkert.org 6517672Snate@binkert.org if command == 'rxbpp': 6526657Snate@binkert.org bpp = system.tsunami.etherdev.rxBytes / system.tsunami.etherdev.rxPackets 6536657Snate@binkert.org if options.graph: 6546657Snate@binkert.org graphdata(runs, options, 'rxbpp', 'Receive Bytes / Packet', bpp) 6556657Snate@binkert.org else: 6566657Snate@binkert.org printdata(runs, bpp) 6576657Snate@binkert.org return 6586657Snate@binkert.org 6596657Snate@binkert.org if command == 'txbpp': 6606657Snate@binkert.org bpp = system.tsunami.etherdev.txBytes / system.tsunami.etherdev.txPackets 6616657Snate@binkert.org if options.graph: 6626657Snate@binkert.org graphdata(runs, options, 'txbpp', 'Transmit Bytes / Packet', bpp) 6637542SBrad.Beckmann@amd.com else: 6646657Snate@binkert.org printdata(runs, bpp) 6656657Snate@binkert.org return 6666657Snate@binkert.org 6676657Snate@binkert.org if command == 'rtp': 6686657Snate@binkert.org rtp = system.tsunami.etherdev.rxPackets / system.tsunami.etherdev.txPackets 6696657Snate@binkert.org if options.graph: 6706657Snate@binkert.org graphdata(runs, options, 'rtp', 'rxPackets / txPackets', rtp) 6716657Snate@binkert.org else: 6726657Snate@binkert.org printdata(runs, rtp) 6736657Snate@binkert.org return 6746657Snate@binkert.org 6756657Snate@binkert.org if command == 'rtb': 6766657Snate@binkert.org rtb = system.tsunami.etherdev.rxBytes / system.tsunami.etherdev.txBytes 6776657Snate@binkert.org if options.graph: 6786657Snate@binkert.org graphdata(runs, options, 'rtb', 'rxBytes / txBytes', rtb) 6797007Snate@binkert.org else: 6807007Snate@binkert.org printdata(runs, rtb) 6817007Snate@binkert.org return 6826657Snate@binkert.org 6836657Snate@binkert.org raise CommandException 6846657Snate@binkert.org 6857007Snate@binkert.org 6867007Snate@binkert.orgclass Options: pass 6877007Snate@binkert.org 6886657Snate@binkert.orgif __name__ == '__main__': 6896657Snate@binkert.org import getpass 6906657Snate@binkert.org 6917007Snate@binkert.org options = Options() 6927007Snate@binkert.org options.host = 'zizzer.pool' 6937007Snate@binkert.org options.db = None 6946657Snate@binkert.org options.passwd = '' 6956657Snate@binkert.org options.user = getpass.getuser() 6966657Snate@binkert.org options.runs = None 6977007Snate@binkert.org options.system = 'client' 6987007Snate@binkert.org options.get = None 6997007Snate@binkert.org options.binned = False 7006657Snate@binkert.org options.graph = False 7016657Snate@binkert.org options.graph68 = False 7026657Snate@binkert.org options.ticks = False 7037007Snate@binkert.org 7047007Snate@binkert.org opts, args = getopts(sys.argv[1:], '-6BEFGd:g:h:pr:s:u:T:') 7057007Snate@binkert.org for o,a in opts: 7066657Snate@binkert.org if o == '-6': 7076657Snate@binkert.org options.graph68 = True 7087007Snate@binkert.org if o == '-B': 7097007Snate@binkert.org options.binned = True 7107007Snate@binkert.org if o == '-E': 7117007Snate@binkert.org printval.mode = 'E' 7126657Snate@binkert.org if o == '-F': 7136657Snate@binkert.org printval.mode = 'F' 7146657Snate@binkert.org if o == '-G': 7157007Snate@binkert.org options.graph = True; 7167567SBrad.Beckmann@amd.com if o == '-d': 7177567SBrad.Beckmann@amd.com options.db = a 7187567SBrad.Beckmann@amd.com if o == '-g': 7197567SBrad.Beckmann@amd.com options.get = a 7207567SBrad.Beckmann@amd.com if o == '-h': 7217567SBrad.Beckmann@amd.com options.host = a 7227567SBrad.Beckmann@amd.com if o == '-p': 7237567SBrad.Beckmann@amd.com options.passwd = getpass.getpass() 7247567SBrad.Beckmann@amd.com if o == '-r': 7257567SBrad.Beckmann@amd.com options.runs = a 7267567SBrad.Beckmann@amd.com if o == '-u': 7277567SBrad.Beckmann@amd.com options.user = a 7287567SBrad.Beckmann@amd.com if o == '-s': 7298155Snilay@cs.wisc.edu options.system = a 7308155Snilay@cs.wisc.edu if o == '-T': 7318155Snilay@cs.wisc.edu options.ticks = a 7328155Snilay@cs.wisc.edu 7338155Snilay@cs.wisc.edu if len(args) == 0: 7348155Snilay@cs.wisc.edu usage() 7358155Snilay@cs.wisc.edu 7368155Snilay@cs.wisc.edu command = args[0] 7378155Snilay@cs.wisc.edu args = args[1:] 7388155Snilay@cs.wisc.edu 7398155Snilay@cs.wisc.edu try: 7407567SBrad.Beckmann@amd.com commands(options, command, args) 7418155Snilay@cs.wisc.edu except CommandException: 7428155Snilay@cs.wisc.edu usage() 7437567SBrad.Beckmann@amd.com