[hardware] Add handling of multiple sections
> Add handling of multiple sections.
> Delete keys list.
> Add argument parsing for the results folder.
[hardware] corrent lint error
-import csv
+#!/usr/bin/env python3
+
+# Copyright 2022 ETH Zurich and University of Bologna.
+# Solderpad Hardware License, Version 0.51, see LICENSE for details.
+# SPDX-License-Identifier: SHL-0.51
+
+# This script takes a set of .csv files in one of the results folders and
+# generates the average performances over all the cores used.
+# Author: Marco Bertuletti <mbertuletti@iis.ee.ethz.ch>
+
import os
import pandas as pd
import numpy as np
-from collections import deque, defaultdict
-import sys
+import argparse
-path = '/scratch2/mempool/hardware/build/traces'
ext = ('.csv')
padding = ' ' + '.' * 25
-keys = [ 'cycles',
- 'snitch_loads',
- 'snitch_stores',
- 'snitch_avg_load_latency',
- 'snitch_occupancy',
- 'total_ipc',
- 'snitch_issues',
- 'stall_tot',
- 'stall_ins',
- 'stall_raw',
- 'stall_raw_lsu',
- 'stall_raw_acc',
- 'stall_lsu',
- 'stall_acc',
- 'seq_loads_local',
- 'seq_loads_global',
- 'itl_loads_local',
- 'itl_loads_global',
- 'seq_latency_local',
- 'seq_latency_global',
- 'itl_latency_local',
- 'itl_latency_global',
- 'seq_stores_local',
- 'seq_stores_global',
- 'itl_stores_local',
- 'itl_stores_global']
-
+parser = argparse.ArgumentParser()
+parser.add_argument(
+ '-folder',
+ help='Name of the results folder with traces to be averaged.'
+)
+args = parser.parse_args()
+
+os.chdir("../results")
+os.chdir(args.folder)
+path = os.getcwd()
+print(path)
for files in os.listdir(path):
if files.endswith(ext):
- print(files)
csvread = pd.read_csv(files)
- print('\n\n')
- #print(csvread)
- print("******************************")
- print("** AVERAGE PERFORMANCES **")
- print("******************************")
+
+ print("\n")
+ print("*******************************")
+ print("** AVERAGE PERFORMANCE **")
+ print("*******************************")
print("")
+ for section in set(csvread['section']):
+ print("Section %d:\n" % section)
+ sectionread = csvread.loc[csvread['section'] == section]
+ keys = csvread.columns
+ remove_keys = ['core',
+ 'section',
+ 'start',
+ 'end',
+ 'snitch_load_latency',
+ 'snitch_load_region',
+ 'snitch_load_tile',
+ 'snitch_store_region',
+ 'snitch_store_tile']
+ keys = keys.drop(remove_keys, errors='raise')
for key in keys:
- column = csvread[key].replace(np.nan,0)
+ try:
+ column = sectionread[key].replace(np.nan, 0)
column = column.to_numpy()
avg = np.average(column)
- #print('{:.40s} {}'.format(key + padding, avg))
+ except Exception:
+ # Key could not be averaged
+ continue
print("%-30s %4.4f" % (key, avg))
- print('\n\n')
-
-
-
-
-
