1 | # Based on crunch1
|
---|
2 | # updates for run-scenario columns not seen back then
|
---|
3 | # result eyeballs okay
|
---|
4 |
|
---|
5 | import pandas as pd
|
---|
6 | import numpy as np
|
---|
7 | import sys
|
---|
8 | import os
|
---|
9 | from subprocess import Popen, PIPE
|
---|
10 |
|
---|
11 | def getSingleResults(infileLocal, *,
|
---|
12 | tgtMovement = 'all',
|
---|
13 | tgtPolarity = 'all',
|
---|
14 | tgtAccessor = 'all',
|
---|
15 | tgtInterleave = 0.0 ):
|
---|
16 |
|
---|
17 | infile = os.path.dirname(os.path.abspath(__file__)) + '/../benchmarks/list/' + infileLocal
|
---|
18 |
|
---|
19 | # grep to remove lines that end in comma; these were error runs
|
---|
20 | with Popen("grep '[^,]$' " + infile, shell=True, stdout=PIPE) as process:
|
---|
21 | timings = pd.read_csv(
|
---|
22 | process.stdout,
|
---|
23 | names=['RunMoment', 'RunIdx', 'Args', 'Program', 'expt_ops_completed', 'expt_elapsed_sec', 'mean_op_dur_ns'],
|
---|
24 | dtype={'RunMoment': str,
|
---|
25 | 'RunIdx': np.int64,
|
---|
26 | 'Args': str,
|
---|
27 | 'Program': str,
|
---|
28 | 'expt_ops_completed': np.int64,
|
---|
29 | 'expt_elapsed_sec': np.float64,
|
---|
30 | 'mean_op_dur_ns': np.float64},
|
---|
31 | parse_dates=['RunMoment']
|
---|
32 | )
|
---|
33 | # print(timings.head())
|
---|
34 |
|
---|
35 | ## parse executable name and args
|
---|
36 |
|
---|
37 | timings[['ExperimentDurSec',
|
---|
38 | 'CheckDonePeriod',
|
---|
39 | 'NumNodes',
|
---|
40 | 'ExperimentDurOpCount',
|
---|
41 | 'Seed',
|
---|
42 | 'InterleaveFrac']] = timings['Args'].str.strip().str.split(expand=True)
|
---|
43 | timings["NumNodes"] = pd.to_numeric(timings["NumNodes"])
|
---|
44 | timings["InterleaveFrac"] = pd.to_numeric(timings["InterleaveFrac"]).round(3)
|
---|
45 |
|
---|
46 | timings[['__ProgramPrefix',
|
---|
47 | 'fx',
|
---|
48 | 'op']] = timings['Program'].str.split('--', expand=True)
|
---|
49 |
|
---|
50 | timings[['movement',
|
---|
51 | 'polarity',
|
---|
52 | 'accessor']] = timings['op'].str.split('-', expand=True)
|
---|
53 |
|
---|
54 | ## calculate relative to baselines
|
---|
55 | baseline_fx = 'lq-tailq'
|
---|
56 | baseline_intrl = 0.0
|
---|
57 |
|
---|
58 | # chose calc "FineCrossRun" from labpc:crunch3
|
---|
59 | byPeer = timings.groupby(['NumNodes', 'op', 'InterleaveFrac'])
|
---|
60 | for [NumNodes, op, intrlFrac], peerGroup in byPeer:
|
---|
61 | grpfx = peerGroup.groupby(['fx'])
|
---|
62 | if baseline_fx in grpfx.groups:
|
---|
63 | baselineRows = grpfx.get_group(baseline_fx)
|
---|
64 | baselineDur = meanNoOutlr( baselineRows['mean_op_dur_ns'] )
|
---|
65 | else:
|
---|
66 | baselineDur = 1.0
|
---|
67 | timings.loc[peerGroup.index, 'BaselineFxOpDurNs'] = baselineDur
|
---|
68 | timings['OpDurRelFx'] = timings['mean_op_dur_ns'] / timings['BaselineFxOpDurNs']
|
---|
69 |
|
---|
70 | # relative to same fx, no interleave
|
---|
71 | byPeer = timings.groupby(['NumNodes', 'op', 'fx'])
|
---|
72 | for [NumNodes, op, fx], peerGroup in byPeer:
|
---|
73 | baselineRows = peerGroup.groupby(['InterleaveFrac']).get_group(baseline_intrl)
|
---|
74 | baselineDur = meanNoOutlr( baselineRows['mean_op_dur_ns'] )
|
---|
75 | timings.loc[peerGroup.index, 'BaselineIntrlOpDurNs'] = baselineDur
|
---|
76 | timings['OpDurRelIntrl'] = timings['mean_op_dur_ns'] / timings['BaselineIntrlOpDurNs']
|
---|
77 |
|
---|
78 | movements = timings['movement'].unique()
|
---|
79 | polarities = timings['polarity'].unique()
|
---|
80 | accessors = timings['accessor'].unique()
|
---|
81 | interleaves = timings['InterleaveFrac'].unique()
|
---|
82 |
|
---|
83 | if movements.size > 1:
|
---|
84 | movements = np.append(movements, 'all')
|
---|
85 | if polarities.size > 1:
|
---|
86 | polarities = np.append(polarities, 'all')
|
---|
87 | if accessors.size > 1:
|
---|
88 | accessors = np.append(accessors, 'all')
|
---|
89 |
|
---|
90 | if (tgtMovement != 'all'):
|
---|
91 | grp = timings.groupby('movement')
|
---|
92 | timings = grp.get_group(tgtMovement)
|
---|
93 | if (tgtPolarity != 'all'):
|
---|
94 | grp = timings.groupby('polarity')
|
---|
95 | timings = grp.get_group(tgtPolarity)
|
---|
96 | if (tgtAccessor != 'all'):
|
---|
97 | grp = timings.groupby('accessor')
|
---|
98 | timings = grp.get_group(tgtAccessor)
|
---|
99 | if (tgtInterleave != 'all'):
|
---|
100 | timings = timings[ timings['InterleaveFrac'] == float(tgtInterleave) ]
|
---|
101 |
|
---|
102 | return timings
|
---|
103 |
|
---|
104 | def getSummaryMeta(metaFileCore):
|
---|
105 | metafile = os.path.dirname(os.path.abspath(__file__)) + "/" + metaFileCore + '-meta.dat'
|
---|
106 | metadata = pd.read_csv(
|
---|
107 | metafile,
|
---|
108 | names=['OpIx', 'Op'],
|
---|
109 | delimiter='\t'
|
---|
110 | )
|
---|
111 | metadata[['movement',
|
---|
112 | 'polarity',
|
---|
113 | 'accessor']] = metadata['Op'].str.split('\\\\n', expand=True)
|
---|
114 | metadata.replace('*', 'all', inplace=True)
|
---|
115 | return metadata
|
---|
116 |
|
---|
117 | def printManySummary(*,
|
---|
118 | infileLocal,
|
---|
119 | metafileCore,
|
---|
120 | fxs,
|
---|
121 | sizeQual = (lambda x: x < 150), # x < 8
|
---|
122 | tgtInterleave = 0.0,
|
---|
123 | measure = 'OpDurRelFx') :
|
---|
124 |
|
---|
125 | metadata = getSummaryMeta(metafileCore)
|
---|
126 |
|
---|
127 | print("# op_num\tfx_num\tfx\tmean\tstdev\tmin\tmax\tcount\tpl95\tpl68\tp50\tph68\tph95")
|
---|
128 |
|
---|
129 | for op in metadata.itertuples():
|
---|
130 | timings = getSingleResults(infileLocal,
|
---|
131 | tgtMovement = op.movement,
|
---|
132 | tgtPolarity = op.polarity,
|
---|
133 | tgtAccessor = op.accessor,
|
---|
134 | tgtInterleave = tgtInterleave )
|
---|
135 |
|
---|
136 | timings = timings[ timings['fx'].isin(fxs) ]
|
---|
137 | timings = timings[ timings['NumNodes'].apply(sizeQual) ]
|
---|
138 |
|
---|
139 | fxnums = timings['fx'].apply(
|
---|
140 | lambda fx: fxs.index(fx) + 1
|
---|
141 | )
|
---|
142 | timings.insert(loc=0, column='fx_num', value=fxnums)
|
---|
143 | timings.insert(loc=0, column='op_num', value=op.OpIx)
|
---|
144 |
|
---|
145 | grouped = timings.groupby(['op_num', 'fx_num', 'fx'])
|
---|
146 |
|
---|
147 | aggregated = grouped[measure].agg(
|
---|
148 | ["mean", "std", "min", "max", "count",
|
---|
149 | lambda x: x.quantile(0.025),
|
---|
150 | lambda x: x.quantile(0.16),
|
---|
151 | lambda x: x.quantile(0.5),
|
---|
152 | lambda x: x.quantile(0.84),
|
---|
153 | lambda x: x.quantile(0.975)]
|
---|
154 | )
|
---|
155 |
|
---|
156 | text = aggregated.to_csv(header=False, index=True, sep='\t')
|
---|
157 | print(text, end='')
|
---|
158 |
|
---|
159 | def printSingleDetail(infileLocal, *,
|
---|
160 | tgtMovement = 'all',
|
---|
161 | tgtPolarity = 'all',
|
---|
162 | tgtAccessor = 'all',
|
---|
163 | tgtInterleave = 0.0,
|
---|
164 | measure = 'mean_op_dur_ns' ):
|
---|
165 |
|
---|
166 | timings = getSingleResults(infileLocal,
|
---|
167 | tgtMovement = tgtMovement,
|
---|
168 | tgtPolarity = tgtPolarity,
|
---|
169 | tgtAccessor = tgtAccessor,
|
---|
170 | tgtInterleave = tgtInterleave)
|
---|
171 | groupedFx = timings.groupby('fx')
|
---|
172 |
|
---|
173 | for fx, fgroup in groupedFx:
|
---|
174 | # print(fgroup.head())
|
---|
175 | groupedRun = fgroup.groupby(['NumNodes']) # , 'fx', 'op'
|
---|
176 | aggregated = groupedRun[measure].agg(
|
---|
177 | ["mean", "std", "min", "max", "count", "sum"]
|
---|
178 | )
|
---|
179 | aggregated['mean_no_outlr'] = (
|
---|
180 | ( aggregated['sum'] - aggregated['min'] - aggregated['max'] )
|
---|
181 | /
|
---|
182 | ( aggregated['count'] - 2 )
|
---|
183 | )
|
---|
184 |
|
---|
185 | #print(aggregated.head())
|
---|
186 |
|
---|
187 | print('"{header}"'.format(header=fx))
|
---|
188 | text = aggregated.to_csv(header=False, index=True, sep='\t')
|
---|
189 | print(text)
|
---|
190 | print()
|
---|
191 | print()
|
---|
192 |
|
---|
193 | def meanNoOutlr(range):
|
---|
194 | return ( range.sum() - range.min() - range.max() ) / ( range.count() - 2 )
|
---|