3 # Copyright (c) 2003-2004 The Regents of The University of Michigan
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions are
8 # met: redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer;
10 # redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution;
13 # neither the name of the copyright holders nor the names of its
14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission.
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 from __future__
import division
35 Usage: %s [-E] [-F] [-d <db> ] [-g <get> ] [-h <host>] [-p]
36 [-s <system>] [-r <runs> ] [-T <samples>] [-u <username>]
37 <command> [command args]
39 commands extra parameters description
40 ----------- ------------------ ---------------------------------------
41 bins [regex] List bins (only matching regex)
42 formula <formula> Evaluated formula specified
43 formulas [regex] List formulas (only matching regex)
44 runs none List all runs in database
45 samples none List samples present in database
46 stability <pairnum> <stats> Calculated statistical info about stats
47 stat <regex> Show stat data (only matching regex)
48 stats [regex] List all stats (only matching regex)
50 database <command> Where command is drop, init, or clean
55 def getopts(list, flags
):
58 opts
, args
= getopt
.getopt(list, flags
)
59 except getopt
.GetoptError
:
64 def printval(name
, value
, invert
= False):
65 if invert
and value
!= 0.0:
68 if value
== (1e300
*1e300
):
71 if printval
.mode
== 'G':
72 print '%s: %g' % (name
, value
)
73 elif printval
.mode
!= 'F' and value
> 1e6
:
74 print '%s: %0.5e' % (name
, value
)
76 print '%s: %f' % (name
, value
)
82 map(set.__setitem
__, list, [])
85 #benchmarks = [ 'm', 's', 'snt', 'nb1', 'w1', 'w2', 'w3', 'w4', 'nm', 'ns', 'nw1', 'nw2', 'nw3' ]
87 def graphdata(runs
, options
, tag
, label
, value
):
122 configs
= ['ste', 'hte', 'htd', 'ocm', 'occ', 'ocp' ]
123 benchmarks
= [ 'm', 'snt', 'w2', 'nm', 'nw2' ]
124 caches
= [ '0', '2', '4' ]
127 for bench
in benchmarks
:
128 if bench_system
[bench
] != options
.system
:
132 names
.append([bench
, cache
])
134 for bench
,cache
in names
:
135 base
= '%s.%s' % (bench
, cache
)
136 fname
= 'data/uni.%s.%s.dat' % (tag
, base
)
138 print >>f
, '#set TITLE = '
139 print >>f
, '#set ylbl = %s' % label
140 #print >>f, '#set sublabels = %s' % ' '.join(configs)
141 print >>f
, '#set sublabels = ste hte htd ocm occ ocs'
143 for speed
in ('s1', 'm1', 'f1', 'q1'):
144 label
= system_configs
[speed
]
145 print >>f
, '"%s"' % label
,
147 name
= '%s.%s.%s.%s' % (conf
, bench
, cache
, speed
)
148 run
= info
.source
.allRunNames
[name
]
149 info
.display_run
= run
.run
;
151 if val
== 1e300
*1e300
:
154 print >>f
, "%f" % val
,
158 configs
= ['ste', 'hte', 'htd', 'ocm', 'occ', 'ocp' ]
160 caches
= [ '0', '2', '4' ]
163 for bench
in benchmarks
:
164 if bench_system
[bench
] != options
.system
:
168 names
.append([bench
, cache
])
170 for bench
,cache
in names
:
171 base
= '%s.%s' % (bench
, cache
)
172 fname
= 'data/mp.%s.%s.dat' % (tag
, base
)
174 print >>f
, '#set TITLE = '
175 print >>f
, '#set ylbl = %s' % label
176 #print >>f, '#set sublabels = %s' % ' '.join(configs)
177 print >>f
, '#set sublabels = ste hte htd ocm occ ocs'
179 for speed
in ('s2', 'm2', 's4', 'm4'):
180 label
= system_configs
[speed
]
181 print >>f
, '"%s"' % label
,
183 name
= '%s.%s.%s.%s' % (conf
, bench
, cache
, speed
)
184 run
= info
.source
.allRunNames
[name
]
185 info
.display_run
= run
.run
;
187 if val
== 1e300
*1e300
:
190 print >>f
, "%f" % val
,
194 def printdata(runs
, value
, invert
= False):
197 info
.display_run
= run
.run
;
199 printval(run
.name
, val
)
201 class CommandException(Exception):
204 def commands(options
, command
, args
):
205 if command
== 'database':
206 if len(args
) == 0: raise CommandException
209 mydb
= dbinit
.MyDB(options
)
211 if args
[0] == 'drop':
212 if len(args
) > 2: raise CommandException
215 if len(args
) == 2 and args
[1] == 'init':
222 if args
[0] == 'init':
223 if len(args
) > 1: raise CommandException
231 if args
[0] == 'clean':
232 if len(args
) > 1: raise CommandException
237 raise CommandException
240 info
.source
= db
.Database()
241 info
.source
.host
= options
.host
242 info
.source
.db
= options
.db
243 info
.source
.passwd
= options
.passwd
244 info
.source
.user
= options
.user
245 info
.source
.connect()
246 info
.source
.update_dict(globals())
248 if type(options
.get
) is str:
249 info
.source
.get
= options
.get
251 if options
.runs
is None:
252 runs
= info
.source
.allRuns
254 rx
= re
.compile(options
.runs
)
256 for run
in info
.source
.allRuns
:
257 if rx
.match(run
.name
):
260 info
.display_run
= runs
[0].run
262 if command
== 'runs':
264 opts
, args
= getopts(args
, '-u')
266 raise CommandException
270 info
.source
.listRuns(user
)
273 if command
== 'stability':
275 raise CommandException
281 stats
= info
.source
.getStat(args
[1])
282 info
.source
.get
= "sum"
285 #loop through all the stats selected
288 print "%s:" % stat
.name
289 print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
290 ("run name", "average", "stdev", ">10%", ">1SDV", ">2SDV", "SAMP", "CV")
291 print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
292 ("--------------------", "------------",
293 "------------", "----", "-----", "-----", "-----", "----------")
294 #loop through all the selected runs
296 info
.display_run
= run
.run
;
297 runTicks
= info
.source
.retTicks([ run
])
298 #throw away the first one, it's 0
300 info
.globalTicks
= runTicks
307 if float(stat
) == 1e300
*1e300
:
309 for t
in range(0, len(runTicks
)-(merge
-1), merge
):
311 for p
in range(0,merge
):
312 tempPair
.append(runTicks
[t
+p
])
313 pairRunTicks
.append(tempPair
)
314 #loop through all the various ticks for each run
315 for tick
in pairRunTicks
:
316 info
.globalTicks
= tick
318 avg
/= len(pairRunTicks
)
319 for tick
in pairRunTicks
:
320 info
.globalTicks
= tick
322 stdev
+= pow((val
-avg
),2)
323 stdev
= math
.sqrt(stdev
/ len(pairRunTicks
))
324 for tick
in pairRunTicks
:
325 info
.globalTicks
= tick
327 if (val
< (avg
* .9)) or (val
> (avg
* 1.1)):
329 if (val
< (avg
- stdev
)) or (val
> (avg
+ stdev
)):
331 if (val
< (avg
- (2*stdev
))) or (val
> (avg
+ (2*stdev
))):
334 print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
335 (run
.name
, "%.1f" % avg
, "%.1f" % stdev
,
336 "%d" % numoutsideavg
, "%d" % numoutside1std
,
337 "%d" % numoutside2std
, "%d" % len(pairRunTicks
),
338 "%.3f" % (stdev
/avg
*100))
340 print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
341 (run
.name
, "%.1f" % avg
, "%.1f" % stdev
,
342 "%d" % numoutsideavg
, "%d" % numoutside1std
,
343 "%d" % numoutside2std
, "%d" % len(pairRunTicks
),
344 "%.5f" % (stdev
/avg
*100))
346 print "%-20s %12s %12s %4s %5s %5s %5s %10s" % \
347 (run
.name
, "%.5f" % avg
, "%.5f" % stdev
,
348 "%d" % numoutsideavg
, "%d" % numoutside1std
,
349 "%d" % numoutside2std
, "%d" % len(pairRunTicks
),
350 "%.7f" % (stdev
/avg
*100))
353 if command
== 'stats':
355 info
.source
.listStats()
357 info
.source
.listStats(args
[0])
359 raise CommandException
363 if command
== 'stat':
365 raise CommandException
367 stats
= info
.source
.getStat(args
[0])
370 graphdata(runs
, options
, stat
.name
, stat
.name
, stat
)
373 print 'only displaying sample %s' % options
.ticks
374 info
.globalTicks
= [ int(x
) for x
in options
.ticks
.split() ]
379 printdata(runs
, stat
)
383 printdata(runs
, stat
)
387 printdata(runs
, stat
)
389 print 'interrupt ticks'
390 stat
.bins
= 'interrupt'
391 printdata(runs
, stat
)
397 printdata(runs
, stat
)
400 if command
== 'formula':
402 raise CommandException
404 stats
= eval(args
[0])
407 graphdata(runs
, options
, stat
.name
, stat
.name
, stat
)
412 printdata(runs
, stat
)
416 printdata(runs
, stat
)
420 printdata(runs
, stat
)
422 print 'interrupt ticks'
423 stat
.bins
= 'interrupt'
424 printdata(runs
, stat
)
430 printdata(runs
, stat
)
433 if command
== 'bins':
435 info
.source
.listBins()
437 info
.source
.listBins(args
[0])
439 raise CommandException
443 if command
== 'formulas':
445 info
.source
.listFormulas()
447 info
.source
.listFormulas(args
[0])
449 raise CommandException
453 if command
== 'samples':
455 raise CommandException
457 info
.source
.listTicks(runs
)
461 raise CommandException
463 system
= info
.source
.__dict
__[options
.system
]
465 if command
== 'usertime':
467 kernel
= copy
.copy(system
.full0
.numCycles
)
468 kernel
.bins
= 'kernel'
470 user
= copy
.copy(system
.full0
.numCycles
)
474 graphdata(runs
, options
, 'usertime', 'User Fraction',
475 user
/ system
.full0
.numCycles
)
477 printdata(runs
, user
/ system
.full0
.numCycles
)
480 if command
== 'ticks':
483 system
.full0
.numCycles
.bins
= 'kernel'
484 printdata(runs
, system
.full0
.numCycles
)
487 system
.full0
.numCycles
.bins
= 'idle'
488 printdata(runs
, system
.full0
.numCycles
)
491 system
.full0
.numCycles
.bins
= 'user'
492 printdata(runs
, system
.full0
.numCycles
)
496 system
.full0
.numCycles
.bins
= None
497 printdata(runs
, system
.full0
.numCycles
)
500 if command
== 'packets':
501 packets
= system
.tsunami
.etherdev0
.rxPackets
503 graphdata(runs
, options
, 'packets', 'Packets', packets
)
505 printdata(runs
, packets
)
508 if command
== 'ppt' or command
== 'tpp':
509 ppt
= system
.tsunami
.etherdev0
.rxPackets
/ sim_ticks
510 printdata(runs
, ppt
, command
== 'tpp')
514 pps
= system
.tsunami
.etherdev0
.rxPackets
/ sim_seconds
516 graphdata(runs
, options
, 'pps', 'Packets/s', pps
)
521 if command
== 'bpt' or command
== 'tpb':
522 bytes
= system
.tsunami
.etherdev0
.rxBytes
+ system
.tsunami
.etherdev0
.txBytes
523 bpt
= bytes
/ sim_ticks
* 8
525 graphdata(runs
, options
, 'bpt', 'bps / Hz', bpt
)
527 printdata(runs
, bpt
, command
== 'tpb')
530 if command
== 'bptb' or command
== 'tpbb':
531 bytes
= system
.tsunami
.etherdev0
.rxBytes
+ system
.tsunami
.etherdev0
.txBytes
534 bytes
.bins
= 'kernel'
535 printdata(runs
, bytes
/ ticks
)
539 printdata(runs
, bytes
/ ticks
)
543 printdata(runs
, bytes
/ ticks
)
547 if command
== 'bytes':
548 stat
= system
.tsunami
.etherdev0
.rxBytes
+ system
.tsunami
.etherdev0
.txBytes
551 print '%s kernel stats' % stat
.name
553 printdata(runs
, stat
)
555 print '%s idle stats' % stat
.name
557 printdata(runs
, stat
)
559 print '%s user stats' % stat
.name
561 printdata(runs
, stat
)
563 print '%s total stats' % stat
.name
566 printdata(runs
, stat
)
569 if command
== 'rxbps':
570 gbps
= system
.tsunami
.etherdev0
.rxBandwidth
/ 1e9
572 graphdata(runs
, options
, 'rxbps', 'Bandwidth (Gbps)', gbps
)
574 printdata(runs
, gbps
)
577 if command
== 'txbps':
578 gbps
= system
.tsunami
.etherdev0
.txBandwidth
/ 1e9
580 graphdata(runs
, options
, 'txbps', 'Bandwidth (Gbps)', gbps
)
582 printdata(runs
, gbps
)
586 rxbps
= system
.tsunami
.etherdev0
.rxBandwidth
587 txbps
= system
.tsunami
.etherdev0
.txBandwidth
588 gbps
= (rxbps
+ txbps
) / 1e9
590 graphdata(runs
, options
, 'bps', 'Bandwidth (Gbps)', gbps
)
592 printdata(runs
, gbps
)
595 if command
== 'misses':
596 stat
= system
.l2
.overall_mshr_misses
598 print '%s kernel stats' % stat
.name
600 printdata(runs
, stat
)
602 print '%s idle stats' % stat
.name
604 printdata(runs
, stat
)
606 print '%s user stats' % stat
.name
608 printdata(runs
, stat
)
610 print '%s total stats' % stat
.name
614 graphdata(runs
, options
, 'misses', 'Overall MSHR Misses', stat
)
616 printdata(runs
, stat
)
619 if command
== 'mpkb':
620 misses
= system
.l2
.overall_mshr_misses
621 rxbytes
= system
.tsunami
.etherdev0
.rxBytes
622 txbytes
= system
.tsunami
.etherdev0
.txBytes
625 print 'mpkb kernel stats'
626 misses
.bins
= 'kernel'
627 mpkb
= misses
/ ((rxbytes
+ txbytes
) / 1024)
628 printdata(runs
, mpkb
)
630 print 'mpkb idle stats'
632 mpkb
= misses
/ ((rxbytes
+ txbytes
) / 1024)
633 printdata(runs
, mpkb
)
635 print 'mpkb user stats'
637 mpkb
= misses
/ ((rxbytes
+ txbytes
) / 1024)
638 printdata(runs
, mpkb
)
640 print 'mpkb total stats'
642 mpkb
= misses
/ ((rxbytes
+ txbytes
) / 1024)
645 graphdata(runs
, options
, 'mpkb', 'Misses / KB', mpkb
)
647 printdata(runs
, mpkb
)
650 if command
== 'ipkb':
651 interrupts
= system
.full0
.kern
.faults
[4]
652 rxbytes
= system
.tsunami
.etherdev0
.rxBytes
653 txbytes
= system
.tsunami
.etherdev0
.txBytes
656 print 'ipkb kernel stats'
657 interrupts
.bins
= 'kernel'
658 ipkb
= interrupts
/ ((rxbytes
+ txbytes
) / 1024)
659 printdata(runs
, ipkb
)
661 print 'ipkb idle stats'
662 interrupts
.bins
= 'idle'
663 ipkb
= interrupts
/ ((rxbytes
+ txbytes
) / 1024)
664 printdata(runs
, ipkb
)
666 print 'ipkb user stats'
667 interrupts
.bins
= 'user'
668 ipkb
= interrupts
/ ((rxbytes
+ txbytes
) / 1024)
669 printdata(runs
, ipkb
)
671 print 'ipkb total stats'
673 ipkb
= interrupts
/ ((rxbytes
+ txbytes
) / 1024)
674 interrupts
.bins
= None
676 graphdata(runs
, options
, 'ipkb', 'Interrupts / KB', ipkb
)
678 printdata(runs
, ipkb
)
681 if command
== 'execute':
682 printdata(runs
, system
.full0
.ISSUE__count
)
685 if command
== 'commit':
686 printdata(runs
, system
.full0
.COM__count
)
689 if command
== 'fetch':
690 printdata(runs
, system
.full0
.FETCH__count
)
694 ed
= system
.tsunami
.etherdev0
695 bpp
= (ed
.rxBytes
+ ed
.txBytes
) / (ed
.rxPackets
+ ed
.txPackets
)
697 graphdata(runs
, options
, 'bpp', 'Bytes / Packet', bpp
)
702 if command
== 'rxbpp':
703 bpp
= system
.tsunami
.etherdev0
.rxBytes
/ system
.tsunami
.etherdev0
.rxPackets
705 graphdata(runs
, options
, 'rxbpp', 'Receive Bytes / Packet', bpp
)
710 if command
== 'txbpp':
711 bpp
= system
.tsunami
.etherdev0
.txBytes
/ system
.tsunami
.etherdev0
.txPackets
713 graphdata(runs
, options
, 'txbpp', 'Transmit Bytes / Packet', bpp
)
719 rtp
= system
.tsunami
.etherdev0
.rxPackets
/ system
.tsunami
.etherdev0
.txPackets
721 graphdata(runs
, options
, 'rtp', 'rxPackets / txPackets', rtp
)
727 rtb
= system
.tsunami
.etherdev0
.rxBytes
/ system
.tsunami
.etherdev0
.txBytes
729 graphdata(runs
, options
, 'rtb', 'rxBytes / txBytes', rtb
)
734 raise CommandException
739 if __name__
== '__main__':
743 options
.host
= 'zizzer.pool'
746 options
.user
= getpass
.getuser()
748 options
.system
= 'client'
750 options
.binned
= False
751 options
.graph
= False
752 options
.ticks
= False
754 opts
, args
= getopts(sys
.argv
[1:], '-6BEFGd:g:h:pr:s:u:T:')
757 options
.binned
= True
763 options
.graph
= True;
771 options
.passwd
= getpass
.getpass()
788 commands(options
, command
, args
)
789 except CommandException
: