From 8ba104ddc2be21ae507c218fda6f080c553731df Mon Sep 17 00:00:00 2001 From: Roger Barton Date: Thu, 15 Feb 2024 19:21:29 +0100 Subject: [PATCH] process more perf data into df, export to matlab --- target/sim/bench.ipynb | 101 ++++++++++++------ .../cfg/{single-cluster.hjson => 1Q1C.hjson} | 0 2 files changed, 68 insertions(+), 33 deletions(-) rename target/sim/cfg/{single-cluster.hjson => 1Q1C.hjson} (100%) diff --git a/target/sim/bench.ipynb b/target/sim/bench.ipynb index 3b41a6a8b..a51385dcf 100644 --- a/target/sim/bench.ipynb +++ b/target/sim/bench.ipynb @@ -15,7 +15,7 @@ "metadata": {}, "outputs": [], "source": [ - "!python -m pip install pandas plotly pyyaml" + "!python -m pip install pandas plotly pyyaml scipy" ] }, { @@ -330,22 +330,6 @@ "outputs": [], "source": [] }, - { - "cell_type": "code", - "execution_count": null, - "id": "813a82e1-5683-497a-8603-545cb55baada", - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "46335c5f-0802-4541-8ebe-5f3ef2de12e4", - "metadata": {}, - "outputs": [], - "source": [] - }, { "cell_type": "markdown", "id": "db94fbb4-44d3-4ca1-a271-5be3d0f904f5", @@ -616,32 +600,33 @@ { "cell_type": "code", "execution_count": null, - "id": "6186458e-484c-495a-8b5a-1bd5883667ac", + "id": "75cb302d-07aa-49e9-819a-0487738bcea2", "metadata": {}, "outputs": [], "source": [ "import hjson\n", "from pathlib import Path\n", - "dfs = []\n", - "for i in range(4):\n", - " with Path(f'logs_{i}/params.hjson').open() as f:\n", - " param = hjson.loads(f.read())\n", - " df1 = pd.json_normalize(param)\n", - " df1.index = df1.index + i\n", - " dfs.append(df1)\n", - "runs = pd.concat(dfs)\n", - "runs" + "import pandas as pd\n", + "import plotly.express as px" ] }, { "cell_type": "code", "execution_count": null, - "id": "481d6636-026f-4111-88e6-b86773d1aa03", + "id": "74f75c0a-47e4-432a-bf91-3750988e64ed", "metadata": {}, "outputs": [], "source": [ - "import pandas as pd\n", - "import plotly.express as px" + "dfs = []\n", + "n_runs = 11\n", + "for i in range(n_runs):\n", + " with Path(f'logs_{i}/params.hjson').open() as f:\n", + " param = hjson.loads(f.read())\n", + " df1 = pd.json_normalize(param)\n", + " df1.index = df1.index + i\n", + " dfs.append(df1)\n", + "runs = pd.concat(dfs)\n", + "runs" ] }, { @@ -657,7 +642,7 @@ "end_region = -2\n", "\n", "dfs = []\n", - "for run_id in range(4):\n", + "for run_id in range(n_runs):\n", " for i in range(9):\n", " hart_type = 'dma' if i % 9 == 8 else 'fpu'\n", " p = [i % 9, int(i / 9), 0]\n", @@ -703,6 +688,16 @@ "perf" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "015c33a5-e12c-459f-8a7c-fa0980fe66f0", + "metadata": {}, + "outputs": [], + "source": [ + "perf[(perf['hart_type'] == 'fpu') & (perf['region_id'] == 2)][['fpss_fpu_occupancy','gemmInfo.K','gemmInfo.N']]" + ] + }, { "cell_type": "code", "execution_count": null, @@ -710,8 +705,18 @@ "metadata": {}, "outputs": [], "source": [ - "# px.violin(perf[(perf['hart_type'] == 'fpu') & (perf['region_id'] == 2)], 'gemmInfo.K', 'fpss_fpu_occupancy', violinmode='overlay')\n", - "px.bar(perf[(perf['hart_type'] == 'fpu')], 'gemmInfo.K', 'fpss_fpu_occupancy', color='region_id')" + "# px.violin(perf[(perf['hart_type'] == 'fpu') & (perf['region_id'] == 2)], color='gemmInfo.K', y='fpss_fpu_occupancy', violinmode='overlay')\n", + "px.scatter(perf[(perf['hart_type'] == 'fpu')], 'gemmImpl.L1_K', 'fpss_fpu_occupancy', color='gemmImpl.L1_N', log_x=True, range_y=[0,1])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "710efc36-a758-4571-83db-bd46b3ce6105", + "metadata": {}, + "outputs": [], + "source": [ + "px.scatter(perf[(perf['hart_type'] == 'fpu')], 'gemmImpl.L1_K', 'cycles', color='gemmImpl.L1_N', log_x=True)" ] }, { @@ -754,6 +759,36 @@ "px.violin(perf[(perf['cycles'] < 1000) & (perf['fpss_occupancy'] == 0)], 'cycles')" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "6b80cbd5-49a7-4067-bc25-4b846f7ae433", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cf2bab5d-ee65-4dca-84fa-e067d44f8cd8", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4d4799a3-c653-438b-b4b1-4d209a7deb43", + "metadata": {}, + "outputs": [], + "source": [ + "# Export df to matlab\n", + "import scipy.io as sio\n", + "import re\n", + "out = perf[(perf['hart_type'] == 'fpu') & (perf['region_id'] == 2)]\n", + "sio.savemat('./logs/perf.mat', out.rename(columns=lambda x: re.sub('[\\. -]','_',x)).to_dict('list'))" + ] + }, { "cell_type": "markdown", "id": "925ac4a8-de21-4203-b52a-185aaa3c212c", diff --git a/target/sim/cfg/single-cluster.hjson b/target/sim/cfg/1Q1C.hjson similarity index 100% rename from target/sim/cfg/single-cluster.hjson rename to target/sim/cfg/1Q1C.hjson