1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
#!/usr/bin/python
################################################################################
# Description
################################################################################
# Control script for unit-trace
################################################################################
# Setup
################################################################################
# Get trace files from command line arguments
from optparse import OptionParser
usage = "usage: %prog [options] <one or more trace files>"
parser = OptionParser(usage=usage)
parser.add_option("-b", "--bufsize", dest="buffsize", default=200, type=int,
help="Per-CPU buffer size for sorting records")
parser.add_option("-c", "--clean", action="store_true", dest="clean",
default=False, help="Use sanitizer to clean garbage records")
parser.add_option("-d", "--dist", action="store_true", dest="dist",
default=False, help="Print out CDF")
parser.add_option("-e", "--earliest", default=0, type=int, dest="earliest",
help="Earliest timestamp of interest")
parser.add_option("-f", "--out_file", dest="out_file",
metavar="out_file", help="out File for CDF and Info")
parser.add_option("-g", "--gedf", action="store_true", dest="gedf",
default=False, help="Run G-EDF test")
parser.add_option("-i", "--info", dest="num_inversions", default=-1, type=int,
help="Print the n longest inversions, plus statistical info")
parser.add_option("-l", "--latest", default=0, type=int, dest="latest",
help="Latest timestamp of interest")
parser.add_option("-m", "--max", dest="maxnum", default=-1, type=int,
help="Maximum number of records to parse")
parser.add_option("-o", "--stdout", action="store_true", dest="stdout",
default=False, help="Use stdout_printer")
parser.add_option("-p", "--progress", action="store_true", dest="progress",
default=False, help="Show parsing progress")
parser.add_option("-q", "--cdf_unit", dest="cdf_unit", default=1, type=float,
help="The time unit of clumatiative distrubtion")
parser.add_option("-s", "--skip", dest="skipnum", default=0, type=int,
help="Skip over a fixed number of records")
parser.add_option("-t", "--time-per-maj", default=10000000.0, type=float,
dest="time_per_maj", help="Time interval between major ticks, in the visualizer")
parser.add_option("-u", "--cedf", action="store_true", dest="cedf",
default=False, help="Run C-EDF test")
parser.add_option("-v", "--visual", action="store_true", dest="visualize",
default=False, help="Use visualizer")
parser.add_option("-z", "--csize", dest="csize", default=6, type=int,
help="Cluster size in C-EDF test")
(options, traces) = parser.parse_args()
traces = list(traces)
if len(traces) < 1:
parser.print_help()
exit()
################################################################################
# Pipeline
################################################################################
# Import the unit_trace module
import unit_trace
# Read events from traces
from unit_trace import trace_reader
stream = trace_reader.trace_reader(traces, options.buffsize)
# Skip over records
if options.skipnum > 0:
from unit_trace import skipper
stream = skipper.skipper(stream, options.skipnum)
# Enforce max number of records to parse
#if options.maxnum > 0:
# from unit_trace import maxer
# stream = maxer.maxer(stream, options.maxnum)
# Enfore earliest timestamp
if options.earliest > 0:
from unit_trace import earliest
stream = earliest.earliest(stream,options.earliest)
# Enfore latest timestamp
if options.latest > 0:
from unit_trace import latest
stream = latest.latest(stream,options.latest)
# Filter out garbage events
if options.clean is True:
from unit_trace import sanitizer
stream = sanitizer.sanitizer(stream)
# Display progress information using stderr
# e.g. # records completed so far, total time, etc.
if options.progress is True:
from unit_trace import progress
stream = progress.progress(stream)
# Produce G-EDF error records
#if options.gedf is True:
# from unit_trace import gedf_test
# stream = gedf_test.gedf_test(stream)
# Produce C-EDF error records
if options.cedf is True and options.maxnum > 0:
from unit_trace import cedf_test
stream = cedf_test.cedf_test(stream,options.csize,options.maxnum)
# Filter some records out
#def my_filter(record):
# if record.record_type == 'error' and record.type_name == 'inversion_end':
# if record.job.inversion_end - record.job.inversion_start < 4000000:
# return False
# return True
#stream = filter(my_filter, stream)
# Tee by the number of possible outputs
# This might cause a performance bottleneck that could be eliminated by
# checking how many we actually need :-)
import itertools
stream1, stream2, stream3, stream4, stream5, stream6 = itertools.tee(stream,6)
# Call standard out printer
if options.stdout is True:
from unit_trace import stdout_printer
stdout_printer.stdout_printer(stream1,options.csize)
# Print G_EDF inversion statistics
#if options.num_inversions > -1:
# if options.gedf is not True:
# import sys
# sys.stderr.write("You must enable the G-EDF test module to print" +
# " G-EDF inversion statistics\n")
# else:
# from unit_trace import gedf_inversion_stat_printer
# gedf_inversion_stat_printer.gedf_inversion_stat_printer(stream2,options.num_inversions,"Task_")
# gedf_inversion_stat_printer.gedf_inversion_stat_printer(stream2,options.num_inversions,"Tasklet_")
# gedf_inversion_stat_printer.gedf_inversion_stat_printer(stream2,options.num_inversions,"Work_Item_")
# Print C_EDF inversion statistics
if options.dist is True:
if options.cedf is not True:
import sys
sys.stderr.write("You must enable the C-EDF test module to print" +
" C-EDF statistics\n")
else:
from unit_trace import cedf_stat_printer
cedf_stat_printer.cedf_stat_printer(stream2,options.cdf_unit,False,0,"Task_inversion",options.out_file)
#cedf_stat_printer.cedf_stat_printer(stream3,options.cdf_unit,False,1,"Task_inversion",options.out_file)
cedf_stat_printer.cedf_stat_printer(stream3,options.cdf_unit,False,0,"Tasklet_inversion",options.out_file)
#cedf_stat_printer.cedf_stat_printer(stream6,options.cdf_unit,False,1,"Tasklet_inversion",options.out_file)
cedf_stat_printer.cedf_stat_printer(stream4,options.cdf_unit,False,0,"Work_Item_inversion",options.out_file)
#cedf_stat_printer.cedf_stat_printer(stream9,options.cdf_unit,False,1,"Work_Item_inversion",options.out_file)
cedf_stat_printer.cedf_stat_printer(stream5,options.cdf_unit,False,0,"Tasklet_simultaneous",options.out_file)
#cedf_stat_printer.cedf_stat_printer(stream12,options.cdf_unit,False,1,"Tasklet_simultaneous",options.out_file)
cedf_stat_printer.cedf_stat_printer(stream6,options.cdf_unit,False,0,"Work_Item_simultaneous",options.out_file)
#cedf_stat_printer.cedf_stat_printer(stream15,options.cdf_unit,False,1,"Work_Item_simultaneous",options.out_file)
# Print any warnings
#from unit_trace import warning_printer
#warning_printer.warning_printer(stream11)
# Call visualizer
if options.visualize is True:
from unit_trace import viz
viz.visualizer.visualizer(stream6, options.time_per_maj)
|