From da29aa865bc8b8073d3f2ea341987361bdcb42e0 Mon Sep 17 00:00:00 2001 From: Derek Christ Date: Mon, 26 Feb 2024 19:19:14 +0100 Subject: [PATCH] First plot script --- configs/pim_config.py | 5 +++- configs/pim_simulation.py | 2 +- pim_plots.py | 35 ++++++++++++++++++++++++++ simulation_script.py | 53 +++++++++++++++++++++++++++++---------- 4 files changed, 80 insertions(+), 15 deletions(-) create mode 100644 pim_plots.py diff --git a/configs/pim_config.py b/configs/pim_config.py index e3c78e535e..ffda503e03 100644 --- a/configs/pim_config.py +++ b/configs/pim_config.py @@ -4,7 +4,10 @@ from pathlib import Path @dataclass(frozen=True) class Configuration: name: str - workload: Path + workload: str + executable: Path + pim: bool + level: str frequency: str = "3GHz" @dataclass(frozen=True) diff --git a/configs/pim_simulation.py b/configs/pim_simulation.py index 84201c925b..94ad3540cf 100644 --- a/configs/pim_simulation.py +++ b/configs/pim_simulation.py @@ -57,7 +57,7 @@ for core in processor.get_cores(): workload = CustomWorkload( "set_baremetal_workload", { - "kernel": BinaryResource(configuration.workload), + "kernel": BinaryResource(configuration.executable), }, ) board.set_workload(workload) diff --git a/pim_plots.py b/pim_plots.py new file mode 100644 index 0000000000..40c8b6f70f --- /dev/null +++ b/pim_plots.py @@ -0,0 +1,35 @@ +import matplotlib.pyplot as plt +import pandas as pd +import numpy as np + +df = pd.read_csv("pim_results.csv") + +frequency_filter = df["frequency"] == "3GHz" + +workloads = df["workload"].unique() + +fig, ax = plt.subplots() + +width = 0.25 +index = 0 + +# for workload in workloads: +for level in df["level"].unique(): + level_filter = df["level"] == level + + for pim in [False, True]: + workload_filter = df["workload"] == "vadd" + + filtered_df = df[level_filter & workload_filter & frequency_filter] + print(filtered_df) + + x = np.arange(len(filtered_df)) + + offset = 6*width * index + print(x+offset) + bars = ax.bar(x + offset, "ticks", width, data=filtered_df, label=level) + # ax.bar_label(bars, padding=2) + index += 1 + +ax.legend(loc="upper left") +plt.show() diff --git a/simulation_script.py b/simulation_script.py index 8364b5ac37..dec2d27899 100644 --- a/simulation_script.py +++ b/simulation_script.py @@ -3,6 +3,7 @@ import csv import copy import dataclasses import json +import pandas as pd from threading import Thread from pathlib import Path @@ -35,20 +36,15 @@ class Gem5Thread(Thread): ], capture_output=True, ) - # print(out.stderr) - # print(out.stdout) + output = out.stdout.splitlines()[-1] self.statistics = Statistics(**json.loads(output)) -workload_directory = Path("kernels") +workload_base_directory = Path("kernels") +workload_sub_directory = Path("aarch64-unknown-none/release") workloads = [ - "classic_vadd", - "classic_vmul", - "classic_haxpy", - "classic_gemv", - # "classic_gemv_layers", "vadd", "vmul", "haxpy", @@ -59,10 +55,34 @@ workloads = [ configurations: list[Configuration] = [] for frequency in ["3GHz", "100GHz"]: - for workload in workloads: - configurations.append( - Configuration(workload + "_" + frequency, (workload_directory / workload).as_posix(), frequency) - ) + for level in ["X1", "X2", "X3", "X4"]: + for pim in [False, True]: + for workload in workloads: + if workload == "gemv_layers" and level != "X4": + continue + + executable = workload + + if pim: + executable = f"classic_{workload}" + + executable = ( + workload_base_directory + / level + / workload_sub_directory + / executable + ) + + configurations.append( + Configuration( + f"{workload}_{level}_{frequency}", + workload, + executable.as_posix(), + pim, + level, + frequency, + ) + ) threads: list[Gem5Thread] = [] @@ -71,6 +91,13 @@ for configuration in configurations: thread.start() threads.append(thread) +results: list[dict] = [] + for thread in threads: thread.join() - print(thread.configuration, thread.statistics) + + result = dataclasses.asdict(thread.configuration) | dataclasses.asdict(thread.statistics) + results.append(result) + +dataframe = pd.DataFrame(results) +dataframe.to_csv("pim_results.csv", index=False)