@@ -81,6 +81,44 @@ def collect_all_timings(path, prefix, labels, substeps):
81
81
data [label ][b ][substep ]["mean" ] = float (vals [0 ])
82
82
data [label ][b ][substep ]["median" ] = float (vals [1 ])
83
83
data [label ][b ][substep ]["stdev" ] = float (vals [2 ])
84
+
85
+ return data
86
+
87
+
88
+ def collect_all_flops (path , prefix , labels , substeps ):
89
+ """
90
+ Collect all flops data.
91
+ Example of access to return dictionary: data['v1.1']['benchmark-1-0']['FLIP']['mean']
92
+ """
93
+ data = {}
94
+
95
+ for label in labels :
96
+ data [label ] = {}
97
+ batch_path = os .path .join (path , f"{ prefix } { label } " )
98
+ benchmark_names = get_benchmark_names ()
99
+
100
+ for b in benchmark_names :
101
+ filename = os .path .join (batch_path , b , "cost_analysis.txt" )
102
+ print (f"Reading { filename } ..." )
103
+
104
+ filename = os .path .abspath (filename )
105
+ if not os .path .isfile (filename ):
106
+ exit ('Error: could not open file.' )
107
+
108
+ with open (filename ) as f :
109
+ lines = f .read ().splitlines ()
110
+
111
+ data [label ][b ] = {}
112
+ for line in lines :
113
+ for substep in substeps :
114
+ if line .find (substep ) > - 1 :
115
+ data [label ][b ][substep ] = {}
116
+ vals = line .split ()
117
+ data [label ][b ][substep ]['adds' ] = float (vals [1 ])
118
+ data [label ][b ][substep ]['muls' ] = float (vals [2 ])
119
+ data [label ][b ][substep ]['divs' ] = float (vals [3 ])
120
+ data [label ][b ][substep ]['read' ] = float (vals [4 ])
121
+
84
122
return data
85
123
86
124
@@ -119,7 +157,7 @@ def plot_histogram(benchmark, tags, substeps, all_data, output, show=False, titl
119
157
plt .close (fig )
120
158
121
159
122
- def plot_perf (tag , substeps , all_data , output , show = False , title = None ):
160
+ def plot_perf (tag , substeps , all_data , all_flops , output , show = False , title = None ):
123
161
if title is None :
124
162
title = f"Runtime plot for optimization stage '{ tag } '"
125
163
@@ -130,7 +168,9 @@ def plot_perf(tag, substeps, all_data, output, show=False, title=None):
130
168
for substep in substeps :
131
169
tmp = []
132
170
for benchmark in benchmarks :
133
- tmp .append (all_data [tag ][benchmark ][substep ]['mean' ])
171
+ if substep != "compute_mesh" : tmp .append ((all_flops [tag ][benchmark ][substep ]['adds' ] + all_flops [tag ][benchmark ][substep ]['muls' ]) / all_data [tag ][benchmark ][substep ]['mean' ])
172
+ else : tmp .append (0. )
173
+ # tmp.append(all_data[tag][benchmark][substep]['mean'])
134
174
my_data [substep ] = np .array (tmp )
135
175
136
176
fig , ax = plt .subplots ()
@@ -140,7 +180,7 @@ def plot_perf(tag, substeps, all_data, output, show=False, title=None):
140
180
ax .set_prop_cycle (my_cycler )
141
181
142
182
143
- ax .set_ylabel ("Average runtime [cycles]" )
183
+ ax .set_ylabel ("Average performance [cycles]" )
144
184
ax .set_xlabel ("Number of cells [-]" )
145
185
for substep in substeps :
146
186
ax .plot (problem_dimensions , my_data [substep ], label = substep )
@@ -196,7 +236,10 @@ def plot_perf(tag, substeps, all_data, output, show=False, title=None):
196
236
if d .find (prefix ) == 0 :
197
237
all_tags .append (d .replace (prefix , "" , 1 ))
198
238
199
- all_data = collect_all_timings (path , prefix , all_tags , substeps )
239
+ print (all_tags , args .tag )
240
+
241
+ all_data = collect_all_timings (path , prefix , all_tags , substeps )
242
+ all_flops = collect_all_flops (path , prefix , all_tags , substeps )
200
243
201
244
benchmarks_hist_plots = None
202
245
if args .all :
@@ -216,4 +259,4 @@ def plot_perf(tag, substeps, all_data, output, show=False, title=None):
216
259
217
260
if benchmark_perf_plots is not None :
218
261
for tag in benchmark_perf_plots :
219
- plot_perf (tag , substeps , all_data , output , show )
262
+ plot_perf (tag , substeps , all_data , all_flops , output , show )
0 commit comments