4import matplotlib.pyplot
as plt
11 ParallelisationVariants,
12 Parallelisation_DomainDecomposition,
15 AllKernelOptimisationVariants,
17 BasicKernelOptimisationVariants,
18 KernelOptimisation_NoOptimisation,
21Symbols = [
"-o",
"-s",
"-v",
"-^"]
29 data_files = tar.getnames()
31 for choice
in choices:
32 print(
"study choice/variant {}".format(choice))
33 for file
in data_files:
34 if choice +
".out" in file:
35 print(
"read file {}".format(file))
36 time_stepping_cost = 0
38 input_file = open(file,
"r")
39 for line
in input_file:
40 if "time stepping:" in line:
41 time_stepping_cost = float(
42 line.split(
"time stepping:")[1].split(
"s")[0]
44 print(
"cost is {}s".format(time_stepping_cost))
45 data_points.append(time_stepping_cost)
48 thread_count = archive_file.split(
"-threads")[0].split(
"-")[-1]
51 Symbols[args.file.index(archive_file)],
52 label=thread_count +
" threads",
61 You can pass in the subchoices directly, or you can simply pass in some
62 strings. The routine takes the points in the identifier and replaces them
66 return [x.replace(
".",
"\n")
for x
in sub_choices]
75 Add the labels of the choices as x-ticks and rotate them by 90 degrees.
76 After that, we have to extend the whitespace underneath the plot, as the
77 labels otherwise don't fit in.
81 range(0, len(labels_on_x_axis)),
86 plt.ylabel(
"time [t]=s")
88 plt.subplots_adjust(bottom=0.3)
91if __name__ ==
"__main__":
92 parser = argparse.ArgumentParser(
93 description=
"SPH comparison of different implementation variants"
98 help=
"Filename of the file to parse. You can specify multiple files.",
101 "-o",
"--output", dest=
"output", required=
True, help=
"Output file"
103 args = parser.parse_args()
108 sub_choices = Choices
110 for archive_file
in args.file:
111 print(
"Study file {}".format(archive_file))
113 sub_choices, tarfile.open(archive_file,
"r:gz"), plt
119 print(
"Write to file {}.pdf and {}.png".format(args.output, args.output))
120 plt.savefig(args.output +
".pdf")
121 plt.savefig(args.output +
".png")
123 plt.savefig(args.output +
"-log.pdf")
124 plt.savefig(args.output +
"-log.png")
130 parallelisation_variant
136 + kernel_optimisation
137 for parallelisation_variant
in [Parallelisation_DomainDecomposition]
138 for storage
in [Storage_Scattered]
139 for sorting
in SortingVariants
140 for kernel_optimisation
in BasicKernelOptimisationVariants
142 parallelisation_variant
148 + kernel_optimisation
149 for parallelisation_variant
in [Parallelisation_DomainDecomposition]
150 for storage
in StorageVariants
151 for sorting
in SortingVariants
152 for kernel_optimisation
in AllKernelOptimisationVariants
155 for archive_file
in args.file:
156 print(
"Study file {}".format(archive_file))
158 sub_choices, tarfile.open(archive_file,
"r:gz"), plt
164 x.replace(Parallelisation_DomainDecomposition +
".",
"")
169 print(
"Write to file {}.pdf and {}.png".format(args.output, args.output))
170 plt.savefig(args.output +
"-domain-decomposition.pdf")
171 plt.savefig(args.output +
"-domain-decomposition.png")
173 plt.savefig(args.output +
"-domain-decomposition-log.pdf")
174 plt.savefig(args.output +
"-domain-decomposition-log.png")
180 parallelisation_variant
186 + kernel_optimisation
187 for parallelisation_variant
in [Parallelisation_DomainDecomposition]
188 for storage
in [Storage_Scattered] + StorageVariants
189 for sorting
in SortingVariants
190 for kernel_optimisation
in [KernelOptimisation_NoOptimisation]
193 for archive_file
in args.file:
194 print(
"Study file {}".format(archive_file))
196 sub_choices, tarfile.open(archive_file,
"r:gz"), plt
202 x.replace(Parallelisation_DomainDecomposition +
".",
"")
207 print(
"Write to file {}.pdf and {}.png".format(args.output, args.output))
208 plt.savefig(args.output +
"-compare-only-storage.pdf")
209 plt.savefig(args.output +
"-compare-only-storage.png")
211 plt.savefig(args.output +
"-compare-only-storage-log.pdf")
212 plt.savefig(args.output +
"-compare-only-storage-log.png")
plot_for_subset_of_variants(choices, tar, plt)
add_legend_and_labels(plt, labels_on_x_axis)
Add the labels of the choices as x-ticks and rotate them by 90 degrees.
construct_labels(sub_choices)
You can pass in the subchoices directly, or you can simply pass in some strings.