All logging should use call new functions

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


[ROCm/rocprofiler-compute commit: 5bf38a4fed]
此提交包含在:
colramos-amd
2024-01-30 17:25:16 -06:00
提交者 Karl W. Schulz
父節點 cfdf288cba
當前提交 a1371462ba
共有 26 個檔案被更改,包括 474 行新增337 行删除
+48 -11
查看文件
@@ -23,11 +23,11 @@
##############################################################################el
import argparse
import logging
import sys
import os
from pathlib import Path
import shutil
<<<<<<< HEAD
from utils.specs import generate_machine_specs
from utils.utils import (
demarcate,
@@ -38,6 +38,11 @@ from utils.utils import (
error,
get_submodules,
)
=======
from utils.specs import get_machine_specs
from utils.utils import demarcate, get_version, get_version_display, detect_rocprof, get_submodules, console_log, console_error
from utils.logger import setup_logging
>>>>>>> All logging should use call new functions
from argparser import omniarg_parser
import config
import pandas as pd
@@ -70,7 +75,7 @@ class Omniperf:
self.__supported_archs = SUPPORTED_ARCHS
self.__mspec: MachineSpecs = None # to be initalized in load_soc_specs()
self.setup_logging()
setup_logging()
self.set_version()
self.parse_args()
@@ -80,9 +85,15 @@ class Omniperf:
self.detect_profiler()
elif self.__mode == "analyze":
self.detect_analyze()
<<<<<<< HEAD
logging.info("Execution mode = %s" % self.__mode)
=======
console_log("Execution mode = %s" % self.__mode)
>>>>>>> All logging should use call new functions
def print_graphic(self):
"""Log program name as ascii art to terminal."""
ascii_art = r"""
@@ -92,6 +103,7 @@ class Omniperf:
| |_| | | | | | | | | | | |_) | __/ | | _|
\___/|_| |_| |_|_| |_|_| .__/ \___|_| |_|
|_|
<<<<<<< HEAD
"""
logging.info(ascii_art)
@@ -119,6 +131,10 @@ class Omniperf:
sys.exit(1)
logging.basicConfig(format="%(message)s", level=loglevel, stream=sys.stdout)
=======
'''
print(ascii_art)
>>>>>>> All logging should use call new functions
def get_mode(self):
return self.__mode
@@ -138,8 +154,7 @@ class Omniperf:
or self.__args.use_rocscope
):
if not shutil.which("rocscope"):
logging.error("Rocscope must be in PATH")
sys.exit(1)
console_error("Rocscope must be in PATH")
else:
self.__profiler_mode = "rocscope"
else:
@@ -149,10 +164,15 @@ class Omniperf:
elif str(rocprof_cmd).endswith("rocprofv2"):
self.__profiler_mode = "rocprofv2"
else:
<<<<<<< HEAD
error(
"Incompatible profiler: %s. Supported profilers include: %s"
% (rocprof_cmd, get_submodules("omniperf_profile"))
)
=======
console_error("Incompatible profiler: %s. Supported profilers include: %s" % (rocprof_cmd, get_submodules('omniperf_profile')))
>>>>>>> All logging should use call new functions
return
@@ -175,12 +195,27 @@ class Omniperf:
# NB: This checker is a bit redundent. We already check this in specs module
if arch not in self.__supported_archs.keys():
<<<<<<< HEAD
error("%s is an unsupported SoC" % arch)
soc_module = importlib.import_module("omniperf_soc.soc_" + arch)
soc_class = getattr(soc_module, arch + "_soc")
self.__soc[arch] = soc_class(self.__args, self.__mspec)
return
=======
console_error("%s is an unsupported SoC" % arch)
else:
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)
console_log("SoC = %s" % self.__soc_name)
return arch
>>>>>>> All logging should use call new functions
@demarcate
def parse_args(self):
@@ -202,8 +237,7 @@ class Omniperf:
print(generate_machine_specs(self.__args))
sys.exit(0)
parser.print_help(sys.stderr)
error("Omniperf requires a valid mode.")
console_error("Omniperf requires you pass a valid mode. Detected None.")
return
@demarcate
@@ -217,7 +251,9 @@ class Omniperf:
self.__args.path, self.__args.name, self.__mspec.gpu_model
)
logging.info("Profiler choice = %s" % self.__profiler_mode)
console_log(
"Profiler choice = %s" % self.__profiler_mode
)
# instantiate desired profiler
if self.__profiler_mode == "rocprofv1":
@@ -239,8 +275,7 @@ class Omniperf:
self.__args, self.__profiler_mode, self.__soc[self.__mspec.gpu_arch]
)
else:
logging.error("Unsupported profiler")
sys.exit(1)
console_error("Unsupported profiler")
# -----------------------
# run profiling workflow
@@ -275,7 +310,9 @@ class Omniperf:
def run_analysis(self):
self.print_graphic()
logging.info("Analysis mode = %s" % self.__analyze_mode)
console_log(
"Analysis mode = %s" % self.__analyze_mode
)
if self.__analyze_mode == "cli":
from omniperf_analyze.analysis_cli import cli_analysis
@@ -286,7 +323,7 @@ class Omniperf:
analyzer = webui_analysis(self.__args, self.__supported_archs)
else:
error("Unsupported anlaysis mode -> %s" % self.__analyze_mode)
console_error("Unsupported anlaysis mode -> %s" % self.__analyze_mode)
# -----------------------
# run analysis workflow