source: doc/theses/mike_brooks_MMath/plots/list-mchn-szz.py@ 17f2a7f4

Last change on this file since 17f2a7f4 was 17f2a7f4, checked in by Michael Brooks <mlbrooks@…>, 3 weeks ago

Revise presentation of absolute times and add discussion of their physical influences.

  • Property mode set to 100644
File size: 4.1 KB
Line 
1import pandas as pd
2import numpy as np
3import os
4import sys
5import math
6
7sys.path.insert(0, os.path.dirname(__file__))
8from ListCommon import *
9
10# The range from 0.9759 to 1.0247 (which is 1.05 x wide) has 1.0 in its centre.
11# This is the bucket with key 0.
12# Logs of values in this bucket go from -0.5 to +0.5.
13# Rounding a log value to the nearest integer gives the key.
14# Exponentiating a key directly gives the centre of its bucket.
15# Exponentiating a key less 0.5 gives the bottom of its bucket.
16# Gnuplot expects the latter.
17
18bucketMin = 0.25
19bucketMax = 4.0
20bucketGrain = 1.05
21bktKeyLo = math.floor( math.log(bucketMin, bucketGrain) )
22bktKeyHi = math.ceil( math.log(bucketMax, bucketGrain) )
23
24def bktKeyOfVal( relDur ):
25 distance = math.log(relDur, bucketGrain)
26 key = round( distance )
27 return key
28
29def bktIxOfVal( relDur ):
30 return bktKeyToIx( bktKeyOfVal( relDur ) )
31
32def botValOfBucketK( key ):
33 return bucketGrain ** ( key - 0.5 )
34
35def topValOfBucketBotVal( botVal ):
36 return bucketGrain * botVal
37
38def bktKeyToIx( key ):
39 return key - bktKeyLo
40
41def bktIxToKey( ix ):
42 return ix + bktKeyLo
43
44def botOfBucketOfVal( relDur ):
45 return botValOfBucketK( bktKeyOfVal( relDur ) )
46
47buckets = [ botValOfBucketK(key) for key in range(bktKeyLo, bktKeyHi) ]
48
49# printSingleDetail
50def printHistos(*,
51 tgtMovement = 'all',
52 tgtPolarity = 'all',
53 tgtAccessor = 'all',
54 tgtInterleave = 0.0,
55 marginalizeOn=['fx'] ):
56
57 # watch out for filtering too early here; need everything sticking around until baselines are applies
58 # ie, maybe I should get rid of all the tgt parms at the pre-benchmark layers
59 timings = getSingleResults(
60 tgtMovement = tgtMovement,
61 tgtPolarity = tgtPolarity,
62 tgtAccessor = tgtAccessor,
63 tgtInterleave = tgtInterleave)
64 timings = getJustCanon( timings,
65 fxInc = ['cfa-cfa', 'lq-tailq', 'upp-upp', 'lq-list'],
66 szInc = ['SM', 'ML'],
67 sExcl = [1] )
68
69
70# annotateBaselines(timings)
71
72
73 options = timings.groupby(explanations)
74
75 aggregated = options.agg(
76 mean_op_dur_ns = ('mean_op_dur_ns', gMeanNoOutlr)
77 ).reset_index()
78
79
80 annotateBaseline(aggregated, marginalizeOn)
81# annotateCommonBaselines(aggregated)
82
83
84 # if examining "why CFA slow" need both
85 # - getVariousCfa inplace of getJust Canon
86 # - do annotate-then-filter because baseline needs to stay cfa-tailq-upp
87 # (filter-then-annotate is fine for general cases (where all three canons are included) and good for build time)
88
89
90 c_measure = c('OpDurRel', marginalizeOn)
91 # options = timings.groupby(explanations)
92
93 # aggregated = options.agg(
94 # **{measure:(measure,gMeanNoOutlr)}
95 # ).reset_index()
96
97 c_measureBkt = 'BUCKET_' + c_measure
98 aggregated[ c_measureBkt ] = aggregated[c_measure].apply( botOfBucketOfVal )
99
100 marggrp = aggregated.groupby(marginalizeOn)
101
102
103 # print(f'measure is {measure}')
104 # print()
105 # print()
106
107 for mkey, mgroup in marggrp:
108# print(mgroup, file=sys.stderr)
109
110 histo_raw = mgroup[ c_measureBkt ].value_counts()
111 for b in buckets:
112 if b not in histo_raw.keys():
113# print( f"{b} := 0", file=sys.stderr )
114 histo_raw[b] = 0
115 histo_raw = histo_raw.sort_index()
116
117 histo = histo_raw.rename("count").reset_index()
118 histo = histo.rename(columns={c_measureBkt: "y_lo"})
119 y_lo_col_loc = histo.columns.get_loc("y_lo")
120 histo.insert(y_lo_col_loc + 1, "y_hi", histo["y_lo"].apply(topValOfBucketBotVal))
121
122 header = str.join(', ', mkey)
123 print(f'"{header}"')
124 text = histo.to_csv(header=False, index=False, sep='\t')
125 print(text)
126 print()
127 print()
128
129 # print(f'"{header}" FULL')
130 # text = group.to_csv(header=False, index=True, sep='\t')
131 # print(text)
132 # print()
133 # print()
134
135 # print(f'"RAW"')
136 # text = timings.to_csv(header=False, index=True, sep='\t')
137 # print(text)
138
139
140printHistos(
141 tgtMovement = 'all',
142 tgtPolarity = 'all',
143 tgtAccessor = 'all',
144 marginalizeOn=['machine', 'SizeZone'] )
145
Note: See TracBrowser for help on using the repository browser.