From 726b01b9e4e6787d02b1013547aac11c98cf59cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Clasc=C3=A0?= Date: Fri, 28 Jun 2024 14:38:46 +0200 Subject: [PATCH] Fixes #4 GPU metrics matching with device now done with lower 8 bits of typeId --- parse-nsys-stats.ipynb | 5 +++-- parse-nsys-stats.py | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/parse-nsys-stats.ipynb b/parse-nsys-stats.ipynb index 26013dc..c4af5a0 100644 --- a/parse-nsys-stats.ipynb +++ b/parse-nsys-stats.ipynb @@ -1489,8 +1489,8 @@ "metadata": {}, "outputs": [], "source": [ - "gpu_metrics[\"task\"] = gpu_metrics.groupby([\"typeId\"]).ngroup() + 1\n", - "gpu_metrics[\"deviceId\"] = gpu_metrics.groupby([\"typeId\"]).ngroup()\n", + "#gpu_metrics[\"task\"] = gpu_metrics.groupby([\"typeId\"]).ngroup() + 1\n", + "gpu_metrics[\"deviceId\"] = gpu_metrics[\"typeId\"].apply(lambda x: x & 0xFF)\n", "gpu_metrics_agg = gpu_metrics.groupby([\"timestamp\", \"typeId\"]).agg({'metricId': lambda x: list(x+event_type_metrics_base),\n", " 'value': lambda x: list(x),\n", " 'deviceId': 'first',\n", @@ -3094,6 +3094,7 @@ } ], "source": [ + "gpu_metrics_agg[\"task\"] = gpu_metrics_agg[\"deviceId\"].map(devices_set[\"task\"])\n", "gpu_metrics_agg[\"thread\"] = gpu_metrics_agg[\"task\"].map(aux_streams.set_index('task')[\"thread\"])\n", "gpu_metrics_agg" ] diff --git a/parse-nsys-stats.py b/parse-nsys-stats.py index 5d300cb..651a447 100755 --- a/parse-nsys-stats.py +++ b/parse-nsys-stats.py @@ -155,12 +155,11 @@ if t_metrics: metrics_description = pd.read_sql_table("TARGET_INFO_GPU_METRICS", f"sqlite:///{os.path.splitext(REPORT_FILE)[0]}.sqlite") metrics_event_names = metrics_description.groupby(["metricId"]).agg({'metricName': 'first'}).reset_index() metrics_event_names["metricId"] = metrics_event_names["metricId"] + event_type_metrics_base - gpu_metrics["task"] = gpu_metrics.groupby(["typeId"]).ngroup() + 1 - gpu_metrics["deviceId"] = gpu_metrics.groupby(["typeId"]).ngroup() + #gpu_metrics["task"] = gpu_metrics.groupby(["typeId"]).ngroup() + 1 + gpu_metrics["deviceId"] = gpu_metrics["typeId"].apply(lambda x: x & 0xFF) gpu_metrics_agg = gpu_metrics.groupby(["timestamp", "typeId"]).agg({'metricId': lambda x: list(x+event_type_metrics_base), 'value': lambda x: list(x), - 'deviceId': 'first', - 'task': 'first'}) + 'deviceId': 'first'}) gpu_metrics_agg.reset_index(inplace=True) @@ -272,6 +271,7 @@ if t_metrics: aux_streams["row_name"] = "Metrics GPU"+aux_streams["deviceid"].astype(str) aux_streams["Pid"] = aux_streams["deviceid"].map(tasks_set.set_index('device')["Pid"]) aux_streams["thread"] = aux_streams["thread"] + aux_streams["deviceid"].map(tasks_set.set_index('device')['thread']) + 1 + gpu_metrics_agg["task"] = gpu_metrics_agg["deviceId"].map(devices_set["task"]) gpu_metrics_agg["thread"] = gpu_metrics_agg["task"].map(aux_streams.set_index('task')["thread"]) streams = pd.concat([streams, aux_streams]).sort_values(['task', 'thread']) -- GitLab