From 46409ef8c03be1754c96ec01fed7b14b31b5611f Mon Sep 17 00:00:00 2001
From: Michael Zikeli <michael.zikeli@fau.de>
Date: Wed, 5 Feb 2025 15:08:31 +0100
Subject: [PATCH] [no main fork] Add a post-processing script to view if the
 conversation of the timers worked.

---
 .../investigateBenchmarkingTimerOutput.py     | 69 +++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 post_processing/investigateBenchmarkingTimerOutput.py

diff --git a/post_processing/investigateBenchmarkingTimerOutput.py b/post_processing/investigateBenchmarkingTimerOutput.py
new file mode 100644
index 000000000..596a5464f
--- /dev/null
+++ b/post_processing/investigateBenchmarkingTimerOutput.py
@@ -0,0 +1,69 @@
+
+# %%
+import sqlite3
+import pandas as pd
+import os
+import matplotlib.pyplot as plt
+import warnings
+
+# %%
+# Define colors
+color1 = "#1F3B66"
+color2 = "#C14C30"
+color3 = "#4AA7A9"
+color4 = "#EBAE65"
+color5 = "#EBAE65"
+color6 = "#36b700"
+color7 = "#9d2c00"
+color8 = "#c8c8c8"
+
+# %%
+# Database configuration
+GPUs_per_node = 4  # MareNostrum5 ACC has four GPUs per node
+databasename = "/local/ab04unyc/mywalberla/build/benchmark-debug/apps/benchmarks/UniformGridCPU/cpu_benchmark.sqlite3"
+
+# Connect to the database
+conn = sqlite3.connect(databasename)
+cursor = conn.cursor()
+cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
+all_tables = cursor.fetchall()
+
+# Extract table names
+all_table_names = [str(t[0]) for t in all_tables]
+
+# %%
+# Debug output
+all_table_names
+
+# %%
+# Load data from all tables
+for table_name in all_table_names:
+    df = pd.read_sql(f"SELECT * FROM {table_name}", conn)
+    if 'full_df' in globals():
+        full_df = pd.concat([full_df, df], ignore_index=True)
+    else:
+        full_df = df.copy()
+
+# Debug output
+df.columns
+
+# %%
+# Extract unique timer names and properties
+timer_columns = df.filter(like='Timer')
+timer_names = list(set(col.split('_')[1] for col in timer_columns.columns))
+properties = list(set(col.split('_')[2] for col in timer_columns.columns))
+
+# Create a new dataframe with properties as rows and timer names as columns
+grouped_timers = pd.DataFrame(columns=properties, index=timer_names)
+
+# Fill the new dataframe with the corresponding values
+for timer in timer_names:
+    for prop in properties:
+        timer_name = f'Timer_{timer}_{prop}'
+        try:
+            grouped_timers.at[timer, prop] = timer_columns[timer_name].iloc[0]
+        except KeyError:
+            warnings.warn(f"{timer_name} not found in timer_columns")
+
+# Display the grouped timers
+grouped_timers
\ No newline at end of file
-- 
GitLab