diff --git a/cpu_sparse_xp/python/plot_permut_vs_original.py b/cpu_sparse_xp/python/plot_permut_vs_original.py index faec9ad3f5d23f97e46ed1223090cdd0b488f762..820225232e86723d853e922a57ef81fc0c11884b 100644 --- a/cpu_sparse_xp/python/plot_permut_vs_original.py +++ b/cpu_sparse_xp/python/plot_permut_vs_original.py @@ -16,6 +16,19 @@ LATEX_HEADER = [ "ZFR", ] +RENAME = { + "Bands": "Us - No Permutation", + "BandsPermPrimes": "Us - First Part Permutation", + "BandsPermPrimesGorder": "Us - Full Permutation", +} + +BARORDER = { + "MKL": 0, + "Bands": 1, + "BandsPermPrimes": 2, + "BandsPermPrimesGorder": 3, +} + def duration_to_ms(d: dict[str, int]) -> float: return 1000 * d["secs"] + d["nanos"] / 1_000_000 @@ -126,12 +139,17 @@ class BarsData: axs: Any = tmp[1] # pyright:ignore if n_to_cmp == 1: axs = [axs] - for i, (impl, speed) in enumerate( - filter(lambda x: x[0] != "MKL", self.speed_reorder_algos.items()) - ): + # sort the bar according to an hardcoded order + names_values = list(self.speed_reorder_algos.items()) + names_values.sort(key=lambda x: BARORDER.get(x[0], len(self.matrices))) + i = 0 + for impl, speed in names_values: + if "MKL" in impl: + continue axs[i].hist(speed, bins=50) - axs[i].set_title(impl) + axs[i].set_title(RENAME.get(impl, impl)) axs[i].set_xlabel("Speedup vs MKL") + i += 1 axs[0].set_ylabel("Occurences") plt.show() @@ -155,10 +173,14 @@ class BarsData: width = 1 / (len(self.speed_reorder_algos) + 2) x = np.arange(len(self.matrices)) - offset = 1 - for name, values in self.speed_reorder_algos.items(): - ax.bar(x + offset * width, values, width, label=name) - offset += 1 + + # sort the bar according to an hardcoded order + names_values = list(self.speed_reorder_algos.items()) + names_values.sort(key=lambda x: BARORDER.get(x[0], len(self.matrices))) + + for offset, (name, values) in enumerate(names_values): + label = RENAME.get(name, name) + ax.bar(x + offset * width, values, width, label=label) ax.set_ylabel("Speedup (normalized)", fontsize="xx-large") n_implems = len(self.implems)