Skip to content

Commit

Permalink
Add a supported_archs property to Omniperf base class
Browse files Browse the repository at this point in the history
Signed-off-by: colramos-amd <colramos@amd.com>
  • Loading branch information
coleramos425 authored and koomie committed Dec 11, 2023
1 parent fbe6b2d commit 97c5b2c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 62 deletions.
23 changes: 4 additions & 19 deletions src/argparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
# -----------------------------------------
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions src/omniperf_analyze/analysis_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@
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):
return self.__args

@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:
Expand Down
46 changes: 19 additions & 27 deletions src/omniperf_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from argparser import omniarg_parser
import config
import pandas as pd
import importlib

class Omniperf:
def __init__(self):
Expand All @@ -46,6 +47,11 @@ def __init__(self):
"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()
Expand Down Expand Up @@ -140,34 +146,20 @@ def detect_soc(self, arch=None):
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
Expand All @@ -182,7 +174,7 @@ def parse_args(self):
),
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:
Expand Down Expand Up @@ -241,10 +233,10 @@ def run_analysis(self):

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)

Expand Down
17 changes: 4 additions & 13 deletions src/utils/file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand Down

0 comments on commit 97c5b2c

Please sign in to comment.