From f3e5db714ccd8e3a00a2f9fb5702807fa248b676 Mon Sep 17 00:00:00 2001 From: "Karl W. Schulz" Date: Wed, 6 Sep 2023 16:29:48 -0500 Subject: [PATCH] Addition of new files to demonstrate top-level data structure refactoring for 2.x version. Introduces an Omniperf class as the primary structure to organize work elements and allows for a simple main() which is highlighted in a omniperf2 example. Demonstrates desired logger functionality including a custom trace loglevel that can be used to provide more verbosity beyond the debug level. Also introduces three abstract base classes to organize flexibility for alternative implementations of key elements within omniperf: * underlying profiler tool (e.g. rocprof, rocscope, etc) * supported GPU architectures (SoC) * analysis environments (e.g. CLI, web-based, etc) Stub examples for child classes relevant to currently supported options within omniperf are included in separate files. Signed-off-by: Karl W. Schulz --- src/analysis_base.py | 44 +++++++++ src/analysis_cli.py | 42 +++++++++ src/analysis_webui.py | 42 +++++++++ src/omniperf2 | 47 ++++++++++ src/omniperf_base.py | 180 +++++++++++++++++++++++++++++++++++++ src/profiler_base.py | 50 +++++++++++ src/profiler_rocprof.py | 49 ++++++++++ src/profiler_rocprof_v2.py | 49 ++++++++++ src/profiler_rocscope.py | 47 ++++++++++ src/soc_base.py | 43 +++++++++ src/soc_gfx906.py | 45 ++++++++++ src/soc_gfx908.py | 45 ++++++++++ src/soc_gfx90a.py | 45 ++++++++++ src/utils/utils.py | 36 ++++++++ 14 files changed, 764 insertions(+) create mode 100644 src/analysis_base.py create mode 100644 src/analysis_cli.py create mode 100644 src/analysis_webui.py create mode 100755 src/omniperf2 create mode 100644 src/omniperf_base.py create mode 100644 src/profiler_base.py create mode 100644 src/profiler_rocprof.py create mode 100644 src/profiler_rocprof_v2.py create mode 100644 src/profiler_rocscope.py create mode 100644 src/soc_base.py create mode 100644 src/soc_gfx906.py create mode 100644 src/soc_gfx908.py create mode 100644 src/soc_gfx90a.py create mode 100644 src/utils/utils.py diff --git a/src/analysis_base.py b/src/analysis_base.py new file mode 100644 index 0000000000..d16b0eef62 --- /dev/null +++ b/src/analysis_base.py @@ -0,0 +1,44 @@ +##############################################################################bl +# MIT License +# +# Copyright (c) 2021 - 2023 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. +##############################################################################el + +from abc import ABC, abstractmethod + +class OmniAnalyze_Base(): + def __init__(self,args,options): + self.__args = args + self.__options = options + + # Required methods to be implemented by child classes + @abstractmethod + def pre_processing(self): + """Perform initialization prior to analysis. + """ + pass + + @abstractmethod + def run_analysis(self): + """Run analysis. + """ + pass + diff --git a/src/analysis_cli.py b/src/analysis_cli.py new file mode 100644 index 0000000000..e91bc14d1a --- /dev/null +++ b/src/analysis_cli.py @@ -0,0 +1,42 @@ +##############################################################################bl +# MIT License +# +# Copyright (c) 2021 - 2023 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. +##############################################################################el + +import logging +from analysis_base import OmniAnalyze_Base +from utils.utils import demarcate + +class cli_analysis(OmniAnalyze_Base): + + # Required child methods + @demarcate + def pre_processing(self): + """Perform any pre-processing steps prior to analysis. + """ + logging.debug("[analysis] prepping to do some analysis") + + @demarcate + def run_analysis(self): + """Run CLI analysis. + """ + logging.debug("[analysis] check out this wicked cli ascii art") diff --git a/src/analysis_webui.py b/src/analysis_webui.py new file mode 100644 index 0000000000..3d7724c19f --- /dev/null +++ b/src/analysis_webui.py @@ -0,0 +1,42 @@ +##############################################################################bl +# MIT License +# +# Copyright (c) 2021 - 2023 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. +##############################################################################el + +import logging +from analysis_base import OmniAnalyze_Base +from utils.utils import demarcate + +class webui_analysis(OmniAnalyze_Base): + + # Required child methods + @demarcate + def pre_processing(self): + """Perform any pre-processing steps prior to analysis. + """ + logging.debug("[analysis] prepping to do some analysis") + + @demarcate + def run_analysis(self): + """Run CLI analysis. + """ + logging.debug("[analysis] would you like to check out a groovy profiling web site?") diff --git a/src/omniperf2 b/src/omniperf2 new file mode 100755 index 0000000000..df694c488d --- /dev/null +++ b/src/omniperf2 @@ -0,0 +1,47 @@ +#!/usr/bin/env python3 + +##############################################################################bl +# MIT License +# +# Copyright (c) 2021 - 2023 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. +##############################################################################el + +from omniperf_base import Omniperf + +def main(): + + omniperf2 = Omniperf() + omniperf2.parseArgs() + + mode = omniperf2.get_mode() + + # major omniperf execution modes + if mode == "profile": + omniperf2.run_profiler() + elif mode == "database": + omniperf2.update_DB() + elif mode == "analyze": + omniperf2.run_analysis() + else: + omniperf2.error("Unsupported execution mode") + +if __name__ == "__main__": + main() diff --git a/src/omniperf_base.py b/src/omniperf_base.py new file mode 100644 index 0000000000..1d7196fc47 --- /dev/null +++ b/src/omniperf_base.py @@ -0,0 +1,180 @@ +##############################################################################bl +# MIT License +# +# Copyright (c) 2021 - 2023 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. +##############################################################################el + +import argparse +import logging +import sys +import os +from utils.utils import demarcate, trace_logger + + +class Omniperf: + def __init__(self): + self.__args = None + self.__profiler_mode = None + self.__soc_name = None + self.__soc = None + self.__options = {} + + self.setup_logging() + self.parseArgs() + + # hard-coding dummy examples (comment/uncomment below to instantiate different implementations) + self.__profiler_mode = "rocprof_v1" + self.__profiler_mode = "rocprof_v2" + #self.__profiler_mode = "rocscope" + + self.__analyze_mode = "cli" + self.__analyze_mode = "webui" + + # hard-code execution mode + self.__mode = "profile" + #self.__mode = "analyze" + + logging.info("Execution mode = %s" % self.__mode) + + + def setup_logging(self): + + # register a trace level logger + logging.TRACE = logging.DEBUG - 5 + logging.addLevelName(logging.TRACE, "TRACE") + setattr(logging, "TRACE", logging.TRACE) + setattr(logging, "trace", trace_logger) + + # demonstrate override of default loglevel via env variable + loglevel=logging.INFO + if "OMNIPERF_LOGLEVEL" in os.environ.keys(): + loglevel = os.environ['OMNIPERF_LOGLEVEL'] + if loglevel in {"DEBUG","debug"}: + loglevel = logging.DEBUG + elif loglevel in {"TRACE","trace"}: + loglevel = logging.TRACE + elif loglevel in {"INFO","info"}: + loglevel = logging.INFO + elif loglevel in {"ERROR","error"}: + loglevel = logging.ERROR + else: + print("Ignoring unsupported OMNIPERF_LOGLEVEL setting (%s)" % loglevel) + sys.exit(1) + + logging.basicConfig(format="%(message)s", level=loglevel, stream=sys.stdout) + + def get_mode(self): + return self.__mode + + def error(self,message): + logging.error("") + logging.error("[ERROR]: " + message) + logging.error("") + sys.exit(1) + + @demarcate + def detectSoC(self): + # hard-coded example + self.__soc_name = "gfx906" + self.__soc_name = "gfx908" + self.__soc_name = "gfx90a" + + # instantiate underlying SoC support class + if self.__soc_name == "gfx906": + from soc_gfx906 import gfx906_soc + self.__soc = gfx906_soc(self.__args) + elif self.__soc_name == "gfx908": + from soc_gfx908 import gfx908_soc + self.__soc = gfx908_soc(self.__args) + elif self.__soc_name == "gfx90a": + from soc_gfx90a import gfx90a_soc + self.__soc = gfx90a_soc(self.__args) + else: + logging.error("Unsupported SoC") + sys.exit(1) + + logging.info("SoC = %s" % self.__soc_name) + return + + def parseArgs(self): + self.__args = "some arguments" + return + + @demarcate + def run_profiler(self): + self.detectSoC() + + logging.info("Profiler choice = %s" % self.__profiler_mode) + + # instantiate desired profiler + if self.__profiler_mode == "rocprof_v1": + from profiler_rocprof import rocprof_v1_profiler + profiler = rocprof_v1_profiler(self.__soc, self.__args) + elif self.__profiler_mode == "rocprof_v2": + from profiler_rocprof_v2 import rocprof_v2_profiler + profiler = rocprof_v2_profiler(self.__soc, self.__args) + elif self.__profiler_mode == "rocscope": + from profiler_rocscope import rocscope_profiler + profiler = rocscope_profiler(self.__soc, self.__args) + else: + logging.error("Unsupported profiler") + sys.exit(1) + + #----------------------- + # run profiling workflow + #----------------------- + + self.__soc.profiling_setup() + profiler.pre_processing() + profiler.run_profiling() + profiler.post_processing() + + return + + @demarcate + def update_DB(self): + return + + @demarcate + def run_analysis(self): + + self.detectSoC() + + logging.info("Analysis mode choie = %s" % self.__analyze_mode) + + if self.__analyze_mode == "cli": + from analysis_cli import cli_analysis + analyzer = cli_analysis(self.__args,self.__options) + elif self.__analyze_mode == "webui": + from analysis_webui import webui_analysis + analyzer = webui_analysis(self.__args,self.__options) + else: + self.error("Unsupported anlaysis mode -> %s" % self.__analyze_mode) + + #----------------------- + # run analysis workflow + #----------------------- + + self.__soc.analysis_setup() + analyzer.pre_processing() + analyzer.run_analysis() + + return diff --git a/src/profiler_base.py b/src/profiler_base.py new file mode 100644 index 0000000000..ec69ffb1ba --- /dev/null +++ b/src/profiler_base.py @@ -0,0 +1,50 @@ +##############################################################################bl +# MIT License +# +# Copyright (c) 2021 - 2023 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. +##############################################################################el + +from abc import ABC, abstractmethod +# from utils2 import demarcate + +class OmniProfiler_Base(): + def __init__(self,soc,profiling_args): + self.__soc = soc + self.__args = profiling_args + + # Required methods to be implemented by child classes + @abstractmethod + def pre_processing(self): + """Perform any pre-processing steps prior to profiling. + """ + pass + + @abstractmethod + def run_profiling(self): + """Run profiling. + """ + pass + + @abstractmethod + def post_processing(self): + """Perform any post-processing steps prior to profiling. + """ + pass \ No newline at end of file diff --git a/src/profiler_rocprof.py b/src/profiler_rocprof.py new file mode 100644 index 0000000000..533373ad76 --- /dev/null +++ b/src/profiler_rocprof.py @@ -0,0 +1,49 @@ +##############################################################################bl +# MIT License +# +# Copyright (c) 2021 - 2023 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. +##############################################################################el + +import logging +from profiler_base import OmniProfiler_Base +from utils.utils import demarcate + +class rocprof_v1_profiler(OmniProfiler_Base): + + # Required child methods + @demarcate + def pre_processing(self): + """Perform any pre-processing steps prior to profiling. + """ + self.__profiler="rocprof" + logging.debug("[profiling] pre-processing using %s profiler (v1)" % self.__profiler) + + @demarcate + def run_profiling(self): + """Run profiling. + """ + logging.debug("[profiling] performing profiling using %s profiler (v1)" % self.__profiler) + + @demarcate + def post_processing(self): + """Perform any post-processing steps prior to profiling. + """ + logging.debug("[profiling] performing post-processing using %s profiler (v1)" % self.__profiler) diff --git a/src/profiler_rocprof_v2.py b/src/profiler_rocprof_v2.py new file mode 100644 index 0000000000..01e3167fb5 --- /dev/null +++ b/src/profiler_rocprof_v2.py @@ -0,0 +1,49 @@ +##############################################################################bl +# MIT License +# +# Copyright (c) 2021 - 2023 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. +##############################################################################el + +import logging +from profiler_base import OmniProfiler_Base +from utils.utils import demarcate + +class rocprof_v2_profiler(OmniProfiler_Base): + + # Required child methods + @demarcate + def pre_processing(self): + """Perform any pre-processing steps prior to profiling. + """ + self.__profiler="rocprof_v2" + logging.debug("[profiling] pre-processing using %s profiler (v1)" % self.__profiler) + + @demarcate + def run_profiling(self): + """Run profiling. + """ + logging.debug("[profiling] performing profiling using %s profiler (v1)" % self.__profiler) + + @demarcate + def post_processing(self): + """Perform any post-processing steps prior to profiling. + """ + logging.debug("[profiling] performing post-processing using %s profiler (v1)" % self.__profiler) diff --git a/src/profiler_rocscope.py b/src/profiler_rocscope.py new file mode 100644 index 0000000000..e4de27122f --- /dev/null +++ b/src/profiler_rocscope.py @@ -0,0 +1,47 @@ +##############################################################################bl +# MIT License +# +# Copyright (c) 2021 - 2023 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. +##############################################################################el + +import logging +from profiler_base import OmniProfiler_Base +from utils.utils import demarcate + +class rocscope_profiler(OmniProfiler_Base): + + # Required child methods + @demarcate + def pre_processing(self): + """Perform any pre-processing steps prior to profiling. + """ + self.__profiler="rocscope" + logging.debug("[profiling] pre-processing using %s profiler" % self.__profiler) + @demarcate + def run_profiling(self): + """Run profiling. + """ + logging.debug("[profiling] performing profiling using %s profiler" % self.__profiler) + @demarcate + def post_processing(self): + """Perform any post-processing steps prior to profiling. + """ + logging.debug("[profiling] performing post-processing using %s profiler" % self.__profiler) diff --git a/src/soc_base.py b/src/soc_base.py new file mode 100644 index 0000000000..778068074c --- /dev/null +++ b/src/soc_base.py @@ -0,0 +1,43 @@ +##############################################################################bl +# MIT License +# +# Copyright (c) 2021 - 2023 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. +##############################################################################el + +from abc import ABC, abstractmethod + +class OmniSoC_Base(): + def __init__(self,args): + self.__args = args + + # Required methods to be implemented by child classes + @abstractmethod + def profiling_setup(self): + """Perform any SoC-specific setup prior to profiling. + """ + pass + + @abstractmethod + def analysis_setup(self): + """Perform any SoC-specific setup prior to analysis. + """ + pass + diff --git a/src/soc_gfx906.py b/src/soc_gfx906.py new file mode 100644 index 0000000000..3505366a31 --- /dev/null +++ b/src/soc_gfx906.py @@ -0,0 +1,45 @@ +##############################################################################bl +# MIT License +# +# Copyright (c) 2021 - 2023 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. +##############################################################################el + +import logging +from soc_base import OmniSoC_Base +from utils.utils import demarcate + +class gfx906_soc (OmniSoC_Base): + def __init__(self,args): + self.__args = args + self.__soc = "gfx906" + + # Required methods to be implemented by child classes + @demarcate + def profiling_setup(self): + """Perform any SoC-specific setup prior to profiling. + """ + logging.debug("[profiling] perform profiling setup for %s" % self.__soc) + + @demarcate + def analysis_setup(self): + """Perform any SoC-specific setup prior to analysis. + """ + logging.debug("[analysis] perform analysis setup for %s" % self.__soc) \ No newline at end of file diff --git a/src/soc_gfx908.py b/src/soc_gfx908.py new file mode 100644 index 0000000000..30a91edfd3 --- /dev/null +++ b/src/soc_gfx908.py @@ -0,0 +1,45 @@ +##############################################################################bl +# MIT License +# +# Copyright (c) 2021 - 2023 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. +##############################################################################el + +import logging +from soc_base import OmniSoC_Base +from utils.utils import demarcate + +class gfx908_soc (OmniSoC_Base): + def __init__(self,args): + self.__args = args + self.__soc = "gfx908" + + # Required methods to be implemented by child classes + @demarcate + def profiling_setup(self): + """Perform any SoC-specific setup prior to profiling. + """ + logging.debug("[profiling] perform profiling setup for %s" % self.__soc) + + @demarcate + def analysis_setup(self): + """Perform any SoC-specific setup prior to analysis. + """ + logging.debug("[analysis] perform analysis setup for %s" % self.__soc) \ No newline at end of file diff --git a/src/soc_gfx90a.py b/src/soc_gfx90a.py new file mode 100644 index 0000000000..4f38364b79 --- /dev/null +++ b/src/soc_gfx90a.py @@ -0,0 +1,45 @@ +##############################################################################bl +# MIT License +# +# Copyright (c) 2021 - 2023 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. +##############################################################################el + +import logging +from soc_base import OmniSoC_Base +from utils.utils import demarcate + +class gfx90a_soc (OmniSoC_Base): + def __init__(self,args): + self.__args = args + self.__soc = "gfx90a" + + # Required methods to be implemented by child classes + @demarcate + def profiling_setup(self): + """Perform any SoC-specific setup prior to profiling. + """ + logging.debug("[profiling] perform profiling setup for %s" % self.__soc) + + @demarcate + def analysis_setup(self): + """Perform any SoC-specific setup prior to analysis. + """ + logging.debug("[analysis] perform analysis setup for %s" % self.__soc) \ No newline at end of file diff --git a/src/utils/utils.py b/src/utils/utils.py new file mode 100644 index 0000000000..9115c85511 --- /dev/null +++ b/src/utils/utils.py @@ -0,0 +1,36 @@ +##############################################################################bl +# MIT License +# +# Copyright (c) 2021 - 2023 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. +##############################################################################el + +import logging + +def demarcate(function): + def wrap_function(*args, **kwargs): + logging.trace("----- [entering function] -> %s()" % (function.__qualname__)) + result = function(*args, **kwargs) + logging.trace("----- [exiting function] -> %s()" % function.__qualname__) + return result + return wrap_function + +def trace_logger(message, *args, **kwargs): + logging.log(logging.TRACE, message, *args, **kwargs) \ No newline at end of file