From 241a0949e13df8918f29bb84053daaa5081355a7 Mon Sep 17 00:00:00 2001 From: benrichard-amd Date: Wed, 10 Jul 2024 14:55:19 -0500 Subject: [PATCH] Remove duplicate normal counters Interleve TCC channel counters in putput file e.g. TCC_HIT[0] TCC_ATOMIC[0] ... TCC_HIT[1] TCC_ATOMIC[1] Signed-off-by: benrichard-amd --- src/omniperf_soc/soc_base.py | 58 +++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/src/omniperf_soc/soc_base.py b/src/omniperf_soc/soc_base.py index fc9aa4a26e..61d09e1e20 100644 --- a/src/omniperf_soc/soc_base.py +++ b/src/omniperf_soc/soc_base.py @@ -333,8 +333,6 @@ def perfmon_coalesce(pmc_files_list, perfmon_config, workload_dir): normal_counters = OrderedDict() - mpattern = r"^pmc:(.*)" - for fname in pmc_files_list: lines = open(fname, "r").read().splitlines() @@ -347,37 +345,42 @@ def perfmon_coalesce(pmc_files_list, perfmon_config, workload_dir): continue # all pmc counters start with "pmc:" - m = re.match(mpattern, stext) + m = re.match(r"^pmc:(.*)", stext) if m is None: continue counters = m.group(1).split() - # Check for accumulate counter if "SQ_ACCUM_PREV_HIRES" in counters: + # Accumulate counters accumulate_counters.append(counters.copy()) - counters.clear() - - # PMC counters - for ctr in counters: - - # Channel counter - if '[' in ctr: + else: + # Normal counters + for ctr in counters: + + # Channel counter e.g. TCC_ATOMIC[0] + if '[' in ctr: - # Remove number, append "_expand" so we know to add the channel later - channel = int(ctr.split('[')[1].split(']')[0]) - if channel == 0: - counter_name = ctr.split('[')[0] + "_expand" + # Remove channel number, append "_expand" so we know + # add the channel numbers back later + channel = int(ctr.split('[')[1].split(']')[0]) + if channel == 0: + counter_name = ctr.split('[')[0] + "_expand" + try: + normal_counters[counter_name] += 1 + except: + normal_counters[counter_name] = 1 + else: try: - normal_counters[counter_name] += 1 + normal_counters[ctr] += 1 except: - normal_counters[counter_name] = 1 - else: - counter_name = ctr - try: - normal_counters[ctr] += 1 - except: - normal_counters[ctr] = 1 + normal_counters[ctr] = 1 + + # De-duplicate. Remove accumulate counters from normal counters + for accus in accumulate_counters: + for accu in accus: + if accu in normal_counters: + del normal_counters[accu] output_files = [] @@ -402,23 +405,22 @@ def perfmon_coalesce(pmc_files_list, perfmon_config, workload_dir): output_files[-1].add(ctr) + # Output to files for i, f in enumerate(output_files): file_name = os.path.join(workload_perfmon_dir, "pmc_perf_{}.txt".format(i)) pmc = [] for block_name in f.blocks.keys(): - if block_name == "TCC": # Expand and interleve the TCC channel counters # e.g. TCC_HIT[0] TCC_ATOMIC[0] ... TCC_HIT[1] TCC_ATOMIC[1] ... channel_counters = [] - num_channels = perfmon_config["TCC_channels"] for ctr in f.blocks[block_name].elements: if "_expand" in ctr: channel_counters.append(ctr.split("_expand")[0]) - for i in range(0, num_channels): + for i in range(0, perfmon_config["TCC_channels"]): for c in channel_counters: pmc.append("{}[{}]".format(c, i)) @@ -440,8 +442,8 @@ def perfmon_coalesce(pmc_files_list, perfmon_config, workload_dir): fd.write("kernel:\n") fd.close() - # add a timestamp file - fd = open(workload_perfmon_dir + "/timestamps.txt", "w") + # Add a timestamp file + fd = open(os.path.join(workload_perfmon_dir, "timestamps.txt"), "w") fd.write("pmc:\n\n") fd.write("gpu:\n") fd.write("range:\n")