Patch llvm-cxxfilt detection in atypical rocm installs

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


[ROCm/rocprofiler-compute commit: 7187218ed9]
This commit is contained in:
coleramos425
2023-08-22 11:25:06 -05:00
parent d0f1402814
commit 76dc96d87a
3 changed files with 47 additions and 22 deletions
@@ -37,6 +37,32 @@ SOC_LIST = ["mi50", "mi100", "mi200", "vega10"]
DISTRO_MAP = {"platform:el8": "rhel8", "15.3": "sle15sp3", "20.04": "ubuntu20_04"}
def resolve_rocprof(returnPath=False):
# ROCPROF INFO
if not "ROCPROF" in os.environ.keys():
rocprof_cmd = "rocprof"
else:
rocprof_cmd = os.environ["ROCPROF"]
rocprof_path = subprocess.run(
["which", rocprof_cmd], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL
)
if rocprof_path.returncode != 0:
print("\nError: Unable to resolve path to %s binary" % rocprof_cmd)
print(
"Please verify installation or set ROCPROF environment variable with full path."
)
sys.exit(1)
else:
# Resolve any sym links in file path
rocprof_path = os.path.realpath(rocprof_path.stdout.decode("utf-8").rstrip("\n"))
print("ROC Profiler: ", rocprof_path)
if returnPath:
return rocprof_path
else:
return rocprof_cmd
def getVersion():
# symantic version info
version = os.path.join(OMNIPERF_HOME.parent, "VERSION")
+3 -21
View File
@@ -43,6 +43,7 @@ from utils import remove_workload
from utils import csv_processor # Import workload
from omniperf_analyze.omniperf_analyze import roofline_only # Standalone roofline
from omniperf_analyze.omniperf_analyze import analyze # CLI analysis
from common import resolve_rocprof
from common import (
OMNIPERF_HOME,
@@ -102,26 +103,6 @@ def capture_subprocess_output(subprocess_args):
return (success, output)
def resolve_rocprof():
# ROCPROF INFO
global rocprof_cmd
if not "ROCPROF" in os.environ.keys():
rocprof_cmd = "rocprof"
else:
rocprof_cmd = os.environ["ROCPROF"]
rocprof_path = subprocess.run(
["which", rocprof_cmd], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL
)
if rocprof_path.returncode != 0:
print("\nError: Unable to resolve path to %s binary" % rocprof_cmd)
print(
"Please verify installation or set ROCPROF environment variable with full path."
)
sys.exit(1)
print("ROC Profiler: ", rocprof_path.stdout.decode("utf-8"))
def get_soc():
mspec = specs.get_machine_specs(0)
@@ -747,7 +728,8 @@ def main():
if args.mode == "profile":
Extractionlvl = args.kernelVerbose
print("Resolving rocprof")
resolve_rocprof()
global rocprof_cmd
rocprof_cmd = resolve_rocprof()
# Cannot access parent directories
if ".." in str(args.path):
throw_parse_error(
@@ -33,6 +33,7 @@ import getpass
from pymongo import MongoClient
from tqdm import tqdm
import glob
from common import resolve_rocprof
cache = dict()
@@ -40,6 +41,7 @@ supported_arch = {"gfx906": "mi50", "gfx908": "mi100", "gfx90a": "mi200"}
MAX_SERVER_SEL_DELAY = 5000 # 5 sec connection timeout
# Note: shortener is now dependent on a rocprof install with llvm
def kernel_name_shortener(workload_dir, level):
def shorten_file(df, level):
global cache
@@ -57,7 +59,7 @@ def kernel_name_shortener(workload_dir, level):
if original_name in cache:
continue
cmd = ["/opt/rocm/llvm/bin/llvm-cxxfilt", original_name]
cmd = [llvm_filt, original_name]
proc = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE
@@ -125,6 +127,19 @@ def kernel_name_shortener(workload_dir, level):
# Only shorten if valid shortening level
if level < 5:
returnPath = True
rocprof_path = resolve_rocprof(returnPath)
# Given expected rocprof dir format (ie '/opt/rocm-x.x.x/bin/rocprof') navigate to llvm in parent
rocm_dir = os.path.abspath(os.path.join(rocprof_path, os.pardir, os.pardir))
llvm_filt = os.path.join(rocm_dir, "llvm", "bin", "llvm-cxxfilt")
if not os.path.isfile(llvm_filt):
print(
"Error: Could not resolve llvm-cxxfilt in rocm install: {}".format(
llvm_filt
)
)
sys.exit(0)
for fpath in glob.glob(workload_dir + "/*.csv"):
try:
orig_df = pd.read_csv(
@@ -137,6 +152,8 @@ def kernel_name_shortener(workload_dir, level):
except pd.errors.EmptyDataError:
print("Skipping empty csv " + str(fpath))
print("KernelName shortening complete!")
# Verify target directory and setup connection
def parse(args, profileAndExport):