Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfixes for override arch option and deprecated python module #370

Merged
merged 7 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 55 additions & 23 deletions src/omniperf
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
import logging
import os
import sys
import pkg_resources
from pip._internal.req import parse_requirements
from pathlib import Path
from pkg_resources import DistributionNotFound, VersionConflict
from distutils import text_file
from importlib import import_module, metadata
import re

try:
from omniperf_base import Omniperf
Expand All @@ -39,35 +39,67 @@ except:
pass


def verify_deps():
def verify_deps_version(localVer, desiredVer, operator):
"""Check package version strings with simple operators used in companion requirements.txt file"""
if operator == "==":
return localVer == desiredVer
elif operator == ">=":
return localVer >= desiredVer
elif operator == "<=":
return localVer <= desiredVer
elif operator == ">":
return localVer > desiredVer
elif operator == "<":
return localVer < desiredVer
else:
return True


def verify_deps():
"""Utility to read library dependencies from requirements.txt and endeavor to load them within current execution environment.
Used in top-level omniperf to provide error messages if necessary dependencies are not available. """
bindir = Path(__file__).resolve().parent
depsLocation = ["requirements.txt", "../requirements.txt"]

for location in depsLocation:
checkFile = os.path.join(bindir, location)
if os.path.exists(checkFile):
with open(checkFile, "r") as file_in:
dependencies = file_in.read().splitlines()

dependencies = text_file.TextFile(checkFile).readlines()
error = False

try:
pkg_resources.require(dependencies)
except DistributionNotFound as e:
print(
"[ERROR] The '%s' distribution was not found in the current execution environment."
% e.req.key
)
error = True

except VersionConflict as e:
print(
"[ERROR] the '%s' distribution does not meet version requirements to use omniperf."
% e.req.key
)
print(" --> version installed :", e.dist)
print(" --> version required :", e.req)
error = True
version_pattern = r"^([^=<>]+)([=<>]+)(.*)$"

for dependency in dependencies:
desiredVersion = None
match = re.match(version_pattern, dependency)
if match:
package = match.group(1)
operator = match.group(2) or None
desiredVersion = match.group(3) or None
else:
package = dependency
try:
localVersion = metadata.distribution(package).version
except metadata.PackageNotFoundError:
error = True
print(
"[ERROR] The '%s' package was not found in the current execution environment."
% dependency
)

# check version requirement
if not error:
if desiredVersion:
if not verify_deps_version(
localVersion, desiredVersion, operator
):
print(
"[ERROR] the '%s' distribution does not meet version requirements to use omniperf."
% dependency
)
print(" --> version installed :", localVersion)
error = True

if error:
print("")
Expand Down
18 changes: 15 additions & 3 deletions src/omniperf_soc/soc_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ def get_profiler_options(self):
# assume no SoC specific options and return empty list by default
return []

def check_arch_override(self):
if "OMNIPERF_ARCH_OVERRIDE" in os.environ.keys():
return os.environ["OMNIPERF_ARCH_OVERRIDE"]
return ""

@demarcate
def populate_mspec(self):
from utils.specs import search, run, total_sqc, total_xcds
Expand Down Expand Up @@ -179,13 +184,20 @@ def populate_mspec(self):
0
][0]
if self._mspec.gpu_arch == "gfx942":
if "MI300A" in "\n".join(self._mspec._rocminfo):
if (
"MI300A" in "\n".join(self._mspec._rocminfo)
or "MI300A" in self.check_arch_override()
):
self._mspec.gpu_model = "MI300A_A1"
elif "MI300X" in "\n".join(self._mspec._rocminfo):
elif (
"MI300X" in "\n".join(self._mspec._rocminfo)
or "MI300X" in self.check_arch_override()
):
self._mspec.gpu_model = "MI300X_A1"
else:
console_error(
"Cannot parse MI300 details from rocminfo. Please verify output."
"Cannot parse MI300 details from rocminfo. Please verify output or set the arch using (e.g.,) "
'export OMNIPERF_ARCH_OVERRIDE="MI300A"'
)

self._mspec.num_xcd = str(
Expand Down
2 changes: 2 additions & 0 deletions src/utils/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ def to_max(*args):
def to_avg(a):
if str(type(a)) == "<class 'NoneType'>":
return np.nan
elif np.isnan(a).all():
return np.nan
elif a.empty:
return np.nan
elif isinstance(a, pd.core.series.Series):
Expand Down
16 changes: 12 additions & 4 deletions src/utils/tty.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,21 @@ def show_all(args, runs, archConfigs, output):
elif header not in comparable_columns:
if (
type == "raw_csv_table"
and table_config["source"] == "pmc_kernel_top.csv"
and (
table_config["source"] == "pmc_kernel_top.csv"
or table_config["source"] == "pmc_dispatch_info.csv"
)
and header == "Kernel_Name"
):
# NB: the width of kernel name might depend on the header of the table.
adjusted_name = base_df["Kernel_Name"].apply(
lambda x: string_multiple_lines(x, 40, 3)
)
if table_config["source"] == "pmc_kernel_top.csv":
adjusted_name = base_df["Kernel_Name"].apply(
lambda x: string_multiple_lines(x, 40, 3)
)
else:
adjusted_name = base_df["Kernel_Name"].apply(
lambda x: string_multiple_lines(x, 80, 4)
)
df = pd.concat([df, adjusted_name], axis=1)
elif type == "raw_csv_table" and header == "Info":
for run, data in runs.items():
Expand Down