Skip to content

Commit

Permalink
Add support for splitting line plots into series by metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
EdmundGoodman committed Feb 26, 2024
1 parent 0df6c4d commit 442fb2e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
18 changes: 13 additions & 5 deletions src/hpc_multibench/test_bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,23 @@ def report(self) -> None:
# Extract the outputs into the data format needed for the line plot
for plot in self.bench_model.analysis.line_plots:
# TODO: Could extraction function out into analysis file?
data: dict[str, list[tuple[float, float]]] = {
run_name: [] for run_name in self.run_configuration_models
}
data: dict[tuple[str, ...], list[tuple[float, float]]] = {}

for run_configuration, output in run_outputs.values():
if output is not None:
metrics = self.extract_metrics(output)
if metrics is None:
continue
data[run_configuration.name].append(

split_data: list[str] = [
f"{split_metric}={metrics[split_metric]}"
for split_metric in plot.split_by
]
series_name = (run_configuration.name, *split_data)

if series_name not in data:
data[series_name] = []
data[series_name].append(
(
float(metrics[plot.x]),
float(metrics[plot.y]),
Expand All @@ -270,7 +278,7 @@ def report(self) -> None:

for name, results in data.items():
print(name, results)
plt.plot(*zip(*results, strict=True), marker="x", label=name)
plt.plot(*zip(*results, strict=True), marker="x", label=",".join(name))
plt.xlabel(plot.x)
plt.ylabel(plot.y)
plt.title(plot.title)
Expand Down
1 change: 1 addition & 0 deletions src/hpc_multibench/yaml_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class LinePlotModel(BaseModel):
title: str
x: str
y: str
split_by: list[str] = []


# class RooflinePlotModel(BaseModel):
Expand Down
12 changes: 11 additions & 1 deletion yaml_examples/kudu/simple_rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ benches:
y: "Wall time (s)"

"mpi-config-sweep":
enabled: False
run_configurations:
- "cpp-mpi"
- "rust-mpi"
Expand All @@ -190,12 +189,18 @@ benches:
"Total flops": "FLOPS Summary:[\\s\\S]*Total\\s*: ([\\d\\.]+)[\\s\\S]*\nMFLOPS Summary"
"Total mflops": "MFLOPS Summary:[\\s\\S]*Total\\s*: ([\\d\\.]+)"
"Wall time (s)": "real\\s([\\d\\.]+)\nuser"
"Nodes": "=== RUN INSTANTIATION ===\n\\{.*sbatch_config: \\{.*nodes: (\\d+).*\\}"
"Tasks per Node": "=== RUN INSTANTIATION ===\n\\{.*sbatch_config: \\{.*ntasks-per-node: (\\d+).*\\}"
line_plots:
- title: "MPI Configuration Sweep"
x: "Mesh x size"
y: "Wall time (s)"
split_by:
- "Nodes"
- "Tasks per Node"

"hybrid-single-node-config-sweep":
enabled: False
run_configurations:
- "cpp-hybrid"
- "rust-hybrid"
Expand All @@ -218,7 +223,12 @@ benches:
"Total flops": "FLOPS Summary:[\\s\\S]*Total\\s*: ([\\d\\.]+)[\\s\\S]*\nMFLOPS Summary"
"Total mflops": "MFLOPS Summary:[\\s\\S]*Total\\s*: ([\\d\\.]+)"
"Wall time (s)": "real\\s([\\d\\.]+)\nuser"
"Tasks per Node": "=== RUN INSTANTIATION ===\n\\{.*sbatch_config: \\{.*ntasks-per-node: (\\d+).*\\}"
"Threads": "=== RUN INSTANTIATION ===\n\\{.*sbatch_config: \\{.*cpus-per-task: (\\d+).*\\}"
line_plots:
- title: "Parallel Implementation Comparison"
x: "Mesh x size"
y: "Wall time (s)"
split_by:
- "Tasks per Node"
- "Threads"

0 comments on commit 442fb2e

Please sign in to comment.