2 from __future__
import division
7 Usage: %s [-E] [-F] [-d <db> ] [-g <get> ] [-h <host>] [-p]
8 [-s <system>] [-r <runs> ] [-u <username>] <command> [command args]
12 def getopts(list, flags
):
15 opts
, args
= getopt
.getopt(list, flags
)
16 except getopt
.GetoptError
:
21 def printval(name
, value
, invert
= False):
22 if invert
and value
!= 0.0:
25 if value
== (1e300
*1e300
):
28 if printval
.mode
== 'G':
29 print '%s: %g' % (name
, value
)
30 elif printval
.mode
!= 'F' and value
> 1e6
:
31 print '%s: %0.5e' % (name
, value
)
33 print '%s: %f' % (name
, value
)
39 map(set.__setitem
__, list, [])
42 def graphdata68(runs
, options
, tag
, label
, value
):
44 configs
= ['ste', 'hte', 'htd', 'ocm', 'occ', 'ocp' ]
45 benchmarks
= [ 'm', 's', 'snt', 'nb1', 'w1', 'w2', 'w3', 'w4', 'nm', 'ns', 'nw1', 'nw2', 'nw3' ]
73 for bench
in benchmarks
:
74 if bench_system
[bench
] != options
.system
:
79 names
.append([bench
, dma
, cache
])
81 for bench
,dma
,cache
in names
:
82 base
= '%s.%s.%s' % (bench
, dma
, cache
)
83 fname
= 'data/%s.%s.68.dat' % (tag
, base
)
85 print >>f
, '#set TITLE = '
86 print >>f
, '#set ylbl = %s' % label
87 #print >>f, '#set sublabels = %s' % ' '.join(configs)
88 print >>f
, '#set sublabels = ste hte htd ocm occ ocs'
90 for speed
,freq
in zip(['s', '6', '8', 'q'],['4GHz', '6GHz','8GHz', '10GHz']):
91 print >>f
, '"%s"' % freq
,
93 name
= '%s.%s.%s.%s.%s' % (conf
, bench
, dma
, cache
, speed
)
94 run
= info
.source
.allRunNames
[name
]
95 info
.display_run
= run
.run
;
97 if val
== 1e300
*1e300
:
100 print >>f
, "%f" % val
,
104 def graphdata(runs
, options
, tag
, label
, value
):
106 graphdata68(runs
, options
, tag
, label
, value
)
110 configs
= ['ste', 'hte', 'htd', 'ocm', 'occ', 'ocp' ]
111 #benchmarks = [ 'm', 's', 'nb1', 'nb2', 'nt1', 'nt2', 'w1', 'w2', 'w3', 'w4', 'ns', 'nm', 'nw1', 'nw2', 'nw3' ]
112 #benchmarks = [ 'm', 's', 'nb1', 'nb2', 'nt1', 'w1', 'w2', 'w3', 'ns', 'nm', 'w1s' ]
113 benchmarks
= [ 'm', 's', 'nb1', 'nb2', 'w1', 'w2', 'w3', 'w4', 'ns', 'nm', 'nw1', 'snt' ]
114 #dmas = [ 'x', 'd', 'b' ]
116 caches
= [ '2', '4' ]
142 for bench
in benchmarks
:
143 if bench_system
[bench
] != options
.system
:
148 names
.append([bench
, dma
, cache
])
150 for bench
,dma
,cache
in names
:
151 base
= '%s.%s.%s' % (bench
, dma
, cache
)
152 fname
= 'data/%s.%s.dat' % (tag
, base
)
154 print >>f
, '#set TITLE = '
155 print >>f
, '#set ylbl = %s' % label
156 #print >>f, '#set sublabels = %s' % ' '.join(configs)
157 print >>f
, '#set sublabels = ste hte htd ocm occ ocs'
159 for speed
,freq
in zip(['s', 'q'],['4GHz','10GHz']):
160 print >>f
, '"%s"' % freq
,
162 name
= '%s.%s.%s.%s.%s' % (conf
, bench
, dma
, cache
, speed
)
163 run
= info
.source
.allRunNames
[name
]
164 info
.display_run
= run
.run
;
166 if val
== 1e300
*1e300
:
169 print >>f
, "%f" % val
,
173 def printdata(runs
, value
, invert
= False):
176 info
.display_run
= run
.run
;
178 printval(run
.name
, val
)
180 class CommandException(Exception):
183 def commands(options
, command
, args
):
184 if command
== 'database':
185 if len(args
) == 0: raise CommandException
188 mydb
= dbinit
.MyDB(options
)
190 if args
[0] == 'drop':
191 if len(args
) > 2: raise CommandException
194 if len(args
) == 2 and args
[1] == 'init':
201 if args
[0] == 'init':
202 if len(args
) > 1: raise CommandException
210 if args
[0] == 'clean':
211 if len(args
) > 1: raise CommandException
216 raise CommandException
219 info
.source
= db
.Database()
220 info
.source
.host
= options
.host
221 info
.source
.db
= options
.db
222 info
.source
.passwd
= options
.passwd
223 info
.source
.user
= options
.user
224 info
.source
.connect()
225 info
.source
.update_dict(globals())
227 if type(options
.get
) is str:
228 info
.source
.get
= options
.get
230 if options
.runs
is None:
231 runs
= info
.source
.allRuns
233 rx
= re
.compile(options
.runs
)
235 for run
in info
.source
.allRuns
:
236 if rx
.match(run
.name
):
239 info
.display_run
= runs
[0].run
241 if command
== 'runs':
243 opts
, args
= getopts(args
, '-u')
245 raise CommandException
249 info
.source
.listRuns(user
)
252 if command
== 'stability':
253 stats
= info
.source
.getStat(args
[0])
254 info
.source
.get
= "avg"
256 #loop through all the stats selected
259 print "%s:" % stat
.name
260 print "%-30s %12s %12s %4s %5s %5s %5s" % \
261 ("run name", "average", "stdev", ">10%", ">1SDV", ">2SDV", "SAMP")
262 print "%-30s %12s %12s %4s %5s %5s %5s" % \
263 ("------------------------------", "------------",
264 "------------", "----", "-----", "-----", "-----")
265 #loop through all the selected runs
267 info
.display_run
= run
.run
;
268 runTicks
= info
.source
.retTicks([ run
])
269 #throw away the first one, it's 0
271 stat
.ticks
= runTicks
278 #loop through all the various ticks for each run
279 for tick
in runTicks
:
280 stat
.ticks
= str(tick
)
282 if (val
< (avg
* .9)) or (val
> (avg
* 1.1)):
284 stdev
+= pow((val
-avg
),2)
286 stdev
= math
.sqrt(stdev
/ len(runTicks
))
287 for tick
in runTicks
:
288 stat
.ticks
= str(tick
)
290 if (val
< (avg
- stdev
)) or (val
> (avg
+ stdev
)):
292 if (val
< (avg
- (2*stdev
))) or (val
> (avg
+ (2*stdev
))):
295 print "%-30s %12s %12s %4s %5s %5s %5s" % \
296 (run
.name
, "%.1f" % avg
, "%.1f" % stdev
,
297 "%d" % numoutsideavg
, "%d" % numoutside1std
,
298 "%d" % numoutside2std
, "%d" % len(runTicks
))
302 if command
== 'stats':
304 info
.source
.listStats()
306 info
.source
.listStats(args
[0])
308 raise CommandException
312 if command
== 'stat':
314 raise CommandException
316 stats
= info
.source
.getStat(args
[0])
319 graphdata(runs
, options
, stat
.name
, stat
.name
, stat
)
322 print 'only displaying sample %s' % options
.ticks
323 stat
.ticks
= options
.ticks
328 printdata(runs
, stat
)
332 printdata(runs
, stat
)
336 printdata(runs
, stat
)
338 print 'interrupt ticks'
339 stat
.bins
= 'interrupt'
340 printdata(runs
, stat
)
346 printdata(runs
, stat
)
349 if command
== 'formula':
351 raise CommandException
353 stats
= eval(args
[0])
356 graphdata(runs
, options
, stat
.name
, stat
.name
, stat
)
361 printdata(runs
, stat
)
365 printdata(runs
, stat
)
369 printdata(runs
, stat
)
371 print 'interrupt ticks'
372 stat
.bins
= 'interrupt'
373 printdata(runs
, stat
)
379 printdata(runs
, stat
)
382 if command
== 'bins':
384 info
.source
.listBins()
386 info
.source
.listBins(args
[0])
388 raise CommandException
392 if command
== 'formulas':
394 info
.source
.listFormulas()
396 info
.source
.listFormulas(args
[0])
398 raise CommandException
402 if command
== 'samples':
404 raise CommandException
406 info
.source
.listTicks(runs
)
410 raise CommandException
412 system
= info
.source
.__dict
__[options
.system
]
414 if command
== 'usertime':
416 kernel
= copy
.copy(system
.full_cpu
.numCycles
)
417 kernel
.bins
= 'kernel'
419 user
= copy
.copy(system
.full_cpu
.numCycles
)
423 graphdata(runs
, options
, 'usertime', 'User Fraction',
424 user
/ system
.full_cpu
.numCycles
)
426 printdata(runs
, user
/ system
.full_cpu
.numCycles
)
429 if command
== 'ticks':
432 system
.full_cpu
.numCycles
.bins
= 'kernel'
433 printdata(runs
, system
.full_cpu
.numCycles
)
436 system
.full_cpu
.numCycles
.bins
= 'idle'
437 printdata(runs
, system
.full_cpu
.numCycles
)
440 system
.full_cpu
.numCycles
.bins
= 'user'
441 printdata(runs
, system
.full_cpu
.numCycles
)
445 system
.full_cpu
.numCycles
.bins
= None
446 printdata(runs
, system
.full_cpu
.numCycles
)
449 if command
== 'packets':
450 packets
= system
.tsunami
.etherdev
.rxPackets
452 graphdata(runs
, options
, 'packets', 'Packets', packets
)
454 printdata(runs
, packets
)
457 if command
== 'ppt' or command
== 'tpp':
458 ppt
= system
.tsunami
.etherdev
.rxPackets
/ sim_ticks
459 printdata(runs
, ppt
, command
== 'tpp')
463 pps
= system
.tsunami
.etherdev
.rxPackets
/ sim_seconds
465 graphdata(runs
, options
, 'pps', 'Packets/s', pps
)
470 if command
== 'bpt' or command
== 'tpb':
471 bytes
= system
.tsunami
.etherdev
.rxBytes
+ system
.tsunami
.etherdev
.txBytes
472 bpt
= bytes
/ sim_ticks
* 8
474 graphdata(runs
, options
, 'bpt', 'bps / Hz', bpt
)
476 printdata(runs
, bpt
, command
== 'tpb')
479 if command
== 'bptb' or command
== 'tpbb':
480 bytes
= system
.tsunami
.etherdev
.rxBytes
+ system
.tsunami
.etherdev
.txBytes
483 bytes
.bins
= 'kernel'
484 printdata(runs
, bytes
/ ticks
)
488 printdata(runs
, bytes
/ ticks
)
492 printdata(runs
, bytes
/ ticks
)
496 if command
== 'bytes':
497 stat
= system
.tsunami
.etherdev
.rxBytes
+ system
.tsunami
.etherdev
.txBytes
500 print '%s kernel stats' % stat
.name
502 printdata(runs
, stat
)
504 print '%s idle stats' % stat
.name
506 printdata(runs
, stat
)
508 print '%s user stats' % stat
.name
510 printdata(runs
, stat
)
512 print '%s total stats' % stat
.name
515 printdata(runs
, stat
)
518 if command
== 'rxbps':
519 gbps
= system
.tsunami
.etherdev
.rxBandwidth
/ 1e9
521 graphdata(runs
, options
, 'rxbps', 'Bandwidth (Gbps)', gbps
)
523 printdata(runs
, gbps
)
526 if command
== 'txbps':
527 gbps
= system
.tsunami
.etherdev
.txBandwidth
/ 1e9
529 graphdata(runs
, options
, 'txbps', 'Bandwidth (Gbps)', gbps
)
531 printdata(runs
, gbps
)
535 rxbps
= system
.tsunami
.etherdev
.rxBandwidth
536 txbps
= system
.tsunami
.etherdev
.txBandwidth
537 gbps
= (rxbps
+ txbps
) / 1e9
539 graphdata(runs
, options
, 'bps', 'Bandwidth (Gbps)', gbps
)
541 printdata(runs
, gbps
)
544 if command
== 'misses':
545 stat
= system
.L2
.overall_mshr_misses
547 print '%s kernel stats' % stat
.name
549 printdata(runs
, stat
)
551 print '%s idle stats' % stat
.name
553 printdata(runs
, stat
)
555 print '%s user stats' % stat
.name
557 printdata(runs
, stat
)
559 print '%s total stats' % stat
.name
563 graphdata(runs
, options
, 'misses', 'Overall MSHR Misses', stat
)
565 printdata(runs
, stat
)
568 if command
== 'mpkb':
569 misses
= system
.L2
.overall_mshr_misses
570 rxbytes
= system
.tsunami
.etherdev
.rxBytes
571 txbytes
= system
.tsunami
.etherdev
.txBytes
574 print 'mpkb kernel stats'
575 misses
.bins
= 'kernel'
576 mpkb
= misses
/ ((rxbytes
+ txbytes
) / 1024)
577 printdata(runs
, mpkb
)
579 print 'mpkb idle stats'
581 mpkb
= misses
/ ((rxbytes
+ txbytes
) / 1024)
582 printdata(runs
, mpkb
)
584 print 'mpkb user stats'
586 mpkb
= misses
/ ((rxbytes
+ txbytes
) / 1024)
587 printdata(runs
, mpkb
)
589 print 'mpkb total stats'
591 mpkb
= misses
/ ((rxbytes
+ txbytes
) / 1024)
594 graphdata(runs
, options
, 'mpkb', 'Misses / KB', mpkb
)
596 printdata(runs
, mpkb
)
599 if command
== 'ipkb':
600 interrupts
= system
.full_cpu
.kern
.faults
[4]
601 rxbytes
= system
.tsunami
.etherdev
.rxBytes
602 txbytes
= system
.tsunami
.etherdev
.txBytes
605 print 'ipkb kernel stats'
606 interrupts
.bins
= 'kernel'
607 ipkb
= interrupts
/ ((rxbytes
+ txbytes
) / 1024)
608 printdata(runs
, ipkb
)
610 print 'ipkb idle stats'
611 interrupts
.bins
= 'idle'
612 ipkb
= interrupts
/ ((rxbytes
+ txbytes
) / 1024)
613 printdata(runs
, ipkb
)
615 print 'ipkb user stats'
616 interrupts
.bins
= 'user'
617 ipkb
= interrupts
/ ((rxbytes
+ txbytes
) / 1024)
618 printdata(runs
, ipkb
)
620 print 'ipkb total stats'
622 ipkb
= interrupts
/ ((rxbytes
+ txbytes
) / 1024)
623 interrupts
.bins
= None
625 graphdata(runs
, options
, 'ipkb', 'Interrupts / KB', ipkb
)
627 printdata(runs
, ipkb
)
630 if command
== 'execute':
631 printdata(runs
, system
.full_cpu
.ISSUE__count
)
634 if command
== 'commit':
635 printdata(runs
, system
.full_cpu
.COM__count
)
638 if command
== 'fetch':
639 printdata(runs
, system
.full_cpu
.FETCH__count
)
643 ed
= system
.tsunami
.etherdev
644 bpp
= (ed
.rxBytes
+ ed
.txBytes
) / (ed
.rxPackets
+ ed
.txPackets
)
646 graphdata(runs
, options
, 'bpp', 'Bytes / Packet', bpp
)
651 if command
== 'rxbpp':
652 bpp
= system
.tsunami
.etherdev
.rxBytes
/ system
.tsunami
.etherdev
.rxPackets
654 graphdata(runs
, options
, 'rxbpp', 'Receive Bytes / Packet', bpp
)
659 if command
== 'txbpp':
660 bpp
= system
.tsunami
.etherdev
.txBytes
/ system
.tsunami
.etherdev
.txPackets
662 graphdata(runs
, options
, 'txbpp', 'Transmit Bytes / Packet', bpp
)
668 rtp
= system
.tsunami
.etherdev
.rxPackets
/ system
.tsunami
.etherdev
.txPackets
670 graphdata(runs
, options
, 'rtp', 'rxPackets / txPackets', rtp
)
676 rtb
= system
.tsunami
.etherdev
.rxBytes
/ system
.tsunami
.etherdev
.txBytes
678 graphdata(runs
, options
, 'rtb', 'rxBytes / txBytes', rtb
)
683 raise CommandException
688 if __name__
== '__main__':
692 options
.host
= 'zizzer.pool'
695 options
.user
= getpass
.getuser()
697 options
.system
= 'client'
699 options
.binned
= False
700 options
.graph
= False
701 options
.graph68
= False
702 options
.ticks
= False
704 opts
, args
= getopts(sys
.argv
[1:], '-6BEFGd:g:h:pr:s:u:T:')
707 options
.graph68
= True
709 options
.binned
= True
715 options
.graph
= True;
723 options
.passwd
= getpass
.getpass()
740 commands(options
, command
, args
)
741 except CommandException
: