Improved communication between SoC and profiler classes
Signed-off-by: coleramos425 <colramos@amd.com>
[ROCm/rocprofiler-compute commit: 4c1e516fb6]
This commit is contained in:
@@ -37,7 +37,6 @@ class OmniProfiler_Base():
|
||||
self.__args = args
|
||||
self.__profiler = profiler_mode
|
||||
self._soc = soc # OmniSoC obj
|
||||
|
||||
self.__perfmon_dir = os.path.join(str(config.omniperf_home), "omniperf_soc", "profile_configs")
|
||||
|
||||
def get_args(self):
|
||||
@@ -255,7 +254,10 @@ class OmniProfiler_Base():
|
||||
"""Perform any pre-processing steps prior to profiling.
|
||||
"""
|
||||
logging.debug("[profiling] pre-processing using %s profiler" % self.__profiler)
|
||||
|
||||
|
||||
# verify soc compatibility
|
||||
if self.__profiler not in self._soc.get_compatible_profilers():
|
||||
error("%s is not enabled in %s. Available profilers include: %s" % (self._soc.get_soc_name(), self.__profiler, self._soc.get_compatible_profilers()))
|
||||
# verify not accessing parent directories
|
||||
if ".." in str(self.__args.path):
|
||||
error("Access denied. Cannot access parent directories in path (i.e. ../)")
|
||||
@@ -345,7 +347,9 @@ class OmniProfiler_Base():
|
||||
# perfmon_dir=self.__perfmon_dir,
|
||||
# cmd=self.__args.remaining,
|
||||
# target=self.__args.target,
|
||||
profiler_options=options
|
||||
profiler_options=options,
|
||||
target=self.__args.target,
|
||||
workload_dir=self.get_args().path
|
||||
)
|
||||
|
||||
elif self.__profiler == "rocscope":
|
||||
|
||||
@@ -55,7 +55,7 @@ class rocprof_v2_profiler(OmniProfiler_Base):
|
||||
"""
|
||||
super().pre_processing()
|
||||
if self.ready_to_profile:
|
||||
self.pmc_perf_split(self.get_args().path)
|
||||
self.pmc_perf_split()
|
||||
|
||||
@demarcate
|
||||
def run_profiling(self, version, prog):
|
||||
@@ -68,26 +68,6 @@ class rocprof_v2_profiler(OmniProfiler_Base):
|
||||
else:
|
||||
logging.info("[roofline] Detected existing pmc_perf.csv")
|
||||
|
||||
# [Run] Get any SoC specific rocprof options
|
||||
# Pass profiler name and throw error if not supported
|
||||
soc_options = self._soc.get_rocprof_options(rocprof_version)
|
||||
|
||||
# [Run] Load any rocprof version rocprof options
|
||||
# -i
|
||||
# -d
|
||||
# -o
|
||||
profiler_options = [
|
||||
"-i", fname,
|
||||
"-d", workload_dir,
|
||||
"-o", fbase,
|
||||
cmd
|
||||
]
|
||||
|
||||
# [Run] Call run_prof() util
|
||||
|
||||
|
||||
|
||||
|
||||
@demarcate
|
||||
def post_processing(self):
|
||||
"""Perform any post-processing steps prior to profiling.
|
||||
|
||||
@@ -36,21 +36,22 @@ from pathlib import Path
|
||||
class OmniSoC_Base():
|
||||
def __init__(self,args):
|
||||
self.__args = args
|
||||
self.__soc = None
|
||||
self.__name = None # SoC name
|
||||
self.__perfmon_dir = None
|
||||
self.__perfmon_config = {} # Per IP block max number of simulutaneous counters. GFX IP Blocks
|
||||
self.__soc_params = {} # SoC specifications
|
||||
self.__compatible_profilers = [] # Store profilers compatible with SoC
|
||||
if self.__args.path == os.path.join(os.getcwd(), "workloads"):
|
||||
self.__workload_dir = os.path.join(self.__args.path, self.__args.name, self.__args.target)
|
||||
else:
|
||||
self.__workload_dir = self.__args.path
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self.__soc)
|
||||
return hash(self.__name)
|
||||
def __eq__(self, other):
|
||||
if not isinstance(other, type(self)):
|
||||
return NotImplemented
|
||||
return self.__soc == other.get_soc()
|
||||
return self.__name == other.get_soc()
|
||||
|
||||
def set_perfmon_dir(self, path:str):
|
||||
self.__perfmon_dir = path
|
||||
@@ -62,12 +63,16 @@ class OmniSoC_Base():
|
||||
return str(Path(self.__perfmon_dir).parent.absolute())
|
||||
def get_soc_param(self):
|
||||
return self.__soc_params
|
||||
def set_soc(self, soc: str):
|
||||
self.__soc = soc
|
||||
def get_soc(self):
|
||||
return self.__soc
|
||||
def set_soc_name(self, soc: str):
|
||||
self.__name = soc
|
||||
def get_soc_name(self):
|
||||
return self.__name
|
||||
def get_args(self):
|
||||
return self.__args
|
||||
def set_compatible_profilers(self, profiler_names: list):
|
||||
self.__compatible_profilers = profiler_names
|
||||
def get_compatible_profilers(self):
|
||||
return self.__compatible_profilers
|
||||
|
||||
@demarcate
|
||||
def get_profiler_options(self):
|
||||
@@ -94,7 +99,7 @@ class OmniSoC_Base():
|
||||
|
||||
if not roofline_perfmon_only:
|
||||
ref_pmc_files_list = glob.glob(self.__perfmon_dir + "/" + "pmc_*perf*.txt")
|
||||
ref_pmc_files_list += glob.glob(self.__perfmon_dir + "/" + self.__soc + "/pmc_*_perf*.txt")
|
||||
ref_pmc_files_list += glob.glob(self.__perfmon_dir + "/" + self.__name + "/pmc_*_perf*.txt")
|
||||
|
||||
# Perfmon list filtering
|
||||
if self.__args.ipblocks != None:
|
||||
@@ -131,20 +136,20 @@ class OmniSoC_Base():
|
||||
def profiling_setup(self):
|
||||
"""Perform any SoC-specific setup prior to profiling.
|
||||
"""
|
||||
logging.debug("[profiling] perform SoC profiling setup for %s" % self.__soc)
|
||||
logging.debug("[profiling] perform SoC profiling setup for %s" % self.__name)
|
||||
|
||||
|
||||
@abstractmethod
|
||||
def post_profiling(self):
|
||||
"""Perform any SoC-specific post profiling activities.
|
||||
"""
|
||||
logging.debug("[profiling] perform SoC post processing for %s" % self.__soc)
|
||||
logging.debug("[profiling] perform SoC post processing for %s" % self.__name)
|
||||
|
||||
@abstractmethod
|
||||
def analysis_setup(self):
|
||||
"""Perform any SoC-specific setup prior to analysis.
|
||||
"""
|
||||
logging.debug("[analysis] perform SoC analysis setup for %s" % self.__soc)
|
||||
logging.debug("[analysis] perform SoC analysis setup for %s" % self.__name)
|
||||
|
||||
|
||||
@demarcate
|
||||
|
||||
@@ -30,9 +30,9 @@ from utils.utils import demarcate, error
|
||||
class gfx906_soc (OmniSoC_Base):
|
||||
def __init__(self,args):
|
||||
super().__init__(args)
|
||||
soc = "gfx906"
|
||||
self.set_soc(soc)
|
||||
self.set_perfmon_dir(os.path.join(str(config.omniperf_home), "omniperf_soc", "profile_configs", soc))
|
||||
self.set_soc_name("gfx906")
|
||||
self.set_perfmon_dir(os.path.join(str(config.omniperf_home), "omniperf_soc", "profile_configs", self.get_soc_name()))
|
||||
self.set_compatible_profilers(["rocprofv1", "rocscope"])
|
||||
# Per IP block max number of simultaneous counters. GFX IP Blocks
|
||||
self.set_perfmon_config(
|
||||
{
|
||||
@@ -72,7 +72,7 @@ class gfx906_soc (OmniSoC_Base):
|
||||
"""
|
||||
super().profiling_setup()
|
||||
if self.get_args().roof_only:
|
||||
error("%s does not support roofline analysis" % self.get_soc())
|
||||
error("%s does not support roofline analysis" % self.get_soc_name())
|
||||
# Perfmon filtering
|
||||
self.perfmon_filter()
|
||||
|
||||
|
||||
@@ -30,9 +30,9 @@ from utils.utils import demarcate, error
|
||||
class gfx908_soc (OmniSoC_Base):
|
||||
def __init__(self,args):
|
||||
super().__init__(args)
|
||||
soc = "gfx908"
|
||||
self.set_soc(soc)
|
||||
self.set_perfmon_dir(os.path.join(str(config.omniperf_home), "omniperf_soc", "profile_configs", soc))
|
||||
self.set_soc_name("gfx908")
|
||||
self.set_perfmon_dir(os.path.join(str(config.omniperf_home), "omniperf_soc", "profile_configs", self.get_soc_name()))
|
||||
self.set_compatible_profilers(["rocprofv1", "rocscope"])
|
||||
# Per IP block max number of simultaneous counters. GFX IP Blocks
|
||||
self.set_perfmon_config(
|
||||
{
|
||||
@@ -77,7 +77,7 @@ class gfx908_soc (OmniSoC_Base):
|
||||
"""
|
||||
super().profiling_setup()
|
||||
if self.get_args().roof_only:
|
||||
error("%s does not support roofline analysis" % self.get_soc())
|
||||
error("%s does not support roofline analysis" % self.get_soc_name())
|
||||
# Perfmon filtering
|
||||
self.perfmon_filter(self.get_args().roof_only)
|
||||
|
||||
|
||||
@@ -32,12 +32,12 @@ import logging
|
||||
class gfx90a_soc (OmniSoC_Base):
|
||||
def __init__(self,args):
|
||||
super().__init__(args)
|
||||
soc = "gfx90a"
|
||||
self.set_soc(soc)
|
||||
self.set_soc_name("gfx90a")
|
||||
if hasattr(self.get_args(), 'roof_only') and self.get_args().roof_only:
|
||||
self.set_perfmon_dir(os.path.join(str(config.omniperf_home), "omniperf_soc", "profile_configs", "roofline"))
|
||||
else:
|
||||
self.set_perfmon_dir(os.path.join(str(config.omniperf_home), "omniperf_soc", "profile_configs", soc))
|
||||
self.set_perfmon_dir(os.path.join(str(config.omniperf_home), "omniperf_soc", "profile_configs", self.get_soc_name()))
|
||||
self.set_compatible_profilers(["rocprofv1", "rocscope"])
|
||||
# Per IP block max number of simultaneous counters. GFX IP Blocks
|
||||
self.set_perfmon_config(
|
||||
{
|
||||
|
||||
مرجع در شماره جدید
Block a user