6import exahype2.postprocessing
12import matplotlib.pyplot
as plt
15Colors = [
"#aa0000",
"#00aa00",
"#0000aa",
"#797900",
"#790079",
"#007979",
"#ababab"]
19Symbols = [
"o",
"s",
"<",
">",
"v",
"^"]
27 plt.plot([1, max_x], [max_serial_y, max_serial_y / max_x],
"--", color=
"#ababab")
28 plt.plot([1, max_x], [min_serial_y, min_serial_y / max_x],
"--", color=
"#ababab")
37 max_x = max(max_x, x_data[-1])
39 for i
in range(0, len(x_data)):
40 serialised_value = y_data[i] * x_data[i]
41 max_serial_y = max(max_serial_y, serialised_value)
42 min_serial_y = min(min_serial_y, serialised_value)
45def visualise(data_points, symbol_counter, colour_counter):
51 (x_data, y_data) = exahype2.postprocessing.extract_times_per_step(
52 data_points, args.max_cores_per_rank
57 if args.plot_efficiency:
58 normalised_fasted_time = y_data[0] * x_data[0]
59 for i
in range(0, len(x_data)):
60 y_data[i] = normalised_fasted_time / y_data[i] / x_data[i]
61 if args.max_cores_per_rank > 0:
62 y_data = [y / float(args.max_cores_per_rank)
for y
in y_data]
63 y_data = [min(y, 1.1)
for y
in y_data]
65 symbol =
"-" + Symbols[symbol_counter % len(Symbols)]
66 my_color = Colors[colour_counter % len(Colors)]
70 symbol_counter % len(Symbols) % (len(x_data) + 1),
71 int(len(x_data) / 8) + 1,
75 max_time = max(y_data[0], max_time)
78 plt.plot(x_data, y_data, symbol, color=my_color, markevery=my_markevery)
81 my_label = args.labels.split(
",")[args.file.index(file)]
85 + str(args.file.index(file))
89 + str(args.labels.split(
","))
97 markevery=my_markevery,
103 args.output +
".txt", np.c_[x_data, y_data], fmt=[
"%1.f",
"%1.2f"]
107if __name__ ==
"__main__":
108 parser = argparse.ArgumentParser(
110ExaHyPE 2 scaling plotter:
112A generic script to create speedup plots.
119 help=
"filename of the file to parse. You can specify multiple files",
122 "-v",
"--verbose", help=
"increase output verbosity", action=
"store_true"
125 "--max-cores-per-rank",
126 dest=
"max_cores_per_rank",
128 help=
"max number of cores per rank (pick 0 if you have only one core count per rank, pick -1 if you want to plot single-node data)",
134 help=
"group k consecutive measurements as one piece of data, i.e. use similar styles (default=0, i.e. off)",
139 "--log-x", dest=
"log_x", help=
"plot with logarithmic axes", action=
"store_true"
142 "--log-y", dest=
"log_y", help=
"plot with logarithmic axes", action=
"store_true"
146 dest=
"plot_efficiency",
147 help=
"Don't plot raw times but efficiency",
153 help=
"Plot labels. You can use $...$ to use the math mode, but you will have to escape the dollars with a \\. Separate with , and ensure there's exactly one entry per file",
159 help=
"output file prefix (file name extension is added automatically)",
165 help=
"Solver name (leave blank if there is only one solver)",
171 help=
"Export plot data into a txt file",
177 help=
"Switch file sorting (natural sort)",
180 parser.add_argument(
"--title", dest=
"title", help=
"Title of plot", default=
None)
181 args = parser.parse_args()
185 min_serial_y = sys.float_info.max
193 for file
in args.file:
194 if os.path.isdir(file):
195 print(
"Parse file " + file)
197 for data_file
in os.listdir(file):
199 "========================================================================"
201 print(file +
"/" + data_file +
" from " + file)
203 "========================================================================"
205 new_data = exahype2.postprocessing.PerformanceData(
206 file +
"/" + data_file, args.solver_name, args.verbose
209 data_points.append(new_data)
210 visualise(data_points, symbol_counter, colour_counter)
211 elif file.endswith(
"tar")
or file.endswith(
"tar.gz"):
212 print(
"Parse archive " + file)
214 if file.endswith(
"tar.gz"):
216 elif file.endswith(
"tar"):
221 tar = tarfile.open(file, open_mode)
222 data_files = tar.getnames()
226 data_files = Tcl().call(
"lsort",
"-dict", data_files)
229 for data_file
in data_files:
231 "========================================================================"
233 print(data_file +
" from " + file)
235 "========================================================================"
237 tar.extract(data_file)
238 new_data = exahype2.postprocessing.PerformanceData(
239 data_file, args.solver_name, args.verbose
242 data_points.append(new_data)
246 print(
"have successfully parsed {} files".format(len(data_files)))
248 if len(data_files) > 0:
249 visualise(data_points, symbol_counter, colour_counter)
251 print(
"ERROR: no files in archive")
252 except Exception
as e:
253 print(
"Error: " + str(e))
258 print(file +
" is neither a directory or an archive")
261 if args.group_data > 0:
262 if symbol_counter >= args.group_data:
268 if args.plot_efficiency:
269 plt.ylabel(
"Efficiency")
272 plt.ylabel(
"Time per time step [t]=s")
274 plt.xscale(
"log", base=2)
276 plt.yscale(
"log", base=2)
278 if args.max_cores_per_rank < 0:
285 while xtics[-1] < max_x:
286 xtics.append(xtics[-1] * 2)
287 xlabels.append(str(xtics[-1]))
288 plt.xticks(xtics, xlabels)
291 output_file_name = args.output
292 if output_file_name ==
"":
293 output_file_name = args.file[0].replace(
".tar.gz",
"").replace(
".tar",
"")
295 if args.title !=
None:
296 plt.title(args.title)
298 plt.savefig(output_file_name +
".pdf")
299 plt.savefig(output_file_name +
".png")
compute_min_max(x_data, y_data)
add_linear_speedup_trend_line()
visualise(data_points, symbol_counter, colour_counter)