Skip to content

Commit

Permalink
Refactor roofline data model properties and get plotext error bars wo…
Browse files Browse the repository at this point in the history
…rking
  • Loading branch information
EdmundGoodman committed Mar 3, 2024
1 parent eece7d4 commit e4f41f8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 39 deletions.
49 changes: 26 additions & 23 deletions src/hpc_multibench/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PlotStyle(Enum):
PLOTEXT = auto()


PLOT_STYLE = PlotStyle.SEABORN
PLOT_STYLE = PlotStyle.PLOTEXT
PLOTEXT_MARKER = "braille"
PLOTEXT_THEME = "pro"

Expand Down Expand Up @@ -107,9 +107,14 @@ def draw_line_plot(

if PLOT_STYLE == PlotStyle.PLOTEXT:
plt.clear_figure()
# NOTE: Plotext cannot render error bars!
for name, (x, y, _, _) in data.items():
for name, (x, y, _x_err, _y_err) in data.items():
plt.plot(x, y, marker=PLOTEXT_MARKER, label=name)
# plt.error(
# x,
# y,
# xerr=_x_err,
# yerr=_y_err,
# )
plt.theme(PLOTEXT_THEME)
else:
for name, (x, y, x_err, y_err) in data.items():
Expand Down Expand Up @@ -243,32 +248,30 @@ def draw_roofline_plot(

if PLOT_STYLE == PlotStyle.PLOTEXT:
plt.clear_figure()
# TODO: Refactor to remove need for explicit zip
for label, memory_bound_data in roofline.memory_bound_ceilings.items():
plt.plot(
*zip(*memory_bound_data, strict=True),
label=label,
marker=PLOTEXT_MARKER,
)
for label, compute_bound_data in roofline.compute_bound_ceilings.items():
plt.plot(
*zip(*compute_bound_data, strict=True),
label=label,
marker=PLOTEXT_MARKER,
for label, (x, y) in roofline.memory_bound_ceilings.items():
plt.plot(x, y, label=label, marker=PLOTEXT_MARKER)
for label, (x, y) in roofline.compute_bound_ceilings.items():
plt.plot(x, y, label=label, marker=PLOTEXT_MARKER)
for name, (x_point, y_point, x_err, y_err) in data.items():
plt.error(
[x_point],
[y_point],
xerr=[x_err / 2] * 2 if x_err is not None else None,
yerr=[y_err / 2] * 2 if y_err is not None else None,
label=name,
)
plt.theme(PLOTEXT_THEME)
else:
for label, memory_bound_data in roofline.memory_bound_ceilings.items():
plt.plot(*zip(*memory_bound_data, strict=True), label=label)
for label, compute_bound_data in roofline.compute_bound_ceilings.items():
plt.plot(*zip(*compute_bound_data, strict=True), label=label)
for label, (x, y) in roofline.memory_bound_ceilings.items():
plt.plot(x, y, label=label)
for label, (x, y) in roofline.compute_bound_ceilings.items():
plt.plot(x, y, label=label)
# for ax in plt.gcf().axes:
# labelLines(ax.get_lines())

for name, (x, y, x_err, y_err) in data.items():
for name, (x_point, y_point, x_err, y_err) in data.items():
plt.errorbar(
x,
y,
x_point,
y_point,
xerr=x_err,
yerr=y_err,
marker="o",
Expand Down
28 changes: 12 additions & 16 deletions src/hpc_multibench/roofline_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,26 @@ def from_json(cls, ert_json: Path) -> Self:
)

@property
def memory_bound_ceilings(self) -> dict[str, list[tuple[float, float]]]:
def memory_bound_ceilings(self) -> dict[str, tuple[list[float], list[float]]]:
"""Get a labelled set of memory bound ceiling lines."""
memory_bound_ceilings: dict[str, list[tuple[float, float]]] = {}
memory_bound_ceilings: dict[str, tuple[list[float], list[float]]] = {}
for ceiling_name, m in self.gbytes_per_sec.items():
data_series: list[tuple[float, float]] = []
y_values = [1, *list(self.gflops_per_sec.values())]
for y in y_values:
x = y / m
data_series.append((x, y))
x_values = [y / m for y in y_values]
ceiling_label = f"{ceiling_name} = {m} GB/s"
memory_bound_ceilings[ceiling_label] = data_series
memory_bound_ceilings[ceiling_label] = (x_values, y_values)
return memory_bound_ceilings

@property
def compute_bound_ceilings(self) -> dict[str, list[tuple[float, float]]]:
"""."""
compute_bound_ceilings: dict[str, list[tuple[float, float]]] = {}
def compute_bound_ceilings(self) -> dict[str, tuple[list[float], list[float]]]:
"""Get a labelled set of computer bound ceiling lines."""
compute_bound_ceilings: dict[str, tuple[list[float], list[float]]] = {}
for ceiling_name, y in self.gflops_per_sec.items():
x_min_ceiling = y / max(self.gbytes_per_sec.values())
x_max_ceiling = y / min(self.gbytes_per_sec.values())
data_series: list[tuple[float, float]] = [
(x_min_ceiling, y),
(x_max_ceiling * 20, y),
x_values = [
y / max(self.gbytes_per_sec.values()),
20 * (y / min(self.gbytes_per_sec.values())),
]
y_values = [y, y]
ceiling_label = f"{y} {ceiling_name}"
compute_bound_ceilings[ceiling_label] = data_series
compute_bound_ceilings[ceiling_label] = (x_values, y_values)
return compute_bound_ceilings

0 comments on commit e4f41f8

Please sign in to comment.