Skip to content

Commit

Permalink
kernel_name_shortener now called in create_df_kerenel_top_stats and
Browse files Browse the repository at this point in the history
create_df_pmc

Signed-off-by: Jose Santos <[email protected]>
  • Loading branch information
JoseSantosAMD committed Mar 12, 2024
1 parent de1732d commit 639dc20
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
7 changes: 6 additions & 1 deletion src/omniperf_analyze/analysis_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ def pre_processing(self):
filter_dispatch_ids=self._runs[d[0]].filter_dispatch_ids,
time_unit=self.get_args().time_unit,
max_stat_num=self.get_args().max_stat_num,
kernel_verbose = self.get_args().kernel_verbose,
)
# create 'mega dataframe'
self._runs[d[0]].raw_pmc = file_io.create_df_pmc(
d[0], self.get_args().verbose
d[0], self.get_args().kernel_verbose, self.get_args().verbose
)
# demangle and overwrite original 'Kernel_Name'
kernel_name_shortener(self._runs[d[0]].raw_pmc, self.get_args().kernel_verbose)

# create the loaded table
parser.load_table_data(
workload=self._runs[d[0]],
Expand All @@ -58,6 +62,7 @@ def pre_processing(self):
debug=self.get_args().debug,
verbose=self.get_args().verbose,
)


@demarcate
def run_analysis(self):
Expand Down
4 changes: 3 additions & 1 deletion src/omniperf_analyze/analysis_webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def generate_from_filter(
filter_dispatch_ids=base_data[base_run].filter_dispatch_ids,
time_unit=self.get_args().time_unit,
max_stat_num=base_data[base_run].filter_top_n,
kernel_verbose=self.get_args().kernel_verbose
)
# Only display basic metrics if no filters are applied
if not (disp_filt or kernel_filter or gcd_filter):
Expand Down Expand Up @@ -275,10 +276,11 @@ def pre_processing(self):
filter_dispatch_ids=self._runs[self.dest_dir].filter_dispatch_ids,
time_unit=args.time_unit,
max_stat_num=args.max_stat_num,
kernel_verbose=self.get_args().kernel_verbose
)
# create 'mega dataframe'
self._runs[self.dest_dir].raw_pmc = file_io.create_df_pmc(
self.dest_dir, args.verbose
self.dest_dir, self.get_args().kernel_verbose, args.verbose
)
# create the loaded kernel stats
parser.load_kernel_top(self._runs[self.dest_dir], self.dest_dir)
Expand Down
8 changes: 7 additions & 1 deletion src/utils/file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from pathlib import Path
from utils import schema
from utils.utils import console_debug, console_error
from utils.kernel_name_shortener import kernel_name_shortener
import config

# TODO: use pandas chunksize or dask to read really large csv file
Expand Down Expand Up @@ -89,6 +90,7 @@ def create_df_kernel_top_stats(
filter_dispatch_ids,
time_unit,
max_stat_num,
kernel_verbose,
sortby="sum",
):
"""
Expand All @@ -97,6 +99,8 @@ def create_df_kernel_top_stats(
# NB:
# We even don't have to create pmc_kernel_top.csv explictly
df = pd.read_csv(os.path.join(raw_data_dir, schema.pmc_perf_file_prefix + ".csv"))
# Demangle original KernelNames
kernel_name_shortener(df, kernel_verbose)

# The logic below for filters are the same as in parser.apply_filters(),
# which can be merged together if need it.
Expand Down Expand Up @@ -154,7 +158,7 @@ def create_df_kernel_top_stats(
grouped.to_csv(os.path.join(raw_data_dir, "pmc_kernel_top.csv"), index=False)


def create_df_pmc(raw_data_dir, verbose):
def create_df_pmc(raw_data_dir, kernel_verbose, verbose):
"""
Load all raw pmc counters and join into one df.
"""
Expand All @@ -170,6 +174,8 @@ def create_df_pmc(raw_data_dir, verbose):
f == schema.pmc_perf_file_prefix + ".csv"
):
tmp_df = pd.read_csv(os.path.join(root, f))
# Demangle original KernelNames
kernel_name_shortener(tmp_df, kernel_verbose)
dfs.append(tmp_df)
coll_levels.append(f[:-4])
final_df = pd.concat(dfs, keys=coll_levels, axis=1, copy=False)
Expand Down
26 changes: 11 additions & 15 deletions src/utils/kernel_name_shortener.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
##############################################################################el

import os
import glob
import logging
import re
import subprocess
import pandas as pd

from utils.utils import console_error, console_debug, console_log
from utils.utils import console_error, console_log

cache = dict()

Expand Down Expand Up @@ -59,6 +59,7 @@ def shorten_file(df, level):

demangled_name, e = proc.communicate()
demangled_name = str(demangled_name, "UTF-8").strip()
demangled_name="hello"

# cache miss, add the shortened name to the dictionary
new_name = ""
Expand Down Expand Up @@ -109,7 +110,7 @@ def shorten_file(df, level):
current_level -= 1
curr_index += 1

cache[original_name] = new_name
cache[original_name] = "hello"
if new_name == None or new_name == "":
cache[original_name] = demangled_name

Expand All @@ -125,18 +126,13 @@ def shorten_file(df, level):
"Could not resolve c++filt in expected directory: %s" % cpp_filt
)

for fpath in glob.glob(workload_dir + "/[SQpmc]*.csv"):
try:
orig_df = pd.read_csv(
fpath,
on_bad_lines="skip",
engine="python",
)
modified_df = shorten_file(orig_df, level)
try:
modified_df = shorten_file(df, level)
console_log("profiling", "Kernel_Name shortening complete.")
return modified_df
except pd.errors.EmptyDataError:
console_debug(
"profiling", "Skipping shortening on empty csv: %s" % str(fpath)
except pd.errors.EmptyDataError:
logging.debug("[profiling] Skipping shortening on empty csv"
)

console_log("profiling", "Kernel_Name shortening complete.")


0 comments on commit 639dc20

Please sign in to comment.