Skip to content
Snippets Groups Projects
Commit 80ea57b4 authored by Cyril Moineau's avatar Cyril Moineau
Browse files

[Min] MemManager plot, remove axis and center more the fig.

parent 59bffdf1
No related branches found
No related tags found
2 merge requests!318[Upd] release verision 0.5.0,!276Rewrite memory manager log_info in Python.
...@@ -45,17 +45,17 @@ def compute_default_mem_info(scheduler: aidge_core.Scheduler) -> Tuple[int, List ...@@ -45,17 +45,17 @@ def compute_default_mem_info(scheduler: aidge_core.Scheduler) -> Tuple[int, List
return mem_size, mem_info return mem_size, mem_info
# TODO remove # TODO remove
# def _gnuplot_installed(): def _gnuplot_installed():
# try: try:
# # Run gnuplot with the --version flag and capture the output # Run gnuplot with the --version flag and capture the output
# subprocess.run(["gnuplot", "--version"]) subprocess.run(["gnuplot", "--version"])
# return True return True
# except FileNotFoundError: except FileNotFoundError:
# aidge_core.Log.warn("Gnuplot is not installed.") aidge_core.Log.warn("Gnuplot is not installed.")
# return False return False
# except subprocess.CalledProcessError: except subprocess.CalledProcessError:
# aidge_core.Log.warn("Gnuplot command found but failed to run.") aidge_core.Log.warn("Gnuplot command found but failed to run.")
# return False return False
def log_meminfo(mem_manager:aidge_core.MemoryManager, path: Path, diplay_names:bool): def log_meminfo(mem_manager:aidge_core.MemoryManager, path: Path, diplay_names:bool):
"""Generate a graph representing the memory allocation of each ouputs. """Generate a graph representing the memory allocation of each ouputs.
...@@ -104,12 +104,17 @@ def log_meminfo(mem_manager:aidge_core.MemoryManager, path: Path, diplay_names:b ...@@ -104,12 +104,17 @@ def log_meminfo(mem_manager:aidge_core.MemoryManager, path: Path, diplay_names:b
plt.text(x_end,y_end, node.name(), rotation=45) plt.text(x_end,y_end, node.name(), rotation=45)
color_id += 1 color_id += 1
plt.xlim(0, max_lifetime + 1)
plt.ylim(0, peak_usage)
plt.axhline(y=peak_usage, color='red', linestyle='--') plt.axhline(y=peak_usage, color='red', linestyle='--')
plt.text(0, peak_usage, f'Peak usage = {peak_usage} KWords', color='red') plt.text(0, peak_usage, f'Peak usage = {peak_usage} KWords', color='red')
plt.xlabel("Time") plt.xlabel("Time")
plt.ylabel("Memory usage (KWords)") plt.ylabel("Memory usage (KWords)")
plt.title("Memory Usage Over Time") plt.title("Memory Usage Over Time")
plt.grid(True) plt.grid(True)
ax = plt.gca()
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
plt.savefig(path) plt.savefig(path)
plt.close() plt.close()
aidge_core.Log.notice(f"Generated memory management info at: {path}") aidge_core.Log.notice(f"Generated memory management info at: {path}")
...@@ -153,18 +158,18 @@ def generate_optimized_memory_info(scheduler: aidge_core.Scheduler, stats_folder ...@@ -153,18 +158,18 @@ def generate_optimized_memory_info(scheduler: aidge_core.Scheduler, stats_folder
if stats_folder is not None: if stats_folder is not None:
log_meminfo(mem_manager, Path(stats_folder) / "memory_info.png", display_names) log_meminfo(mem_manager, Path(stats_folder) / "memory_info.png", display_names)
# TODO remove # TODO remove
# if _gnuplot_installed(): if _gnuplot_installed():
# # Use gnuplot to generate the log # Use gnuplot to generate the log
# os.makedirs(str(Path(stats_folder) / "graph"), exist_ok=True) os.makedirs(str(Path(stats_folder) / "graph"), exist_ok=True)
# mem_manager.log("memory_info") mem_manager.log("memory_info")
# os.chmod("memory_info_plot.gnu", 0o777) os.chmod("memory_info_plot.gnu", 0o777)
# os.system("./memory_info_plot.gnu") os.system("./memory_info_plot.gnu")
# shutil.move("memory_info", str(Path(stats_folder) / "graph" / "memory_info")) shutil.move("memory_info", str(Path(stats_folder) / "graph" / "memory_info"))
# shutil.move("memory_info_plot.png", str( shutil.move("memory_info_plot.png", str(
# Path(stats_folder) / "graph" / "memory_info_plot.png")) Path(stats_folder) / "graph" / "memory_info_plot.png"))
# os.remove("memory_info_plot.gnu") os.remove("memory_info_plot.gnu")
# else: else:
# aidge_core.Log.warn("Warning: gnuplot is not installed, could not generate stat folder.") aidge_core.Log.warn("Warning: gnuplot is not installed, could not generate stat folder.")
# In the export, we currently use an unified memory buffer whose size # In the export, we currently use an unified memory buffer whose size
# is determined by the memory peak usage # is determined by the memory peak usage
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment