From 8a6396ab7d6da548ed8ae3071f1cf0e4cb0d09c4 Mon Sep 17 00:00:00 2001
From: Christoph Alt <christoph.alt@fau.de>
Date: Mon, 16 Oct 2023 17:09:13 +0200
Subject: [PATCH] added likwid keys

---
 cbutil/likwid_keys.py              | 64 ++++++++++++++++++++++++++++++
 dashboards/dashboard_pystencils.py | 63 +++++++++++++----------------
 2 files changed, 91 insertions(+), 36 deletions(-)
 create mode 100644 cbutil/likwid_keys.py

diff --git a/cbutil/likwid_keys.py b/cbutil/likwid_keys.py
new file mode 100644
index 0000000..e8737ba
--- /dev/null
+++ b/cbutil/likwid_keys.py
@@ -0,0 +1,64 @@
+avx_dp_key = 'AVX DP [MFLOP/s]'
+cpi_key = 'CPI'
+dp_key = 'DP [MFLOP/s]'
+
+energy_dram_key = 'Energy DRAM [J]'
+energy_key = 'Energy [J]'
+power_dram_key = 'Power DRAM [W]'
+power_key = 'Power [W]'
+
+memory_bandwidth_key = 'Memory bandwidth [MBytes/s]'
+memory_read_bandwidth_key = 'Memory read bandwidth [MBytes/s]'
+memory_write_bandwidth_key = 'Memory write bandwidth [MBytes/s]'
+
+memory_data_key = 'Memory data volume [GBytes]'
+memory_write_key = 'Memory write data volume [GBytes]'
+memory_read_key = 'Memory read data volume [GBytes]'
+
+oi_key = 'Operational intensity'
+packe_ops_key = 'Packed [MUOPS/s]'
+scalar_ops_key = 'Scalar [MUOPS/s]'
+runtime_key = 'Runtime (RDTSC) [s]'
+clock_key = 'Clock [MHz]'
+
+STAT_SUFFIX = ' STAT'
+
+
+def add_suffix(suffix: str, key: str) -> str:
+    return f'{key} {suffix}'
+
+
+def add_stat(key):
+    return add_suffix(STAT_SUFFIX, key)
+
+
+def add_avg(key):
+    return add_suffix('Avg', key)
+
+
+def add_sum(key):
+    return add_suffix('Sum', key)
+
+
+def add_min(key):
+    return add_suffix('Min', key)
+
+
+def add_max(key):
+    return add_suffix('Max', key)
+
+
+def add_stat_avg(key):
+    return add_avg(add_stat(key))
+
+
+def add_stat_min(key):
+    return add_min(add_stat(key))
+
+
+def add_stat_max(key):
+    return add_max(add_stat(key))
+
+
+def add_stat_sum(key):
+    return add_sum(add_stat(key))
diff --git a/dashboards/dashboard_pystencils.py b/dashboards/dashboard_pystencils.py
index 67c2f85..251dde7 100644
--- a/dashboards/dashboard_pystencils.py
+++ b/dashboards/dashboard_pystencils.py
@@ -11,18 +11,9 @@ from dashboards.variables import get_dashboard_variable, Filter, get_measurement
 from dashboards.influx_queries import join_variable_and
 from dashboards.legends import Units
 
-from cbutil.ncu_keys import (
-    memory_write_data_key,
-    memory_read_data_key,
-    memory_data_key,
-    memory_write_bandwidth_key,
-    memory_read_bandwidth_key,
-    memory_bandwidth_key,
-    runtime_key,
-    operational_intensity_key,
-    p_max_key,
-    dp_key,
-)
+import cbutil.ncu_keys as ncu_keys
+import cbutil.likwid_keys as likwid_keys
+
 
 INTEL_LINESTYLE = "solid"
 GCC_LINESTYLE = "dashed"
@@ -45,19 +36,19 @@ def dashboard_pystencils_cpu():
         Filter("compiler"),
     ]
 
-    fields = [PanelInfos("Runtime (RDTSC) [s]", Units.seconds),
-              PanelInfos("DP [MFLOP/s]", Units.mflop_sec),
-              PanelInfos("Operational intensity", Units.flop_per_byte),
-              PanelInfos('AVX DP [MFLOP/s]" / "DP [MFLOP/s]', Units.percent),
-              PanelInfos('Memory bandwidth [MBytes/s]', Units.mbytes_per_second),
-              PanelInfos('Memory write bandwidth [MBytes/s]', Units.mbytes_per_second),
-              PanelInfos('Memory read bandwidth [MBytes/s]', Units.mbytes_per_second),
-              PanelInfos('Memory data volume [GBytes]', Units.gigabyte),
-              PanelInfos('Memory read data volume [GBytes]', Units.gigabyte),
-              PanelInfos('Memory write data volume [GBytes]', Units.gigabyte),
-              PanelInfos('Energy [J]', Units.joule),
-              PanelInfos('Power [W]', Units.watt),
-              PanelInfos('Clock [MHz] STAT Avg', Units.megahertz), ]
+    fields = [PanelInfos(likwid_keys.runtime_key, Units.seconds),
+              PanelInfos(likwid_keys.dp_key, Units.mflop_sec),
+              PanelInfos(likwid_keys.oi_key, Units.flop_per_byte),
+              PanelInfos(f'{likwid_keys.avx_dp_key}"/"{likwid_keys.dp_key}', Units.percent),
+              PanelInfos(likwid_keys.memory_bandwidth_key, Units.mbytes_per_second),
+              PanelInfos(likwid_keys.memory_write_bandwidth_key, Units.mbytes_per_second),
+              PanelInfos(likwid_keys.memory_read_bandwidth_key, Units.mbytes_per_second),
+              PanelInfos(likwid_keys.memory_data_key, Units.gigabyte),
+              PanelInfos(likwid_keys.memory_read_key, Units.gigabyte),
+              PanelInfos(likwid_keys.memory_write_key, Units.gigabyte),
+              PanelInfos(likwid_keys.energy_key, Units.joule),
+              PanelInfos(likwid_keys.power_key, Units.watt),
+              PanelInfos(likwid_keys.clock_key, Units.megahertz), ]
 
     filter_vars = [get_dashboard_variable(filter, "", data_source) for filter in filters]
     benchmark = get_measurement_filter("benchmark", data_source, filter_pattern="[^u]$")
@@ -107,17 +98,17 @@ def dashboard_pystencils_gpu():
         Filter("GPU"),
     ]
 
-    fields = [PanelInfos(runtime_key, Units.seconds),
-              PanelInfos(dp_key, Units.mflop_sec),
-              PanelInfos(p_max_key, Units.mflop_sec),
-              PanelInfos(f'{dp_key}"/"{p_max_key}', Units.percent),
-              PanelInfos(operational_intensity_key, Units.flop_per_byte),
-              PanelInfos(memory_bandwidth_key, Units.mbytes_per_second),
-              PanelInfos(memory_write_bandwidth_key, Units.mbytes_per_second),
-              PanelInfos(memory_read_bandwidth_key, Units.mbytes_per_second),
-              PanelInfos(memory_data_key, Units.gigabyte),
-              PanelInfos(memory_write_data_key, Units.gigabyte),
-              PanelInfos(memory_read_data_key, Units.gigabyte),
+    fields = [PanelInfos(ncu_keys.runtime_key, Units.seconds),
+              PanelInfos(ncu_keys.dp_key, Units.mflop_sec),
+              PanelInfos(ncu_keys.p_max_key, Units.mflop_sec),
+              PanelInfos(f'{ncu_keys.dp_key}"/"{ncu_keys.p_max_key}', Units.percent),
+              PanelInfos(ncu_keys.operational_intensity_key, Units.flop_per_byte),
+              PanelInfos(ncu_keys.memory_bandwidth_key, Units.mbytes_per_second),
+              PanelInfos(ncu_keys.memory_write_bandwidth_key, Units.mbytes_per_second),
+              PanelInfos(ncu_keys.memory_read_bandwidth_key, Units.mbytes_per_second),
+              PanelInfos(ncu_keys.memory_data_key, Units.gigabyte),
+              PanelInfos(ncu_keys.memory_write_data_key, Units.gigabyte),
+              PanelInfos(ncu_keys.memory_read_data_key, Units.gigabyte),
               ]
 
     filter_vars = [get_dashboard_variable(filter, "", data_source) for filter in filters]
-- 
GitLab