source: doc/theses/mike_brooks_MMath/plots/ListCommon.py@ 7640ff5

Last change on this file since 7640ff5 was 16a843b, checked in by Michael Brooks <mlbrooks@…>, 2 months ago

add linked-list performance assessment

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