Add a supported_archs property to Omniperf base class

Signed-off-by: colramos-amd <colramos@amd.com>


[ROCm/rocprofiler-compute commit: 97c5b2c0a1]
This commit is contained in:
colramos-amd
2023-12-11 16:35:09 -06:00
committed by Karl W. Schulz
parent 19492730f3
commit 3374ead0a9
4 changed files with 30 additions and 62 deletions
+4 -19
View File
@@ -25,29 +25,14 @@
import argparse
import shutil
import os
import glob
def load_avail_arch(omniperf_home):
'''
Load list of avail archs by checking against defined implementations
'''
matching_files=glob.glob(os.path.join(omniperf_home, 'omniperf_soc', 'soc_*.py'))
supported_arch=[]
# Load list of supported archs
for filepath in matching_files:
filename=os.path.basename(filepath)
postfix=filename[len('soc_'):-len('.py')]
# print(f"File: {filename}, Postfix: {postfix}")
if postfix != "base":
supported_arch.append(postfix)
return supported_arch
def print_avail_arch(avail_arch):
def print_avail_arch(avail_arch: list):
ret_str = "\t\tList all available metrics for analysis on specified arch:"
for arch in avail_arch:
ret_str += "\n\t\t {}".format(arch)
return ret_str
def omniarg_parser(parser, omniperf_home, omniperf_version):
def omniarg_parser(parser, omniperf_home, supported_archs, omniperf_version):
# -----------------------------------------
# Parse arguments (dependent on mode)
# -----------------------------------------
@@ -410,8 +395,8 @@ def omniarg_parser(parser, omniperf_home, omniperf_version):
analyze_group.add_argument(
"--list-metrics",
metavar="",
choices=load_avail_arch(omniperf_home),#["gfx906", "gfx908", "gfx90a"],
help=print_avail_arch(load_avail_arch(omniperf_home)),
choices=supported_archs.keys(),#["gfx906", "gfx908", "gfx90a"],
help=print_avail_arch(supported_archs.keys()),
)
analyze_group.add_argument(
"-k",
@@ -35,11 +35,11 @@ import pandas as pd
from tabulate import tabulate
class OmniAnalyze_Base():
def __init__(self,args,options):
def __init__(self,args,supported_archs):
self.__args = args
self._runs = OrderedDict() #NB: I made this public so children can modify/add to obj properties
self._arch_configs = {} #NB: I made this public so children can modify/add to obj properties
self.__options = options
self.__supported_archs = supported_archs
self._output = None #NB: I made this public so children can modify/add to obj properties
def get_args(self):
@@ -47,7 +47,7 @@ class OmniAnalyze_Base():
@demarcate
def generate_configs(self, arch, config_dir, list_kernels, filter_metrics):
single_panel_config = file_io.is_single_panel_config(Path(config_dir))
single_panel_config = file_io.is_single_panel_config(Path(config_dir), self.__supported_archs)
ac = schema.ArchConfig()
if list_kernels:
@@ -33,6 +33,7 @@ from utils.utils import demarcate, trace_logger, get_version, get_version_displa
from argparser import omniarg_parser
import config
import pandas as pd
import importlib
class Omniperf:
def __init__(self):
@@ -46,6 +47,11 @@ class Omniperf:
"ver_pretty": None,
}
self.__options = {}
self.__supported_archs = {
"gfx906": {"mi50": ["MI50", "MI60"]},
"gfx908": {"mi100": ["MI100"]},
"gfx90a": {"mi200": ["MI210", "MI250", "MI250X"]},
}
self.setup_logging()
self.set_version()
@@ -140,34 +146,20 @@ class Omniperf:
mspec = get_machine_specs(0)
arch = mspec.GPU
target=""
if arch == "gfx906":
target = "mi50"
elif arch == "gfx908":
target = "mi100"
elif arch == "gfx90a":
target = "mi200"
else:
error("Unsupported SoC -> %s" % arch)
self.__soc_name.add(target)
if hasattr(self.__args, 'target'):
self.__args.target = target
# instantiate underlying SoC support class
# in case of analyze mode, __soc can accommodate multiple archs
if target == "mi50":
from omniperf_soc.soc_gfx906 import gfx906_soc
self.__soc[arch] = gfx906_soc(self.__args)
elif target == "mi100":
from omniperf_soc.soc_gfx908 import gfx908_soc
self.__soc[arch] = gfx908_soc(self.__args)
elif target == "mi200":
from omniperf_soc.soc_gfx90a import gfx90a_soc
self.__soc[arch] = gfx90a_soc(self.__args)
else:
if arch not in self.__supported_archs.keys():
logging.error("Unsupported SoC")
sys.exit(1)
else:
target = list(self.__supported_archs[arch].keys())[0]
self.__soc_name.add(target)
if hasattr(self.__args, 'target'):
self.__args.target = target
soc_module = importlib.import_module('omniperf_soc.soc_'+arch)
soc_class = getattr(soc_module, arch+'_soc')
self.__soc[arch] = soc_class(self.__args)
logging.info("SoC = %s" % self.__soc_name)
return arch
@@ -182,7 +174,7 @@ class Omniperf:
),
usage="omniperf [mode] [options]",
)
omniarg_parser(parser, config.omniperf_home, self.__version)
omniarg_parser(parser, config.omniperf_home, self.__supported_archs ,self.__version)
self.__args = parser.parse_args()
if self.__args.mode == None:
@@ -241,10 +233,10 @@ class Omniperf:
if self.__analyze_mode == "cli":
from omniperf_analyze.analysis_cli import cli_analysis
analyzer = cli_analysis(self.__args,self.__options)
analyzer = cli_analysis(self.__args,self.__supported_archs)
elif self.__analyze_mode == "webui":
from omniperf_analyze.analysis_webui import webui_analysis
analyzer = webui_analysis(self.__args,self.__options)
analyzer = webui_analysis(self.__args,self.__supported_archs)
else:
error("Unsupported anlaysis mode -> %s" % self.__analyze_mode)
@@ -214,29 +214,20 @@ def collect_wave_occu_per_cu(in_dir, out_dir, numSE):
all.to_csv(Path(out_dir, "wave_occu_per_cu.csv"), index=False)
def is_single_panel_config(root_dir):
def is_single_panel_config(root_dir, supported_archs):
"""
Check the root configs dir structure to decide using one config set for all
archs, or one for each arch.
"""
matching_files=glob.glob(os.path.join(config.omniperf_home, 'omniperf_soc', 'soc_*.py'))
supported_arch=[]
# Load list of supported archs
for filepath in matching_files:
filename=os.path.basename(filepath)
postfix=filename[len('soc_'):-len('.py')]
# print(f"File: {filename}, Postfix: {postfix}")
if postfix != "base":
supported_arch.append(postfix)
# If not single config, verify all supported archs have defined configs
supported_archs = supported_archs.keys()
counter = 0
for arch in supported_arch:
for arch in supported_archs:
if root_dir.joinpath(arch).exists():
counter += 1
if counter == 0:
return True
elif counter == len(supported_arch):
elif counter == len(supported_archs):
return False
else:
logging.error("Found multiple panel config sets but incomplete for all archs!")