Files
rocm-systems/src/omniperf
T

107 lines
3.4 KiB
Python
Raw Normal View History

2022-11-04 14:49:36 -05:00
#!/usr/bin/env python3
2023-02-13 09:26:12 -06:00
##############################################################################bl
# MIT License
2023-02-13 14:50:24 -06:00
#
2024-01-24 17:11:39 -06:00
# Copyright (c) 2021 - 2024 Advanced Micro Devices, Inc. All Rights Reserved.
2023-02-13 14:50:24 -06:00
#
2022-11-04 14:49:36 -05:00
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
2023-02-13 14:50:24 -06:00
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
2023-02-13 14:50:24 -06:00
#
2022-11-04 14:49:36 -05:00
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2022-11-04 14:49:36 -05:00
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
2023-02-13 09:26:12 -06:00
##############################################################################el
2022-11-04 14:49:36 -05:00
import logging
import os
import sys
import pkg_resources
from pathlib import Path
from pkg_resources import DistributionNotFound, VersionConflict
from distutils import text_file
try:
from omniperf_base import Omniperf
from utils.utils import console_error
except:
pass
def verify_deps():
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):
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
if error:
print("")
print(
"Please verify all of the python dependencies called out in the requirements file"
)
print("are installed locally prior to running omniperf.")
print("")
print("See: %s" % checkFile)
sys.exit(1)
return
2022-11-04 14:49:36 -05:00
def main():
# verify required python dependencies
verify_deps()
2023-10-31 15:11:17 -05:00
omniperf = Omniperf()
2023-10-31 15:11:17 -05:00
mode = omniperf.get_mode()
2023-10-31 15:11:17 -05:00
# major omniperf execution modes
if mode == "profile":
omniperf.run_profiler()
elif mode == "database":
2024-01-30 10:43:30 -06:00
omniperf.update_db()
2023-10-31 15:11:17 -05:00
elif mode == "analyze":
omniperf.run_analysis()
else:
2024-01-30 17:25:16 -06:00
console_error("Unsupported execution mode")
2022-11-04 14:49:36 -05:00
sys.exit(0)
2022-11-04 14:49:36 -05:00
if __name__ == "__main__":
main()