#!/usr/bin/env python@_VERSION@ # MIT License # # Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. # # 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: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # 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 # 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. from __future__ import absolute_import __author__ = "AMD Research" __copyright__ = "Copyright 2022, Advanced Micro Devices, Inc." __license__ = "MIT" __version__ = "@PROJECT_VERSION@" __maintainer__ = "AMD Research" __status__ = "Development" """ @file __main__.py Command line execution for profiler """ import os import sys import argparse import traceback PY3 = sys.version_info[0] == 3 # Python 3.x compatibility utils: execfile try: execfile except NameError: # Python 3.x doesn't have 'execfile' builtin import builtins exec_ = getattr(builtins, "exec") def execfile(filename, globals=None, locals=None): with open(filename, "rb") as f: exec_(compile(f.read(), filename, "exec"), globals, locals) def find_script(script_name): """Find the script. If the input is not a file, then $PATH will be searched. """ if os.path.isfile(script_name): return script_name path = os.getenv("PATH", os.defpath).split(os.pathsep) for dir in path: if dir == "": continue fn = os.path.join(dir, script_name) if os.path.isfile(fn): return fn sys.stderr.write("Could not find script %s\n" % script_name) raise SystemExit(1) def parse_args(args=None): """Parse the arguments""" if args is None: args = sys.argv[1:] from .libpyomnitrace.profiler import config as _profiler_config def str2bool(v): if isinstance(v, bool): return v if v.lower() in ("yes", "true", "t", "y", "1"): return True elif v.lower() in ("no", "false", "f", "n", "0"): return False else: raise argparse.ArgumentTypeError("Boolean value expected.") parser = argparse.ArgumentParser( "omnitrace", add_help=True, epilog="usage: {} -m omnitrace --