stats.py revision 1308
11049Sbinkertn@umich.edu#!/usr/bin/env python 21049Sbinkertn@umich.edufrom __future__ import division 31049Sbinkertn@umich.eduimport re, sys 41049Sbinkertn@umich.edu 51049Sbinkertn@umich.edudef usage(): 61049Sbinkertn@umich.edu print '''\ 71049Sbinkertn@umich.eduUsage: %s [-E] [-F] [-d <db> ] [-g <get> ] [-h <host>] [-p] 81049Sbinkertn@umich.edu [-s <system>] [-r <runs> ] [-u <username>] <command> [command args] 91049Sbinkertn@umich.edu''' % sys.argv[0] 101049Sbinkertn@umich.edu sys.exit(1) 111049Sbinkertn@umich.edu 121049Sbinkertn@umich.edudef getopts(list, flags): 131049Sbinkertn@umich.edu import getopt 141049Sbinkertn@umich.edu try: 151049Sbinkertn@umich.edu opts, args = getopt.getopt(list, flags) 161049Sbinkertn@umich.edu except getopt.GetoptError: 171049Sbinkertn@umich.edu usage() 181049Sbinkertn@umich.edu 191049Sbinkertn@umich.edu return opts, args 201049Sbinkertn@umich.edu 211049Sbinkertn@umich.edudef printval(name, value, invert = False): 221049Sbinkertn@umich.edu if invert and value != 0.0: 231049Sbinkertn@umich.edu value = 1 / value 241049Sbinkertn@umich.edu 251049Sbinkertn@umich.edu if value == (1e300*1e300): 261049Sbinkertn@umich.edu return 271049Sbinkertn@umich.edu 281049Sbinkertn@umich.edu if printval.mode == 'G': 291049Sbinkertn@umich.edu print '%s: %g' % (name, value) 301049Sbinkertn@umich.edu elif printval.mode != 'F' and value > 1e6: 311049Sbinkertn@umich.edu print '%s: %0.5e' % (name, value) 321049Sbinkertn@umich.edu else: 331049Sbinkertn@umich.edu print '%s: %f' % (name, value) 341049Sbinkertn@umich.edu 351049Sbinkertn@umich.eduprintval.mode = 'G' 361049Sbinkertn@umich.edu 371049Sbinkertn@umich.edudef unique(list): 381049Sbinkertn@umich.edu set = {} 391049Sbinkertn@umich.edu map(set.__setitem__, list, []) 401049Sbinkertn@umich.edu return set.keys() 411049Sbinkertn@umich.edu 421307Sbinkertn@umich.edudef graphdata68(runs, options, tag, label, value): 431307Sbinkertn@umich.edu import info 441307Sbinkertn@umich.edu configs = ['ste', 'hte', 'htd', 'ocm', 'occ', 'ocp' ] 451307Sbinkertn@umich.edu benchmarks = [ 'm', 's', 'snt', 'nb1', 'w1', 'w2', 'w3', 'w4', 'nm', 'ns', 'nw1', 'nw2', 'nw3' ] 461307Sbinkertn@umich.edu dmas = [ 'x' ] 471307Sbinkertn@umich.edu caches = [ '2', '4' ] 481307Sbinkertn@umich.edu 491307Sbinkertn@umich.edu names = [] 501307Sbinkertn@umich.edu 511307Sbinkertn@umich.edu bench_system = { 521307Sbinkertn@umich.edu 'm' : 'client', 531307Sbinkertn@umich.edu 's' : 'client', 541307Sbinkertn@umich.edu 'snt' : 'client', 551307Sbinkertn@umich.edu 'nb1' : 'server', 561307Sbinkertn@umich.edu 'nb2' : 'server', 571307Sbinkertn@umich.edu 'nt1' : 'server', 581307Sbinkertn@umich.edu 'nt2' : 'server', 591307Sbinkertn@umich.edu 'w1' : 'server', 601307Sbinkertn@umich.edu 'w2' : 'server', 611307Sbinkertn@umich.edu 'w3' : 'server', 621307Sbinkertn@umich.edu 'w4' : 'server', 631307Sbinkertn@umich.edu 'w1s' : 'server', 641307Sbinkertn@umich.edu 'w2s' : 'server', 651307Sbinkertn@umich.edu 'w3s' : 'server', 661307Sbinkertn@umich.edu 'ns' : 'natbox', 671307Sbinkertn@umich.edu 'nm' : 'natbox', 681307Sbinkertn@umich.edu 'nw1' : 'natbox', 691307Sbinkertn@umich.edu 'nw2' : 'natbox', 701307Sbinkertn@umich.edu 'nw3' : 'natbox' 711307Sbinkertn@umich.edu } 721307Sbinkertn@umich.edu 731307Sbinkertn@umich.edu for bench in benchmarks: 741307Sbinkertn@umich.edu if bench_system[bench] != options.system: 751307Sbinkertn@umich.edu continue 761307Sbinkertn@umich.edu 771307Sbinkertn@umich.edu for dma in dmas: 781307Sbinkertn@umich.edu for cache in caches: 791307Sbinkertn@umich.edu names.append([bench, dma, cache]) 801307Sbinkertn@umich.edu 811307Sbinkertn@umich.edu for bench,dma,cache in names: 821307Sbinkertn@umich.edu base = '%s.%s.%s' % (bench, dma, cache) 831307Sbinkertn@umich.edu fname = 'data/%s.%s.68.dat' % (tag, base) 841307Sbinkertn@umich.edu f = open(fname, 'w') 851307Sbinkertn@umich.edu print >>f, '#set TITLE = ' 861307Sbinkertn@umich.edu print >>f, '#set ylbl = %s' % label 871307Sbinkertn@umich.edu #print >>f, '#set sublabels = %s' % ' '.join(configs) 881307Sbinkertn@umich.edu print >>f, '#set sublabels = ste hte htd ocm occ ocs' 891307Sbinkertn@umich.edu 901307Sbinkertn@umich.edu for speed,freq in zip(['s', '6', '8', 'q'],['4GHz', '6GHz','8GHz', '10GHz']): 911307Sbinkertn@umich.edu print >>f, '"%s"' % freq, 921307Sbinkertn@umich.edu for conf in configs: 931307Sbinkertn@umich.edu name = '%s.%s.%s.%s.%s' % (conf, bench, dma, cache, speed) 941307Sbinkertn@umich.edu run = info.source.allRunNames[name] 951307Sbinkertn@umich.edu info.display_run = run.run; 961307Sbinkertn@umich.edu val = float(value) 971307Sbinkertn@umich.edu if val == 1e300*1e300: 981307Sbinkertn@umich.edu print >>f, 0.0, 991307Sbinkertn@umich.edu else: 1001307Sbinkertn@umich.edu print >>f, "%f" % val, 1011307Sbinkertn@umich.edu print >>f 1021307Sbinkertn@umich.edu f.close() 1031307Sbinkertn@umich.edu 1041269Sbinkertn@umich.edudef graphdata(runs, options, tag, label, value): 1051307Sbinkertn@umich.edu if options.graph68: 1061307Sbinkertn@umich.edu graphdata68(runs, options, tag, label, value) 1071307Sbinkertn@umich.edu return 1081307Sbinkertn@umich.edu 1091049Sbinkertn@umich.edu import info 1101269Sbinkertn@umich.edu configs = ['ste', 'hte', 'htd', 'ocm', 'occ', 'ocp' ] 1111269Sbinkertn@umich.edu #benchmarks = [ 'm', 's', 'nb1', 'nb2', 'nt1', 'nt2', 'w1', 'w2', 'w3', 'w4', 'ns', 'nm', 'nw1', 'nw2', 'nw3' ] 1121269Sbinkertn@umich.edu #benchmarks = [ 'm', 's', 'nb1', 'nb2', 'nt1', 'w1', 'w2', 'w3', 'ns', 'nm', 'w1s' ] 1131269Sbinkertn@umich.edu benchmarks = [ 'm', 's', 'nb1', 'nb2', 'w1', 'w2', 'w3', 'w4', 'ns', 'nm', 'nw1', 'snt' ] 1141269Sbinkertn@umich.edu #dmas = [ 'x', 'd', 'b' ] 1151269Sbinkertn@umich.edu dmas = [ 'x' ] 1161162Sbinkertn@umich.edu caches = [ '2', '4' ] 1171049Sbinkertn@umich.edu 1181049Sbinkertn@umich.edu names = [] 1191269Sbinkertn@umich.edu 1201269Sbinkertn@umich.edu bench_system = { 1211269Sbinkertn@umich.edu 'm' : 'client', 1221269Sbinkertn@umich.edu 's' : 'client', 1231269Sbinkertn@umich.edu 'snt' : 'client', 1241269Sbinkertn@umich.edu 'nb1' : 'server', 1251269Sbinkertn@umich.edu 'nb2' : 'server', 1261269Sbinkertn@umich.edu 'nt1' : 'server', 1271269Sbinkertn@umich.edu 'nt2' : 'server', 1281269Sbinkertn@umich.edu 'w1' : 'server', 1291269Sbinkertn@umich.edu 'w2' : 'server', 1301269Sbinkertn@umich.edu 'w3' : 'server', 1311269Sbinkertn@umich.edu 'w4' : 'server', 1321269Sbinkertn@umich.edu 'w1s' : 'server', 1331269Sbinkertn@umich.edu 'w2s' : 'server', 1341269Sbinkertn@umich.edu 'w3s' : 'server', 1351269Sbinkertn@umich.edu 'ns' : 'natbox', 1361269Sbinkertn@umich.edu 'nm' : 'natbox', 1371269Sbinkertn@umich.edu 'nw1' : 'natbox', 1381269Sbinkertn@umich.edu 'nw2' : 'natbox', 1391269Sbinkertn@umich.edu 'nw3' : 'natbox' 1401269Sbinkertn@umich.edu } 1411269Sbinkertn@umich.edu 1421049Sbinkertn@umich.edu for bench in benchmarks: 1431269Sbinkertn@umich.edu if bench_system[bench] != options.system: 1441269Sbinkertn@umich.edu continue 1451269Sbinkertn@umich.edu 1461049Sbinkertn@umich.edu for dma in dmas: 1471049Sbinkertn@umich.edu for cache in caches: 1481269Sbinkertn@umich.edu names.append([bench, dma, cache]) 1491049Sbinkertn@umich.edu 1501269Sbinkertn@umich.edu for bench,dma,cache in names: 1511269Sbinkertn@umich.edu base = '%s.%s.%s' % (bench, dma, cache) 1521165Sbinkertn@umich.edu fname = 'data/%s.%s.dat' % (tag, base) 1531049Sbinkertn@umich.edu f = open(fname, 'w') 1541307Sbinkertn@umich.edu print >>f, '#set TITLE = ' 1551049Sbinkertn@umich.edu print >>f, '#set ylbl = %s' % label 1561307Sbinkertn@umich.edu #print >>f, '#set sublabels = %s' % ' '.join(configs) 1571307Sbinkertn@umich.edu print >>f, '#set sublabels = ste hte htd ocm occ ocs' 1581049Sbinkertn@umich.edu 1591049Sbinkertn@umich.edu for speed,freq in zip(['s', 'q'],['4GHz','10GHz']): 1601049Sbinkertn@umich.edu print >>f, '"%s"' % freq, 1611049Sbinkertn@umich.edu for conf in configs: 1621269Sbinkertn@umich.edu name = '%s.%s.%s.%s.%s' % (conf, bench, dma, cache, speed) 1631049Sbinkertn@umich.edu run = info.source.allRunNames[name] 1641049Sbinkertn@umich.edu info.display_run = run.run; 1651049Sbinkertn@umich.edu val = float(value) 1661049Sbinkertn@umich.edu if val == 1e300*1e300: 1671049Sbinkertn@umich.edu print >>f, 0.0, 1681049Sbinkertn@umich.edu else: 1691049Sbinkertn@umich.edu print >>f, "%f" % val, 1701049Sbinkertn@umich.edu print >>f 1711049Sbinkertn@umich.edu f.close() 1721049Sbinkertn@umich.edu 1731049Sbinkertn@umich.edudef printdata(runs, value, invert = False): 1741049Sbinkertn@umich.edu import info 1751049Sbinkertn@umich.edu for run in runs: 1761049Sbinkertn@umich.edu info.display_run = run.run; 1771049Sbinkertn@umich.edu val = float(value) 1781049Sbinkertn@umich.edu printval(run.name, val) 1791049Sbinkertn@umich.edu 1801049Sbinkertn@umich.educlass CommandException(Exception): 1811049Sbinkertn@umich.edu pass 1821049Sbinkertn@umich.edu 1831049Sbinkertn@umich.edudef commands(options, command, args): 1841049Sbinkertn@umich.edu if command == 'database': 1851049Sbinkertn@umich.edu if len(args) == 0: raise CommandException 1861049Sbinkertn@umich.edu 1871049Sbinkertn@umich.edu import dbinit 1881049Sbinkertn@umich.edu mydb = dbinit.MyDB(options) 1891049Sbinkertn@umich.edu 1901049Sbinkertn@umich.edu if args[0] == 'drop': 1911049Sbinkertn@umich.edu if len(args) > 2: raise CommandException 1921049Sbinkertn@umich.edu mydb.admin() 1931049Sbinkertn@umich.edu mydb.drop() 1941049Sbinkertn@umich.edu if len(args) == 2 and args[1] == 'init': 1951049Sbinkertn@umich.edu mydb.create() 1961049Sbinkertn@umich.edu mydb.connect() 1971049Sbinkertn@umich.edu mydb.populate() 1981049Sbinkertn@umich.edu mydb.close() 1991049Sbinkertn@umich.edu return 2001049Sbinkertn@umich.edu 2011049Sbinkertn@umich.edu if args[0] == 'init': 2021049Sbinkertn@umich.edu if len(args) > 1: raise CommandException 2031049Sbinkertn@umich.edu mydb.admin() 2041049Sbinkertn@umich.edu mydb.create() 2051049Sbinkertn@umich.edu mydb.connect() 2061049Sbinkertn@umich.edu mydb.populate() 2071049Sbinkertn@umich.edu mydb.close() 2081049Sbinkertn@umich.edu return 2091049Sbinkertn@umich.edu 2101049Sbinkertn@umich.edu if args[0] == 'clean': 2111049Sbinkertn@umich.edu if len(args) > 1: raise CommandException 2121049Sbinkertn@umich.edu mydb.connect() 2131049Sbinkertn@umich.edu mydb.clean() 2141049Sbinkertn@umich.edu return 2151049Sbinkertn@umich.edu 2161049Sbinkertn@umich.edu raise CommandException 2171049Sbinkertn@umich.edu 2181049Sbinkertn@umich.edu import db, info 2191049Sbinkertn@umich.edu info.source = db.Database() 2201049Sbinkertn@umich.edu info.source.host = options.host 2211049Sbinkertn@umich.edu info.source.db = options.db 2221049Sbinkertn@umich.edu info.source.passwd = options.passwd 2231049Sbinkertn@umich.edu info.source.user = options.user 2241049Sbinkertn@umich.edu info.source.connect() 2251049Sbinkertn@umich.edu info.source.update_dict(globals()) 2261049Sbinkertn@umich.edu 2271049Sbinkertn@umich.edu if type(options.get) is str: 2281049Sbinkertn@umich.edu info.source.get = options.get 2291049Sbinkertn@umich.edu 2301049Sbinkertn@umich.edu if options.runs is None: 2311049Sbinkertn@umich.edu runs = info.source.allRuns 2321049Sbinkertn@umich.edu else: 2331049Sbinkertn@umich.edu rx = re.compile(options.runs) 2341049Sbinkertn@umich.edu runs = [] 2351049Sbinkertn@umich.edu for run in info.source.allRuns: 2361049Sbinkertn@umich.edu if rx.match(run.name): 2371049Sbinkertn@umich.edu runs.append(run) 2381049Sbinkertn@umich.edu 2391049Sbinkertn@umich.edu info.display_run = runs[0].run 2401049Sbinkertn@umich.edu 2411049Sbinkertn@umich.edu if command == 'runs': 2421049Sbinkertn@umich.edu user = None 2431049Sbinkertn@umich.edu opts, args = getopts(args, '-u') 2441049Sbinkertn@umich.edu if len(args): 2451049Sbinkertn@umich.edu raise CommandException 2461049Sbinkertn@umich.edu for o,a in opts: 2471049Sbinkertn@umich.edu if o == '-u': 2481049Sbinkertn@umich.edu user = a 2491049Sbinkertn@umich.edu info.source.listRuns(user) 2501049Sbinkertn@umich.edu return 2511049Sbinkertn@umich.edu 2521049Sbinkertn@umich.edu if command == 'stats': 2531049Sbinkertn@umich.edu if len(args) == 0: 2541049Sbinkertn@umich.edu info.source.listStats() 2551049Sbinkertn@umich.edu elif len(args) == 1: 2561049Sbinkertn@umich.edu info.source.listStats(args[0]) 2571049Sbinkertn@umich.edu else: 2581049Sbinkertn@umich.edu raise CommandException 2591049Sbinkertn@umich.edu 2601049Sbinkertn@umich.edu return 2611049Sbinkertn@umich.edu 2621049Sbinkertn@umich.edu if command == 'stat': 2631049Sbinkertn@umich.edu if len(args) != 1: 2641049Sbinkertn@umich.edu raise CommandException 2651049Sbinkertn@umich.edu 2661049Sbinkertn@umich.edu stats = info.source.getStat(args[0]) 2671049Sbinkertn@umich.edu for stat in stats: 2681076Sbinkertn@umich.edu if options.graph: 2691269Sbinkertn@umich.edu graphdata(runs, options, stat.name, stat.name, stat) 2701049Sbinkertn@umich.edu else: 2711301Ssaidi@eecs.umich.edu if options.ticks: 2721301Ssaidi@eecs.umich.edu print 'only displaying sample %s' % options.ticks 2731301Ssaidi@eecs.umich.edu stat.ticks = options.ticks 2741301Ssaidi@eecs.umich.edu 2751165Sbinkertn@umich.edu if options.binned: 2761165Sbinkertn@umich.edu print 'kernel ticks' 2771165Sbinkertn@umich.edu stat.bins = 'kernel' 2781165Sbinkertn@umich.edu printdata(runs, stat) 2791165Sbinkertn@umich.edu 2801165Sbinkertn@umich.edu print 'idle ticks' 2811165Sbinkertn@umich.edu stat.bins = 'idle' 2821165Sbinkertn@umich.edu printdata(runs, stat) 2831165Sbinkertn@umich.edu 2841165Sbinkertn@umich.edu print 'user ticks' 2851165Sbinkertn@umich.edu stat.bins = 'user' 2861165Sbinkertn@umich.edu printdata(runs, stat) 2871165Sbinkertn@umich.edu 2881165Sbinkertn@umich.edu print 'interrupt ticks' 2891301Ssaidi@eecs.umich.edu stat.bins = 'interrupt' 2901165Sbinkertn@umich.edu printdata(runs, stat) 2911165Sbinkertn@umich.edu 2921165Sbinkertn@umich.edu print 'total ticks' 2931165Sbinkertn@umich.edu 2941165Sbinkertn@umich.edu stat.bins = None 2951049Sbinkertn@umich.edu print stat.name 2961049Sbinkertn@umich.edu printdata(runs, stat) 2971049Sbinkertn@umich.edu return 2981049Sbinkertn@umich.edu 2991269Sbinkertn@umich.edu if command == 'formula': 3001269Sbinkertn@umich.edu if len(args) != 1: 3011269Sbinkertn@umich.edu raise CommandException 3021269Sbinkertn@umich.edu 3031269Sbinkertn@umich.edu stats = eval(args[0]) 3041269Sbinkertn@umich.edu for stat in stats: 3051269Sbinkertn@umich.edu if options.graph: 3061269Sbinkertn@umich.edu graphdata(runs, options, stat.name, stat.name, stat) 3071269Sbinkertn@umich.edu else: 3081269Sbinkertn@umich.edu if options.binned: 3091269Sbinkertn@umich.edu print 'kernel ticks' 3101269Sbinkertn@umich.edu stat.bins = 'kernel' 3111269Sbinkertn@umich.edu printdata(runs, stat) 3121269Sbinkertn@umich.edu 3131269Sbinkertn@umich.edu print 'idle ticks' 3141269Sbinkertn@umich.edu stat.bins = 'idle' 3151269Sbinkertn@umich.edu printdata(runs, stat) 3161269Sbinkertn@umich.edu 3171269Sbinkertn@umich.edu print 'user ticks' 3181269Sbinkertn@umich.edu stat.bins = 'user' 3191269Sbinkertn@umich.edu printdata(runs, stat) 3201269Sbinkertn@umich.edu 3211269Sbinkertn@umich.edu print 'interrupt ticks' 3221301Ssaidi@eecs.umich.edu stat.bins = 'interrupt' 3231269Sbinkertn@umich.edu printdata(runs, stat) 3241269Sbinkertn@umich.edu 3251269Sbinkertn@umich.edu print 'total ticks' 3261269Sbinkertn@umich.edu 3271269Sbinkertn@umich.edu stat.bins = None 3281269Sbinkertn@umich.edu print args[0] 3291269Sbinkertn@umich.edu printdata(runs, stat) 3301269Sbinkertn@umich.edu return 3311269Sbinkertn@umich.edu 3321049Sbinkertn@umich.edu if command == 'bins': 3331049Sbinkertn@umich.edu if len(args) == 0: 3341049Sbinkertn@umich.edu info.source.listBins() 3351049Sbinkertn@umich.edu elif len(args) == 1: 3361049Sbinkertn@umich.edu info.source.listBins(args[0]) 3371049Sbinkertn@umich.edu else: 3381049Sbinkertn@umich.edu raise CommandException 3391049Sbinkertn@umich.edu 3401049Sbinkertn@umich.edu return 3411049Sbinkertn@umich.edu 3421049Sbinkertn@umich.edu if command == 'formulas': 3431049Sbinkertn@umich.edu if len(args) == 0: 3441049Sbinkertn@umich.edu info.source.listFormulas() 3451049Sbinkertn@umich.edu elif len(args) == 1: 3461049Sbinkertn@umich.edu info.source.listFormulas(args[0]) 3471049Sbinkertn@umich.edu else: 3481049Sbinkertn@umich.edu raise CommandException 3491049Sbinkertn@umich.edu 3501049Sbinkertn@umich.edu return 3511049Sbinkertn@umich.edu 3521049Sbinkertn@umich.edu if command == 'samples': 3531049Sbinkertn@umich.edu if len(args): 3541049Sbinkertn@umich.edu raise CommandException 3551049Sbinkertn@umich.edu 3561049Sbinkertn@umich.edu info.source.listTicks(runs) 3571049Sbinkertn@umich.edu return 3581049Sbinkertn@umich.edu 3591049Sbinkertn@umich.edu if len(args): 3601049Sbinkertn@umich.edu raise CommandException 3611049Sbinkertn@umich.edu 3621209Sbinkertn@umich.edu system = info.source.__dict__[options.system] 3631209Sbinkertn@umich.edu 3641049Sbinkertn@umich.edu if command == 'usertime': 3651049Sbinkertn@umich.edu import copy 3661049Sbinkertn@umich.edu kernel = copy.copy(system.full_cpu.numCycles) 3671049Sbinkertn@umich.edu kernel.bins = 'kernel' 3681049Sbinkertn@umich.edu 3691049Sbinkertn@umich.edu user = copy.copy(system.full_cpu.numCycles) 3701049Sbinkertn@umich.edu user.bins = 'user' 3711049Sbinkertn@umich.edu 3721076Sbinkertn@umich.edu if options.graph: 3731269Sbinkertn@umich.edu graphdata(runs, options, 'usertime', 'User Fraction', 3741049Sbinkertn@umich.edu user / system.full_cpu.numCycles) 3751049Sbinkertn@umich.edu else: 3761049Sbinkertn@umich.edu printdata(runs, user / system.full_cpu.numCycles) 3771049Sbinkertn@umich.edu return 3781049Sbinkertn@umich.edu 3791049Sbinkertn@umich.edu if command == 'ticks': 3801076Sbinkertn@umich.edu if options.binned: 3811049Sbinkertn@umich.edu print 'kernel ticks' 3821049Sbinkertn@umich.edu system.full_cpu.numCycles.bins = 'kernel' 3831049Sbinkertn@umich.edu printdata(runs, system.full_cpu.numCycles) 3841049Sbinkertn@umich.edu 3851049Sbinkertn@umich.edu print 'idle ticks' 3861049Sbinkertn@umich.edu system.full_cpu.numCycles.bins = 'idle' 3871049Sbinkertn@umich.edu printdata(runs, system.full_cpu.numCycles) 3881049Sbinkertn@umich.edu 3891049Sbinkertn@umich.edu print 'user ticks' 3901049Sbinkertn@umich.edu system.full_cpu.numCycles.bins = 'user' 3911049Sbinkertn@umich.edu printdata(runs, system.full_cpu.numCycles) 3921049Sbinkertn@umich.edu 3931049Sbinkertn@umich.edu print 'total ticks' 3941049Sbinkertn@umich.edu 3951049Sbinkertn@umich.edu system.full_cpu.numCycles.bins = None 3961049Sbinkertn@umich.edu printdata(runs, system.full_cpu.numCycles) 3971049Sbinkertn@umich.edu return 3981049Sbinkertn@umich.edu 3991049Sbinkertn@umich.edu if command == 'packets': 4001162Sbinkertn@umich.edu packets = system.tsunami.etherdev.rxPackets 4011076Sbinkertn@umich.edu if options.graph: 4021269Sbinkertn@umich.edu graphdata(runs, options, 'packets', 'Packets', packets) 4031049Sbinkertn@umich.edu else: 4041049Sbinkertn@umich.edu printdata(runs, packets) 4051049Sbinkertn@umich.edu return 4061049Sbinkertn@umich.edu 4071049Sbinkertn@umich.edu if command == 'ppt' or command == 'tpp': 4081162Sbinkertn@umich.edu ppt = system.tsunami.etherdev.rxPackets / sim_ticks 4091049Sbinkertn@umich.edu printdata(runs, ppt, command == 'tpp') 4101049Sbinkertn@umich.edu return 4111049Sbinkertn@umich.edu 4121049Sbinkertn@umich.edu if command == 'pps': 4131162Sbinkertn@umich.edu pps = system.tsunami.etherdev.rxPackets / sim_seconds 4141076Sbinkertn@umich.edu if options.graph: 4151269Sbinkertn@umich.edu graphdata(runs, options, 'pps', 'Packets/s', pps) 4161049Sbinkertn@umich.edu else: 4171049Sbinkertn@umich.edu printdata(runs, pps) 4181049Sbinkertn@umich.edu return 4191049Sbinkertn@umich.edu 4201049Sbinkertn@umich.edu if command == 'bpt' or command == 'tpb': 4211162Sbinkertn@umich.edu bytes = system.tsunami.etherdev.rxBytes + system.tsunami.etherdev.txBytes 4221049Sbinkertn@umich.edu bpt = bytes / sim_ticks * 8 4231076Sbinkertn@umich.edu if options.graph: 4241269Sbinkertn@umich.edu graphdata(runs, options, 'bpt', 'bps / Hz', bpt) 4251049Sbinkertn@umich.edu else: 4261049Sbinkertn@umich.edu printdata(runs, bpt, command == 'tpb') 4271049Sbinkertn@umich.edu return 4281049Sbinkertn@umich.edu 4291049Sbinkertn@umich.edu if command == 'bptb' or command == 'tpbb': 4301162Sbinkertn@umich.edu bytes = system.tsunami.etherdev.rxBytes + system.tsunami.etherdev.txBytes 4311049Sbinkertn@umich.edu 4321049Sbinkertn@umich.edu print 'kernel stats' 4331049Sbinkertn@umich.edu bytes.bins = 'kernel' 4341049Sbinkertn@umich.edu printdata(runs, bytes / ticks) 4351049Sbinkertn@umich.edu 4361049Sbinkertn@umich.edu print 'idle stats' 4371049Sbinkertn@umich.edu bytes.bins = 'idle' 4381049Sbinkertn@umich.edu printdata(runs, bytes / ticks) 4391049Sbinkertn@umich.edu 4401049Sbinkertn@umich.edu print 'user stats' 4411049Sbinkertn@umich.edu bytes.bins = 'user' 4421049Sbinkertn@umich.edu printdata(runs, bytes / ticks) 4431049Sbinkertn@umich.edu 4441049Sbinkertn@umich.edu return 4451049Sbinkertn@umich.edu 4461049Sbinkertn@umich.edu if command == 'bytes': 4471162Sbinkertn@umich.edu stat = system.tsunami.etherdev.rxBytes + system.tsunami.etherdev.txBytes 4481049Sbinkertn@umich.edu 4491076Sbinkertn@umich.edu if options.binned: 4501049Sbinkertn@umich.edu print '%s kernel stats' % stat.name 4511049Sbinkertn@umich.edu stat.bins = 'kernel' 4521049Sbinkertn@umich.edu printdata(runs, stat) 4531049Sbinkertn@umich.edu 4541049Sbinkertn@umich.edu print '%s idle stats' % stat.name 4551049Sbinkertn@umich.edu stat.bins = 'idle' 4561049Sbinkertn@umich.edu printdata(runs, stat) 4571049Sbinkertn@umich.edu 4581049Sbinkertn@umich.edu print '%s user stats' % stat.name 4591049Sbinkertn@umich.edu stat.bins = 'user' 4601049Sbinkertn@umich.edu printdata(runs, stat) 4611049Sbinkertn@umich.edu 4621049Sbinkertn@umich.edu print '%s total stats' % stat.name 4631049Sbinkertn@umich.edu stat.bins = None 4641049Sbinkertn@umich.edu 4651049Sbinkertn@umich.edu printdata(runs, stat) 4661049Sbinkertn@umich.edu return 4671049Sbinkertn@umich.edu 4681049Sbinkertn@umich.edu if command == 'rxbps': 4691162Sbinkertn@umich.edu gbps = system.tsunami.etherdev.rxBandwidth / 1e9 4701076Sbinkertn@umich.edu if options.graph: 4711269Sbinkertn@umich.edu graphdata(runs, options, 'rxbps', 'Bandwidth (Gbps)', gbps) 4721049Sbinkertn@umich.edu else: 4731049Sbinkertn@umich.edu printdata(runs, gbps) 4741049Sbinkertn@umich.edu return 4751049Sbinkertn@umich.edu 4761049Sbinkertn@umich.edu if command == 'txbps': 4771162Sbinkertn@umich.edu gbps = system.tsunami.etherdev.txBandwidth / 1e9 4781076Sbinkertn@umich.edu if options.graph: 4791269Sbinkertn@umich.edu graphdata(runs, options, 'txbps', 'Bandwidth (Gbps)', gbps) 4801049Sbinkertn@umich.edu else: 4811049Sbinkertn@umich.edu printdata(runs, gbps) 4821049Sbinkertn@umich.edu return 4831049Sbinkertn@umich.edu 4841049Sbinkertn@umich.edu if command == 'bps': 4851162Sbinkertn@umich.edu rxbps = system.tsunami.etherdev.rxBandwidth 4861162Sbinkertn@umich.edu txbps = system.tsunami.etherdev.txBandwidth 4871049Sbinkertn@umich.edu gbps = (rxbps + txbps) / 1e9 4881076Sbinkertn@umich.edu if options.graph: 4891269Sbinkertn@umich.edu graphdata(runs, options, 'bps', 'Bandwidth (Gbps)', gbps) 4901049Sbinkertn@umich.edu else: 4911049Sbinkertn@umich.edu printdata(runs, gbps) 4921049Sbinkertn@umich.edu return 4931049Sbinkertn@umich.edu 4941049Sbinkertn@umich.edu if command == 'misses': 4951162Sbinkertn@umich.edu stat = system.L2.overall_mshr_misses 4961076Sbinkertn@umich.edu if options.binned: 4971049Sbinkertn@umich.edu print '%s kernel stats' % stat.name 4981049Sbinkertn@umich.edu stat.bins = 'kernel' 4991049Sbinkertn@umich.edu printdata(runs, stat) 5001049Sbinkertn@umich.edu 5011049Sbinkertn@umich.edu print '%s idle stats' % stat.name 5021049Sbinkertn@umich.edu stat.bins = 'idle' 5031049Sbinkertn@umich.edu printdata(runs, stat) 5041049Sbinkertn@umich.edu 5051049Sbinkertn@umich.edu print '%s user stats' % stat.name 5061049Sbinkertn@umich.edu stat.bins = 'user' 5071049Sbinkertn@umich.edu printdata(runs, stat) 5081049Sbinkertn@umich.edu 5091049Sbinkertn@umich.edu print '%s total stats' % stat.name 5101049Sbinkertn@umich.edu 5111049Sbinkertn@umich.edu stat.bins = None 5121076Sbinkertn@umich.edu if options.graph: 5131269Sbinkertn@umich.edu graphdata(runs, options, 'misses', 'Overall MSHR Misses', stat) 5141049Sbinkertn@umich.edu else: 5151049Sbinkertn@umich.edu printdata(runs, stat) 5161049Sbinkertn@umich.edu return 5171049Sbinkertn@umich.edu 5181049Sbinkertn@umich.edu if command == 'mpkb': 5191162Sbinkertn@umich.edu misses = system.L2.overall_mshr_misses 5201162Sbinkertn@umich.edu rxbytes = system.tsunami.etherdev.rxBytes 5211162Sbinkertn@umich.edu txbytes = system.tsunami.etherdev.txBytes 5221049Sbinkertn@umich.edu 5231076Sbinkertn@umich.edu if options.binned: 5241049Sbinkertn@umich.edu print 'mpkb kernel stats' 5251049Sbinkertn@umich.edu misses.bins = 'kernel' 5261049Sbinkertn@umich.edu mpkb = misses / ((rxbytes + txbytes) / 1024) 5271049Sbinkertn@umich.edu printdata(runs, mpkb) 5281049Sbinkertn@umich.edu 5291049Sbinkertn@umich.edu print 'mpkb idle stats' 5301049Sbinkertn@umich.edu misses.bins = 'idle' 5311049Sbinkertn@umich.edu mpkb = misses / ((rxbytes + txbytes) / 1024) 5321049Sbinkertn@umich.edu printdata(runs, mpkb) 5331049Sbinkertn@umich.edu 5341049Sbinkertn@umich.edu print 'mpkb user stats' 5351049Sbinkertn@umich.edu misses.bins = 'user' 5361049Sbinkertn@umich.edu mpkb = misses / ((rxbytes + txbytes) / 1024) 5371049Sbinkertn@umich.edu printdata(runs, mpkb) 5381049Sbinkertn@umich.edu 5391049Sbinkertn@umich.edu print 'mpkb total stats' 5401049Sbinkertn@umich.edu 5411049Sbinkertn@umich.edu mpkb = misses / ((rxbytes + txbytes) / 1024) 5421049Sbinkertn@umich.edu misses.bins = None 5431076Sbinkertn@umich.edu if options.graph: 5441269Sbinkertn@umich.edu graphdata(runs, options, 'mpkb', 'Misses / KB', mpkb) 5451049Sbinkertn@umich.edu else: 5461049Sbinkertn@umich.edu printdata(runs, mpkb) 5471049Sbinkertn@umich.edu return 5481049Sbinkertn@umich.edu 5491269Sbinkertn@umich.edu if command == 'ipkb': 5501269Sbinkertn@umich.edu interrupts = system.full_cpu.kern.faults[4] 5511269Sbinkertn@umich.edu rxbytes = system.tsunami.etherdev.rxBytes 5521269Sbinkertn@umich.edu txbytes = system.tsunami.etherdev.txBytes 5531269Sbinkertn@umich.edu 5541269Sbinkertn@umich.edu if options.binned: 5551269Sbinkertn@umich.edu print 'ipkb kernel stats' 5561269Sbinkertn@umich.edu interrupts.bins = 'kernel' 5571269Sbinkertn@umich.edu ipkb = interrupts / ((rxbytes + txbytes) / 1024) 5581269Sbinkertn@umich.edu printdata(runs, ipkb) 5591269Sbinkertn@umich.edu 5601269Sbinkertn@umich.edu print 'ipkb idle stats' 5611269Sbinkertn@umich.edu interrupts.bins = 'idle' 5621269Sbinkertn@umich.edu ipkb = interrupts / ((rxbytes + txbytes) / 1024) 5631269Sbinkertn@umich.edu printdata(runs, ipkb) 5641269Sbinkertn@umich.edu 5651269Sbinkertn@umich.edu print 'ipkb user stats' 5661269Sbinkertn@umich.edu interrupts.bins = 'user' 5671269Sbinkertn@umich.edu ipkb = interrupts / ((rxbytes + txbytes) / 1024) 5681269Sbinkertn@umich.edu printdata(runs, ipkb) 5691269Sbinkertn@umich.edu 5701269Sbinkertn@umich.edu print 'ipkb total stats' 5711269Sbinkertn@umich.edu 5721269Sbinkertn@umich.edu ipkb = interrupts / ((rxbytes + txbytes) / 1024) 5731269Sbinkertn@umich.edu interrupts.bins = None 5741269Sbinkertn@umich.edu if options.graph: 5751269Sbinkertn@umich.edu graphdata(runs, options, 'ipkb', 'Interrupts / KB', ipkb) 5761269Sbinkertn@umich.edu else: 5771269Sbinkertn@umich.edu printdata(runs, ipkb) 5781269Sbinkertn@umich.edu return 5791269Sbinkertn@umich.edu 5801049Sbinkertn@umich.edu if command == 'execute': 5811049Sbinkertn@umich.edu printdata(runs, system.full_cpu.ISSUE__count) 5821049Sbinkertn@umich.edu return 5831049Sbinkertn@umich.edu 5841049Sbinkertn@umich.edu if command == 'commit': 5851049Sbinkertn@umich.edu printdata(runs, system.full_cpu.COM__count) 5861049Sbinkertn@umich.edu return 5871049Sbinkertn@umich.edu 5881049Sbinkertn@umich.edu if command == 'fetch': 5891049Sbinkertn@umich.edu printdata(runs, system.full_cpu.FETCH__count) 5901049Sbinkertn@umich.edu return 5911049Sbinkertn@umich.edu 5921162Sbinkertn@umich.edu if command == 'bpp': 5931162Sbinkertn@umich.edu ed = system.tsunami.etherdev 5941162Sbinkertn@umich.edu bpp = (ed.rxBytes + ed.txBytes) / (ed.rxPackets + ed.txPackets) 5951162Sbinkertn@umich.edu if options.graph: 5961269Sbinkertn@umich.edu graphdata(runs, options, 'bpp', 'Bytes / Packet', bpp) 5971162Sbinkertn@umich.edu else: 5981162Sbinkertn@umich.edu printdata(runs, bpp) 5991162Sbinkertn@umich.edu return 6001162Sbinkertn@umich.edu 6011049Sbinkertn@umich.edu if command == 'rxbpp': 6021162Sbinkertn@umich.edu bpp = system.tsunami.etherdev.rxBytes / system.tsunami.etherdev.rxPackets 6031162Sbinkertn@umich.edu if options.graph: 6041269Sbinkertn@umich.edu graphdata(runs, options, 'rxbpp', 'Receive Bytes / Packet', bpp) 6051162Sbinkertn@umich.edu else: 6061162Sbinkertn@umich.edu printdata(runs, bpp) 6071049Sbinkertn@umich.edu return 6081049Sbinkertn@umich.edu 6091049Sbinkertn@umich.edu if command == 'txbpp': 6101162Sbinkertn@umich.edu bpp = system.tsunami.etherdev.txBytes / system.tsunami.etherdev.txPackets 6111162Sbinkertn@umich.edu if options.graph: 6121269Sbinkertn@umich.edu graphdata(runs, options, 'txbpp', 'Transmit Bytes / Packet', bpp) 6131162Sbinkertn@umich.edu else: 6141162Sbinkertn@umich.edu printdata(runs, bpp) 6151162Sbinkertn@umich.edu return 6161162Sbinkertn@umich.edu 6171162Sbinkertn@umich.edu if command == 'rtp': 6181162Sbinkertn@umich.edu rtp = system.tsunami.etherdev.rxPackets / system.tsunami.etherdev.txPackets 6191162Sbinkertn@umich.edu if options.graph: 6201269Sbinkertn@umich.edu graphdata(runs, options, 'rtp', 'rxPackets / txPackets', rtp) 6211162Sbinkertn@umich.edu else: 6221162Sbinkertn@umich.edu printdata(runs, rtp) 6231162Sbinkertn@umich.edu return 6241162Sbinkertn@umich.edu 6251162Sbinkertn@umich.edu if command == 'rtb': 6261162Sbinkertn@umich.edu rtb = system.tsunami.etherdev.rxBytes / system.tsunami.etherdev.txBytes 6271162Sbinkertn@umich.edu if options.graph: 6281269Sbinkertn@umich.edu graphdata(runs, options, 'rtb', 'rxBytes / txBytes', rtb) 6291162Sbinkertn@umich.edu else: 6301162Sbinkertn@umich.edu printdata(runs, rtb) 6311049Sbinkertn@umich.edu return 6321049Sbinkertn@umich.edu 6331049Sbinkertn@umich.edu raise CommandException 6341049Sbinkertn@umich.edu 6351049Sbinkertn@umich.edu 6361049Sbinkertn@umich.educlass Options: pass 6371049Sbinkertn@umich.edu 6381049Sbinkertn@umich.eduif __name__ == '__main__': 6391049Sbinkertn@umich.edu import getpass 6401049Sbinkertn@umich.edu 6411049Sbinkertn@umich.edu options = Options() 6421049Sbinkertn@umich.edu options.host = 'zizzer.pool' 6431049Sbinkertn@umich.edu options.db = None 6441049Sbinkertn@umich.edu options.passwd = '' 6451049Sbinkertn@umich.edu options.user = getpass.getuser() 6461049Sbinkertn@umich.edu options.runs = None 6471049Sbinkertn@umich.edu options.system = 'client' 6481049Sbinkertn@umich.edu options.get = None 6491076Sbinkertn@umich.edu options.binned = False 6501076Sbinkertn@umich.edu options.graph = False 6511307Sbinkertn@umich.edu options.graph68 = False 6521301Ssaidi@eecs.umich.edu options.ticks = False 6531049Sbinkertn@umich.edu 6541308Ssaidi@eecs.umich.edu opts, args = getopts(sys.argv[1:], '-6BEFGd:g:h:pr:s:u:T:') 6551049Sbinkertn@umich.edu for o,a in opts: 6561307Sbinkertn@umich.edu if o == '-6': 6571307Sbinkertn@umich.edu options.graph68 = True 6581049Sbinkertn@umich.edu if o == '-B': 6591049Sbinkertn@umich.edu options.binned = True 6601049Sbinkertn@umich.edu if o == '-E': 6611049Sbinkertn@umich.edu printval.mode = 'E' 6621049Sbinkertn@umich.edu if o == '-F': 6631049Sbinkertn@umich.edu printval.mode = 'F' 6641049Sbinkertn@umich.edu if o == '-G': 6651049Sbinkertn@umich.edu options.graph = True; 6661049Sbinkertn@umich.edu if o == '-d': 6671049Sbinkertn@umich.edu options.db = a 6681049Sbinkertn@umich.edu if o == '-g': 6691049Sbinkertn@umich.edu options.get = a 6701049Sbinkertn@umich.edu if o == '-h': 6711049Sbinkertn@umich.edu options.host = a 6721049Sbinkertn@umich.edu if o == '-p': 6731049Sbinkertn@umich.edu options.passwd = getpass.getpass() 6741049Sbinkertn@umich.edu if o == '-r': 6751049Sbinkertn@umich.edu options.runs = a 6761049Sbinkertn@umich.edu if o == '-u': 6771049Sbinkertn@umich.edu options.user = a 6781049Sbinkertn@umich.edu if o == '-s': 6791049Sbinkertn@umich.edu options.system = a 6801301Ssaidi@eecs.umich.edu if o == '-T': 6811301Ssaidi@eecs.umich.edu options.ticks = a 6821049Sbinkertn@umich.edu 6831049Sbinkertn@umich.edu if len(args) == 0: 6841049Sbinkertn@umich.edu usage() 6851049Sbinkertn@umich.edu 6861049Sbinkertn@umich.edu command = args[0] 6871049Sbinkertn@umich.edu args = args[1:] 6881049Sbinkertn@umich.edu 6891049Sbinkertn@umich.edu try: 6901049Sbinkertn@umich.edu commands(options, command, args) 6911049Sbinkertn@umich.edu except CommandException: 6921049Sbinkertn@umich.edu usage() 693