diff --git a/CMakeLists.txt b/CMakeLists.txt index ff2df00a4a..724d37f0d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -292,6 +292,18 @@ install( # set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "omniperf") set(CPACK_RESOURCE_FILE_LICENSE # "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") +# License header update(s) +add_custom_target( + license + COMMAND + ${PROJECT_SOURCE_DIR}/utils/update_license.py --source ${PROJECT_SOURCE_DIR}/src + --license ${PROJECT_SOURCE_DIR}/LICENSE --extension '.py' + COMMAND + ${PROJECT_SOURCE_DIR}/utils/update_license.py --source ${PROJECT_SOURCE_DIR} + --license ${PROJECT_SOURCE_DIR}/LICENSE --file + "src/omniperf,cmake/Dockerfile,cmake/rocm_install.sh,docker/docker-entrypoint.sh,src/omniperf_analyze/convertor/mongodb/convert" + ) + # Source tarball set(CPACK_SOURCE_GENERATOR "TGZ") set(CPACK_SOURCE_PACKAGE_FILE_NAME ${CMAKE_PROJECT_NAME}-${FULL_VERSION_STRING}) diff --git a/LICENSE b/LICENSE index 5477049050..057656b358 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. +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 diff --git a/cmake/Dockerfile b/cmake/Dockerfile index f95e18d4d0..766be0894f 100644 --- a/cmake/Dockerfile +++ b/cmake/Dockerfile @@ -1,5 +1,7 @@ -################################################################################ -# Copyright (c) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. +##############################################################################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 @@ -8,17 +10,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +##############################################################################el FROM ubuntu:20.04 diff --git a/cmake/rocm_install.sh b/cmake/rocm_install.sh index 8ac34caad5..57d2331779 100755 --- a/cmake/rocm_install.sh +++ b/cmake/rocm_install.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash -################################################################################ -# Copyright (c) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. +##############################################################################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 @@ -10,17 +12,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +##############################################################################el declare -a rocm_versions=("4.3.1" "4.5.2" "5.0.2" "5.1.3" "5.2.3") wget https://repo.radeon.com/amdgpu-install/22.10/ubuntu/focal/amdgpu-install_22.10.50100-1_all.deb @@ -29,4 +31,4 @@ for rocm_version in ${rocm_versions[@]}; do echo "deb [arch=amd64] https://repo.radeon.com/rocm/apt/$rocm_version ubuntu main" | tee /etc/apt/sources.list.d/rocm.list apt update amdgpu-install -y --usecase=rocm --rocmrelease=$rocm_version --no-dkms -done \ No newline at end of file +done diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index 52b3e3914a..6a2923f6f3 100755 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -1,7 +1,9 @@ #!/bin/bash -################################################################################ -# Copyright (c) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. +##############################################################################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 @@ -10,17 +12,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +##############################################################################el pushd /var/lib/grafana/plugins/omniperfData_plugin npm run server & diff --git a/src/common.py b/src/common.py index 8268608b4a..70cdcd8239 100644 --- a/src/common.py +++ b/src/common.py @@ -1,5 +1,7 @@ -################################################################################ -# Copyright (c) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. +##############################################################################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 @@ -8,17 +10,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +##############################################################################el import os import sys diff --git a/src/omniperf b/src/omniperf index b0a6a3af9d..554e59a6e2 100755 --- a/src/omniperf +++ b/src/omniperf @@ -1,7 +1,9 @@ #!/usr/bin/env python3 -################################################################################ -# Copyright (c) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. +##############################################################################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 @@ -10,17 +12,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +##############################################################################el import sys import os @@ -37,7 +39,7 @@ from utils import specs from utils.perfagg import perfmon_filter, pmc_filter from utils import remove_workload from utils import csv_converter # Import workload -from omniperf_analyze.omniperf_analyze import roofline_only # Standalone roofline +from omniperf_analyze.omniperf_analyze import roofline_only # Standalone roofline from omniperf_analyze.omniperf_analyze import analyze # CLI analysis from common import ( @@ -53,10 +55,8 @@ from common import getVersion # Helper Functions ################################################ def run_subprocess(cmd): - subprocess.run( - cmd, - check=True - ) + subprocess.run(cmd, check=True) + def resolve_rocprof(): # ROCPROF INFO @@ -125,7 +125,9 @@ def replace_timestamps(workload_dir): df_pmc_perf["EndNs"] = df_stamps["EndNs"] df_pmc_perf.to_csv(workload_dir + "/pmc_perf.csv", index=False) else: - warnings.warn("WARNING: Incomplete profiling data detected. Unable to update timestamps.") + warnings.warn( + "WARNING: Incomplete profiling data detected. Unable to update timestamps." + ) def gen_sysinfo(workload_name, workload_dir, ip_blocks, app_cmd, skip_roof): @@ -150,7 +152,7 @@ def gen_sysinfo(workload_name, workload_dir, ip_blocks, app_cmd, skip_roof): timestamp = now.strftime("%c") + " (" + local_tzname + ")" # host info param = [workload_name] - param += ["\"" + app_cmd + "\""] + param += ['"' + app_cmd + '"'] param += [ mspec.hostname, mspec.cpu, @@ -257,6 +259,7 @@ def roof_setup(args, my_parser): else: characterize_app(args.path, args.remaining, args.verbose) + def detect_roofline(): mspec = specs.get_machine_specs(0) rocm_ver = mspec.rocmversion[:1] @@ -291,6 +294,7 @@ def detect_roofline(): target_binary = {"rocm_ver": rocm_ver, "distro": distro} return target_binary + def mibench(args): print("No roofline data found. Generating...") @@ -324,6 +328,7 @@ def mibench(args): ] ) + def characterize_app(path, cmd, verbose): target = get_soc() workload_dir = path @@ -355,27 +360,38 @@ def characterize_app(path, cmd, verbose): # Update pmc_perf.csv timestamps replace_timestamps(workload_dir) + ################################################ # Profiling Helpers ################################################ + def run_rocscope(args, fname): # profile the app if args.use_rocscope == True: - result = subprocess.run(["which", "rocscope"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) + result = subprocess.run( + ["which", "rocscope"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL + ) if result.returncode == 0: - rs_cmd = [result.stdout.decode('ascii').strip(), - "metrics", - "-p", args.path, - "-n", args.name, - "-t", fname, - "--"] + rs_cmd = [ + result.stdout.decode("ascii").strip(), + "metrics", + "-p", + args.path, + "-n", + args.name, + "-t", + fname, + "--", + ] for i in args.remaining.split(): rs_cmd.append(i) print(rs_cmd) - result = run_subprocess(rs_cmd) #, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + result = run_subprocess( + rs_cmd + ) # , stdout=subprocess.PIPE, stderr=subprocess.PIPE) if result.returncode != 0: - print(result.stderr.decode('ascii')) + print(result.stderr.decode("ascii")) sys.exit(1) @@ -408,7 +424,7 @@ def omniperf_profile(args, VER): parse.print_help(sys.stderr) sys.exit(1) - #Verify valid name + # Verify valid name if args.name.find(".") != -1 or args.name.find("-") != -1: raise ValueError("'-' and '.' are not permited in workload name", args.name) @@ -428,59 +444,75 @@ def omniperf_profile(args, VER): # Set up directories workload_dir = args.path + "/" + args.name + "/" + args.target perfmon_dir = str(OMNIPERF_HOME) + "/perfmon_pub" - + # Perfmon filtering perfmon_filter(workload_dir, perfmon_dir, args) if not args.lucky == None and args.lucky == True: print("You're feeling lucky - only profiling top N kernels") - #look for whether workload_dir exists - create if not + # look for whether workload_dir exists - create if not try: - os.makedirs(workload_dir, exist_ok = True) + os.makedirs(workload_dir, exist_ok=True) except Exception as e: print("Unable to create workload directory: ", workload_dir) print(e) sys.exit(1) - result = subprocess.run(["which", "rocscope"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) + result = subprocess.run( + ["which", "rocscope"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL + ) if result.returncode == 0: - rs_cmd = [result.stdout.decode('ascii').strip(), - "top10", - "-p", args.path, - "-n", args.name, - "--"] + rs_cmd = [ + result.stdout.decode("ascii").strip(), + "top10", + "-p", + args.path, + "-n", + args.name, + "--", + ] for i in args.remaining.split(): rs_cmd.append(i) print(rs_cmd) - result = run_subprocess(rs_cmd) #, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + result = run_subprocess( + rs_cmd + ) # , stdout=subprocess.PIPE, stderr=subprocess.PIPE) if result.returncode != 0: - print(result.stderr.decode('ascii')) + print(result.stderr.decode("ascii")) else: print("rocscope must be in the PATH") sys.exit(1) elif not args.summaries == None and args.summaries == True: print("creating kernel summaries") - #look for whether workload_dir exists - create if not + # look for whether workload_dir exists - create if not try: - os.makedirs(workload_dir, exist_ok = True) + os.makedirs(workload_dir, exist_ok=True) except Exception as e: print("Unable to create workload directory: ", workload_dir) print(e) sys.exit(1) - result = subprocess.run(["which", "rocscope"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) + result = subprocess.run( + ["which", "rocscope"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL + ) if result.returncode == 0: - rs_cmd = [result.stdout.decode('ascii').strip(), - "summary", - "-p", args.path, - "-n", args.name, - "--"] + rs_cmd = [ + result.stdout.decode("ascii").strip(), + "summary", + "-p", + args.path, + "-n", + args.name, + "--", + ] for i in args.remaining.split(): rs_cmd.append(i) print(rs_cmd) - result = run_subprocess(rs_cmd) #, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + result = run_subprocess( + rs_cmd + ) # , stdout=subprocess.PIPE, stderr=subprocess.PIPE) if result.returncode != 0: - print(result.stderr.decode('ascii')) + print(result.stderr.decode("ascii")) else: print("rocscope must be in the PATH") sys.exit(1) @@ -514,8 +546,6 @@ def omniperf_profile(args, VER): run_rocscope(args, fname) else: run_prof(fname, workload_dir, perfmon_dir, args.remaining, args.verbose) - - # run again with timestamps run_subprocess( diff --git a/src/omniperf_analyze/convertor/mongodb/convert b/src/omniperf_analyze/convertor/mongodb/convert index a5676dc317..dc8a33e920 100755 --- a/src/omniperf_analyze/convertor/mongodb/convert +++ b/src/omniperf_analyze/convertor/mongodb/convert @@ -1,7 +1,9 @@ #!/usr/bin/env python3 -################################################################################ -# Copyright (C) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. +##############################################################################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 @@ -10,17 +12,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +##############################################################################el import ast import astunparse diff --git a/src/omniperf_analyze/convertor/sql/convertor.py b/src/omniperf_analyze/convertor/sql/convertor.py index dba816948a..c6b36b5f97 100644 --- a/src/omniperf_analyze/convertor/sql/convertor.py +++ b/src/omniperf_analyze/convertor/sql/convertor.py @@ -1,7 +1,9 @@ #!/usr/bin/env python3 -################################################################################ -# Copyright (c) 2018 Advanced Micro Devices, Inc. All rights reserved. +##############################################################################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 @@ -10,17 +12,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +##############################################################################el import re import sys diff --git a/src/omniperf_analyze/convertor/sql/convertor2.py b/src/omniperf_analyze/convertor/sql/convertor2.py index df4e2e5135..cc2b89e6d7 100644 --- a/src/omniperf_analyze/convertor/sql/convertor2.py +++ b/src/omniperf_analyze/convertor/sql/convertor2.py @@ -1,7 +1,9 @@ #!/usr/bin/env python3 -################################################################################ -# Copyright (c) 2018 Advanced Micro Devices, Inc. All rights reserved. +################################################################################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 @@ -10,17 +12,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +################################################################################el import re import sys diff --git a/src/omniperf_analyze/omniperf_analyze.py b/src/omniperf_analyze/omniperf_analyze.py index 5c090bc121..368e5c50c5 100644 --- a/src/omniperf_analyze/omniperf_analyze.py +++ b/src/omniperf_analyze/omniperf_analyze.py @@ -1,7 +1,9 @@ #!/usr/bin/env python3 -################################################################################ -# Copyright (c) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. +##############################################################################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 @@ -10,17 +12,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +##############################################################################el """ Quick run: diff --git a/src/omniperf_analyze/tests/unit/ast_parser_tester.py b/src/omniperf_analyze/tests/unit/ast_parser_tester.py index a04832e48a..f728743c2d 100644 --- a/src/omniperf_analyze/tests/unit/ast_parser_tester.py +++ b/src/omniperf_analyze/tests/unit/ast_parser_tester.py @@ -1,7 +1,9 @@ #!/usr/bin/env python3 -################################################################################ -# Copyright (c) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. +##############################################################################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 @@ -10,17 +12,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +##############################################################################el import ast import astunparse diff --git a/src/omniperf_analyze/utils/file_io.py b/src/omniperf_analyze/utils/file_io.py index 04539feb44..05219dbcca 100644 --- a/src/omniperf_analyze/utils/file_io.py +++ b/src/omniperf_analyze/utils/file_io.py @@ -1,5 +1,7 @@ -################################################################################ -# Copyright (c) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. +##############################################################################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 @@ -8,17 +10,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +##############################################################################el import os import pandas as pd diff --git a/src/omniperf_analyze/utils/gui.py b/src/omniperf_analyze/utils/gui.py index 98bc38ebcc..eb083bfe9d 100644 --- a/src/omniperf_analyze/utils/gui.py +++ b/src/omniperf_analyze/utils/gui.py @@ -1,5 +1,7 @@ -################################################################################ -# Copyright (c) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. +##############################################################################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 @@ -8,17 +10,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +##############################################################################el from selectors import EpollSelector import sys diff --git a/src/omniperf_analyze/utils/gui_components/header.py b/src/omniperf_analyze/utils/gui_components/header.py index ddf665d799..3dcf34be69 100644 --- a/src/omniperf_analyze/utils/gui_components/header.py +++ b/src/omniperf_analyze/utils/gui_components/header.py @@ -1,5 +1,7 @@ -################################################################################ -# Copyright (c) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. +##############################################################################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 @@ -8,17 +10,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +##############################################################################el from dash import html, dcc import dash_bootstrap_components as dbc diff --git a/src/omniperf_analyze/utils/gui_components/memchart.py b/src/omniperf_analyze/utils/gui_components/memchart.py index 8616ca9e30..f8af87d547 100644 --- a/src/omniperf_analyze/utils/gui_components/memchart.py +++ b/src/omniperf_analyze/utils/gui_components/memchart.py @@ -1,5 +1,7 @@ -################################################################################ -# Copyright (c) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. +##############################################################################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 @@ -8,17 +10,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +##############################################################################el import sys diff --git a/src/omniperf_analyze/utils/gui_components/roofline.py b/src/omniperf_analyze/utils/gui_components/roofline.py index 89e19af132..8fb6e36a74 100644 --- a/src/omniperf_analyze/utils/gui_components/roofline.py +++ b/src/omniperf_analyze/utils/gui_components/roofline.py @@ -1,5 +1,7 @@ -################################################################################ -# Copyright (c) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. +##############################################################################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 @@ -8,17 +10,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +##############################################################################el from omniperf_analyze.utils import roofline_calc diff --git a/src/omniperf_analyze/utils/parser.py b/src/omniperf_analyze/utils/parser.py index f4f91f4f5a..7d6dcab493 100644 --- a/src/omniperf_analyze/utils/parser.py +++ b/src/omniperf_analyze/utils/parser.py @@ -1,5 +1,7 @@ -################################################################################ -# Copyright (c) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. +##############################################################################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 @@ -8,17 +10,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +##############################################################################el import ast import sys diff --git a/src/omniperf_analyze/utils/roofline_calc.py b/src/omniperf_analyze/utils/roofline_calc.py index 7a324c3efd..987b6694de 100644 --- a/src/omniperf_analyze/utils/roofline_calc.py +++ b/src/omniperf_analyze/utils/roofline_calc.py @@ -1,5 +1,7 @@ -################################################################################ -# Copyright (c) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. +##############################################################################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 @@ -8,17 +10,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +##############################################################################el import sys diff --git a/src/omniperf_analyze/utils/schema.py b/src/omniperf_analyze/utils/schema.py index 3d77eee0ac..13d930916d 100644 --- a/src/omniperf_analyze/utils/schema.py +++ b/src/omniperf_analyze/utils/schema.py @@ -1,5 +1,7 @@ -################################################################################ -# Copyright (c) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. +##############################################################################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 @@ -8,17 +10,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +##############################################################################el # # Define all common data storage classes, diff --git a/src/omniperf_analyze/utils/tty.py b/src/omniperf_analyze/utils/tty.py index 1afe8e08e8..0900fd689f 100644 --- a/src/omniperf_analyze/utils/tty.py +++ b/src/omniperf_analyze/utils/tty.py @@ -1,5 +1,7 @@ -################################################################################ -# Copyright (c) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. +##############################################################################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 @@ -8,17 +10,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +##############################################################################el import pandas as pd from tabulate import tabulate diff --git a/src/parser.py b/src/parser.py index d384be8797..b305b60187 100644 --- a/src/parser.py +++ b/src/parser.py @@ -1,5 +1,7 @@ -################################################################################ -# Copyright (c) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. +##############################################################################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 @@ -8,17 +10,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +##############################################################################el import os import argparse diff --git a/src/utils/csv_converter.py b/src/utils/csv_converter.py index b1e536c12f..b178439aca 100644 --- a/src/utils/csv_converter.py +++ b/src/utils/csv_converter.py @@ -1,5 +1,7 @@ -################################################################################ -# Copyright (c) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. +##############################################################################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 @@ -8,17 +10,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +##############################################################################el import argparse import collections diff --git a/src/utils/gfx_perfmon_builder.py b/src/utils/gfx_perfmon_builder.py index 566449c3d5..c5a77908ac 100755 --- a/src/utils/gfx_perfmon_builder.py +++ b/src/utils/gfx_perfmon_builder.py @@ -1,394 +1,396 @@ -################################################################################ -# Copyright (c) 2021 - 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 PyQt5.QtWidgets import ( - QMainWindow, - QApplication, - QTreeView, - QTableWidget, - QTableWidgetItem, -) -from PyQt5.QtWidgets import ( - QHBoxLayout, - QWidget, - QAction, - QFileDialog, - QAbstractItemView, - qApp, -) -from PyQt5.QtGui import QStandardItemModel, QStandardItem -from lxml import html -import sys - - -# class view(QWidget): -class mainWindow(QMainWindow): - def __init__(self): - super(QMainWindow, self).__init__() - - ############################################################################### - # SOC Parameters - ############################################################################## - - # Per IP block max number of simulutaneous counters - # GFX IP Blocks - self.perfmon_config = { - "SQ": 8, - "TA": 2, - "TD": 2, - "TCP": 4, - "TCC": 4, - "CPC": 2, - "CPF": 2, - "SPI": 2, - "GRBM": 2, - "GDS": 4, - } - - # GFX Architectures - self.soc_arch_list = ["gfx906", "gfx908", "gfx90a"] - - ############################################################################### - # Window layout Design - ############################################################################## - - self.block_list = [] - self.nodes_dict = {} # list of QStandardItem - - self.tree = QTreeView(self) - self.table = QTableWidget() - - # Tree setup - self.tree.header().setDefaultSectionSize(180) - self.model = QStandardItemModel() - self.model.setHorizontalHeaderLabels(["Metric", "Block", "Event", "Definition"]) - - self.tree.setModel(self.model) - # self.importData(data) - self.tree.setEditTriggers(QAbstractItemView.NoEditTriggers) - - # Set up click processing - self.tree.clicked.connect(self.pmc_select) - # self.tree.expandAll() - - # Table setup - tableHeader = list(self.perfmon_config.keys()) - self.table.setColumnCount(len(tableHeader)) - self.table.setHorizontalHeaderLabels(tableHeader) - self.table.setEditTriggers(QAbstractItemView.NoEditTriggers) - self.table.showGrid() - - self.setWindowTitle("GFX Perfmon Builder") - # layout: lhs: metrics; rhs: selected perfmon - layout = QHBoxLayout(self) - layout.addWidget(self.tree) - layout.addWidget(self.table) - - widget = QWidget() - widget.setLayout(layout) - self.setCentralWidget(widget) - - # Add Status - self.statusBar() - - ############################################################################### - # Window Menu Design - ############################################################################## - - # Setup file menu - menuBar = self.menuBar() - menuBar.setNativeMenuBar(False) - - openAction = QAction("&Open", self) - openAction.setShortcut("Ctrl+O") - openAction.setStatusTip("Open GFX Metrics file") - openAction.triggered.connect(self.openGFXDialog) - - saveAction = QAction("&Save", self) - saveAction.setShortcut("Ctrl+S") - saveAction.setStatusTip("Save to PMC file") - saveAction.triggered.connect(self.exportGFXDialog) - - exitAction = QAction("&Exit", self) - exitAction.setShortcut("Ctrl+Q") - exitAction.setStatusTip("Exit") - exitAction.triggered.connect(self.close) - - # Create new action - fileMenu = menuBar.addMenu("&File") - fileMenu.addActions([openAction, saveAction]) - fileMenu.addSeparator() - fileMenu.addActions([exitAction]) - - def openGFXDialog(self): - options = QFileDialog.Options() - options |= QFileDialog.DontUseNativeDialog - fileName, _ = QFileDialog.getOpenFileName( - self, "Open GFX Metrics", "", "XML Files (*.xml)", "XML(*.xml)" - ) - - # Parse the xml - if fileName: - xmlparsed = html.parse(fileName) - self.importData(xmlparsed) - - def exportGFXDialog(self): - options = QFileDialog.Options() - options |= QFileDialog.DontUseNativeDialog - fileName, _ = QFileDialog.getSaveFileName( - self, "Export PMC Counters", "", "Text File (*.txt)", "Text File(*.txt)" - ) - - # Parse the xml - if fileName: - self.exportPMCCounters(fileName) - - def exportPMCCounters(self, fileName): - f = open(fileName, "w") - - total_IP_blocks = len(list(self.perfmon_config.keys())) - for row in range(self.table.rowCount()): - pmc_str = "pmc: " - for col in range(total_IP_blocks): - cell = self.table.item(row, col) - - if cell: - pmc_str = pmc_str + " ".join(cell.text().split("\n")) + " " - - f.write(pmc_str + "\n") - - # Add standard lines - f.write("\n\n") - f.write("gpu: \n") - f.write("dispatch: \n") - f.write("kernel: \n") - - f.close() - - return - - def pmc_metric_selected(self, metric_name, col): - # check if the metric already exists - metric_selected = False - - for row in range(self.table.rowCount()): - entry = self.table.item(row, col) - if entry: - pmc_list = entry.text().split(sep="\n") - if metric_name in pmc_list: - metric_selected = True - break - - return metric_selected - - def pmc_remove_metric(self, metric_name, IP_block): - # Remove the metric to pmc table, if it is selected - - # Map SQC to SQ, since they share the same Perfmon block - if IP_block == "SQC": - IP_block = "SQ" - - # not action if it is for a ghost IP! - if not IP_block in list(self.perfmon_config.keys()): - return - - # This is the column we need to add/remove perfmon counters - col = list(self.perfmon_config.keys()).index(IP_block) - - if not self.pmc_metric_selected(metric_name, col): - return - - pmc_list = [] - for row in range(self.table.rowCount()): - entry = self.table.item(row, col) - - if entry: - pmc_list = pmc_list + entry.text().split(sep="\n") - # clear the cell, we will re-allocate the pmc - - self.table.takeItem(row, col) - - # allowed PMC counters per batch - max_pmc_num = self.perfmon_config[IP_block] - - # remote this metric and re-segment the list and refill all rows in this column - pmc_list.remove(metric_name) - - # We are empty now, do nothing - if len(pmc_list) == 0: - return - - for row in range((len(pmc_list) + max_pmc_num - 1) // max_pmc_num): - start_index = row * max_pmc_num - pmc_str = "\n".join(pmc_list[start_index : start_index + max_pmc_num]) - self.table.setItem(row, col, QTableWidgetItem(pmc_str)) - - # Remove last row, if empty - last_row = self.table.rowCount() - 1 - empty_row = True - total_cols = len(list(self.perfmon_config.keys())) - for cindex in range(total_cols): - x = self.table.item(last_row, cindex) - - if x and x.text(): - empty_row = False - break - - if empty_row: - self.table.removeRow(last_row) - - def pmc_add_metric(self, metric_name, IP_block): - # Add the metric to pmc table, if not there yet - - # Map SQC to SQ, since they share the same Perfmon block - if IP_block == "SQC": - IP_block = "SQ" - - if not IP_block in list(self.perfmon_config.keys()): - return - - # This is the column we need to add/remove perfmon counters - col = list(self.perfmon_config.keys()).index(IP_block) - - # check if the metric already exists - if self.pmc_metric_selected(metric_name, col): - return - - # metric is not bucket yet, add it! - if self.table.rowCount() == 0: - # starting from scratch! - self.table.insertRow(0) - self.table.setItem(0, col, QTableWidgetItem(metric_name)) - return - - # find the row to insert - for row in range(self.table.rowCount()): - entry = self.table.item(row, col) - if not entry: - # print("search insert pos, row:", row, ", cell empty") - break - - if len(entry.text().split(sep="\n")) < self.perfmon_config[IP_block]: - # print("found") - break - - entry = self.table.item(row, col) - if not entry: - # put it into the empty cell - self.table.setItem(row, col, QTableWidgetItem(metric_name)) - return - - pmc_list = entry.text().split(sep="\n") - - if len(pmc_list) < self.perfmon_config[IP_block]: - # we still have hit per-IP HW counters limit, add it to the last row - pmc_list.append(metric_name) - pmc_str = "\n".join(pmc_list) - self.table.setItem(row, col, QTableWidgetItem(pmc_str)) - self.table.resizeRowsToContents() - else: - # Start a new row - row = row + 1 - self.table.insertRow(row) - self.table.setItem(row, col, QTableWidgetItem(metric_name)) - - def pmc_select(self, item): - metric_name = item.data() - if ( - not metric_name in self.nodes_dict - or not self.nodes_dict[metric_name].isCheckable() - ): - return - - # only proper metrics check/uncheck is processed here. - IP_block = item.data().split(sep="_")[0] - - if self.nodes_dict[metric_name].checkState() == 0: - # unselect the metric in the table if it is currently selected - self.pmc_remove_metric(metric_name, IP_block) - - elif self.nodes_dict[metric_name].checkState() == 2: - self.pmc_add_metric(metric_name, IP_block) - - # Function to save populate treeview with a dictionary - def importData(self, xmlparsed, root=None): - self.model.setRowCount(0) - if root is None: - root = self.model.invisibleRootItem() - - for x in xmlparsed.getiterator(): - # Add SoC node to Root - if x.tag in self.soc_arch_list: - parent = root - parent.appendRow([QStandardItem(x.tag)]) - self.nodes_dict[x.tag] = parent.child(parent.rowCount() - 1) - - # check all metrics in an SoC family - if x.tag == "metric" and x.getparent().tag in self.soc_arch_list: - # New IP block (e.g., SQ), detected, create a new hierarchy for the block - if not x.attrib["block"] in self.block_list: - self.block_list.append(x.attrib["block"]) - parent = self.nodes_dict[x.getparent().tag] # the SoC node - parent.appendRow( - [ - QStandardItem(x.attrib["block"]), - QStandardItem(""), - QStandardItem(""), - QStandardItem(""), - ] - ) - - # record the tree node for the block - self.nodes_dict[x.attrib["block"]] = parent.child( - parent.rowCount() - 1 - ) - - # Add metric node to the Block node - parent = self.nodes_dict[x.attrib["block"]] - metric_name = QStandardItem(x.attrib["name"]) - metric_name.setCheckable(True) - parent.appendRow( - [ - metric_name, - QStandardItem(x.attrib["block"]), - QStandardItem(x.attrib["event"]), - QStandardItem(x.attrib["descr"]), - ] - ) - - self.nodes_dict[x.attrib["name"]] = parent.child(parent.rowCount() - 1) - - -if __name__ == "__main__": - app = QApplication(sys.argv) - app.setStyle("Fusion") - - # populate the view with GFX metrics.xml - window = mainWindow() - - # show the view - window.setGeometry(300, 100, 600, 300) - # view.setWindowTitle('GFX Perfmon Counters') - window.show() - - # start the application - sys.exit(app.exec_()) +##############################################################################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 PyQt5.QtWidgets import ( + QMainWindow, + QApplication, + QTreeView, + QTableWidget, + QTableWidgetItem, +) +from PyQt5.QtWidgets import ( + QHBoxLayout, + QWidget, + QAction, + QFileDialog, + QAbstractItemView, + qApp, +) +from PyQt5.QtGui import QStandardItemModel, QStandardItem +from lxml import html +import sys + + +# class view(QWidget): +class mainWindow(QMainWindow): + def __init__(self): + super(QMainWindow, self).__init__() + + ############################################################################### + # SOC Parameters + ############################################################################## + + # Per IP block max number of simulutaneous counters + # GFX IP Blocks + self.perfmon_config = { + "SQ": 8, + "TA": 2, + "TD": 2, + "TCP": 4, + "TCC": 4, + "CPC": 2, + "CPF": 2, + "SPI": 2, + "GRBM": 2, + "GDS": 4, + } + + # GFX Architectures + self.soc_arch_list = ["gfx906", "gfx908", "gfx90a"] + + ############################################################################### + # Window layout Design + ############################################################################## + + self.block_list = [] + self.nodes_dict = {} # list of QStandardItem + + self.tree = QTreeView(self) + self.table = QTableWidget() + + # Tree setup + self.tree.header().setDefaultSectionSize(180) + self.model = QStandardItemModel() + self.model.setHorizontalHeaderLabels(["Metric", "Block", "Event", "Definition"]) + + self.tree.setModel(self.model) + # self.importData(data) + self.tree.setEditTriggers(QAbstractItemView.NoEditTriggers) + + # Set up click processing + self.tree.clicked.connect(self.pmc_select) + # self.tree.expandAll() + + # Table setup + tableHeader = list(self.perfmon_config.keys()) + self.table.setColumnCount(len(tableHeader)) + self.table.setHorizontalHeaderLabels(tableHeader) + self.table.setEditTriggers(QAbstractItemView.NoEditTriggers) + self.table.showGrid() + + self.setWindowTitle("GFX Perfmon Builder") + # layout: lhs: metrics; rhs: selected perfmon + layout = QHBoxLayout(self) + layout.addWidget(self.tree) + layout.addWidget(self.table) + + widget = QWidget() + widget.setLayout(layout) + self.setCentralWidget(widget) + + # Add Status + self.statusBar() + + ############################################################################### + # Window Menu Design + ############################################################################## + + # Setup file menu + menuBar = self.menuBar() + menuBar.setNativeMenuBar(False) + + openAction = QAction("&Open", self) + openAction.setShortcut("Ctrl+O") + openAction.setStatusTip("Open GFX Metrics file") + openAction.triggered.connect(self.openGFXDialog) + + saveAction = QAction("&Save", self) + saveAction.setShortcut("Ctrl+S") + saveAction.setStatusTip("Save to PMC file") + saveAction.triggered.connect(self.exportGFXDialog) + + exitAction = QAction("&Exit", self) + exitAction.setShortcut("Ctrl+Q") + exitAction.setStatusTip("Exit") + exitAction.triggered.connect(self.close) + + # Create new action + fileMenu = menuBar.addMenu("&File") + fileMenu.addActions([openAction, saveAction]) + fileMenu.addSeparator() + fileMenu.addActions([exitAction]) + + def openGFXDialog(self): + options = QFileDialog.Options() + options |= QFileDialog.DontUseNativeDialog + fileName, _ = QFileDialog.getOpenFileName( + self, "Open GFX Metrics", "", "XML Files (*.xml)", "XML(*.xml)" + ) + + # Parse the xml + if fileName: + xmlparsed = html.parse(fileName) + self.importData(xmlparsed) + + def exportGFXDialog(self): + options = QFileDialog.Options() + options |= QFileDialog.DontUseNativeDialog + fileName, _ = QFileDialog.getSaveFileName( + self, "Export PMC Counters", "", "Text File (*.txt)", "Text File(*.txt)" + ) + + # Parse the xml + if fileName: + self.exportPMCCounters(fileName) + + def exportPMCCounters(self, fileName): + f = open(fileName, "w") + + total_IP_blocks = len(list(self.perfmon_config.keys())) + for row in range(self.table.rowCount()): + pmc_str = "pmc: " + for col in range(total_IP_blocks): + cell = self.table.item(row, col) + + if cell: + pmc_str = pmc_str + " ".join(cell.text().split("\n")) + " " + + f.write(pmc_str + "\n") + + # Add standard lines + f.write("\n\n") + f.write("gpu: \n") + f.write("dispatch: \n") + f.write("kernel: \n") + + f.close() + + return + + def pmc_metric_selected(self, metric_name, col): + # check if the metric already exists + metric_selected = False + + for row in range(self.table.rowCount()): + entry = self.table.item(row, col) + if entry: + pmc_list = entry.text().split(sep="\n") + if metric_name in pmc_list: + metric_selected = True + break + + return metric_selected + + def pmc_remove_metric(self, metric_name, IP_block): + # Remove the metric to pmc table, if it is selected + + # Map SQC to SQ, since they share the same Perfmon block + if IP_block == "SQC": + IP_block = "SQ" + + # not action if it is for a ghost IP! + if not IP_block in list(self.perfmon_config.keys()): + return + + # This is the column we need to add/remove perfmon counters + col = list(self.perfmon_config.keys()).index(IP_block) + + if not self.pmc_metric_selected(metric_name, col): + return + + pmc_list = [] + for row in range(self.table.rowCount()): + entry = self.table.item(row, col) + + if entry: + pmc_list = pmc_list + entry.text().split(sep="\n") + # clear the cell, we will re-allocate the pmc + + self.table.takeItem(row, col) + + # allowed PMC counters per batch + max_pmc_num = self.perfmon_config[IP_block] + + # remote this metric and re-segment the list and refill all rows in this column + pmc_list.remove(metric_name) + + # We are empty now, do nothing + if len(pmc_list) == 0: + return + + for row in range((len(pmc_list) + max_pmc_num - 1) // max_pmc_num): + start_index = row * max_pmc_num + pmc_str = "\n".join(pmc_list[start_index : start_index + max_pmc_num]) + self.table.setItem(row, col, QTableWidgetItem(pmc_str)) + + # Remove last row, if empty + last_row = self.table.rowCount() - 1 + empty_row = True + total_cols = len(list(self.perfmon_config.keys())) + for cindex in range(total_cols): + x = self.table.item(last_row, cindex) + + if x and x.text(): + empty_row = False + break + + if empty_row: + self.table.removeRow(last_row) + + def pmc_add_metric(self, metric_name, IP_block): + # Add the metric to pmc table, if not there yet + + # Map SQC to SQ, since they share the same Perfmon block + if IP_block == "SQC": + IP_block = "SQ" + + if not IP_block in list(self.perfmon_config.keys()): + return + + # This is the column we need to add/remove perfmon counters + col = list(self.perfmon_config.keys()).index(IP_block) + + # check if the metric already exists + if self.pmc_metric_selected(metric_name, col): + return + + # metric is not bucket yet, add it! + if self.table.rowCount() == 0: + # starting from scratch! + self.table.insertRow(0) + self.table.setItem(0, col, QTableWidgetItem(metric_name)) + return + + # find the row to insert + for row in range(self.table.rowCount()): + entry = self.table.item(row, col) + if not entry: + # print("search insert pos, row:", row, ", cell empty") + break + + if len(entry.text().split(sep="\n")) < self.perfmon_config[IP_block]: + # print("found") + break + + entry = self.table.item(row, col) + if not entry: + # put it into the empty cell + self.table.setItem(row, col, QTableWidgetItem(metric_name)) + return + + pmc_list = entry.text().split(sep="\n") + + if len(pmc_list) < self.perfmon_config[IP_block]: + # we still have hit per-IP HW counters limit, add it to the last row + pmc_list.append(metric_name) + pmc_str = "\n".join(pmc_list) + self.table.setItem(row, col, QTableWidgetItem(pmc_str)) + self.table.resizeRowsToContents() + else: + # Start a new row + row = row + 1 + self.table.insertRow(row) + self.table.setItem(row, col, QTableWidgetItem(metric_name)) + + def pmc_select(self, item): + metric_name = item.data() + if ( + not metric_name in self.nodes_dict + or not self.nodes_dict[metric_name].isCheckable() + ): + return + + # only proper metrics check/uncheck is processed here. + IP_block = item.data().split(sep="_")[0] + + if self.nodes_dict[metric_name].checkState() == 0: + # unselect the metric in the table if it is currently selected + self.pmc_remove_metric(metric_name, IP_block) + + elif self.nodes_dict[metric_name].checkState() == 2: + self.pmc_add_metric(metric_name, IP_block) + + # Function to save populate treeview with a dictionary + def importData(self, xmlparsed, root=None): + self.model.setRowCount(0) + if root is None: + root = self.model.invisibleRootItem() + + for x in xmlparsed.getiterator(): + # Add SoC node to Root + if x.tag in self.soc_arch_list: + parent = root + parent.appendRow([QStandardItem(x.tag)]) + self.nodes_dict[x.tag] = parent.child(parent.rowCount() - 1) + + # check all metrics in an SoC family + if x.tag == "metric" and x.getparent().tag in self.soc_arch_list: + # New IP block (e.g., SQ), detected, create a new hierarchy for the block + if not x.attrib["block"] in self.block_list: + self.block_list.append(x.attrib["block"]) + parent = self.nodes_dict[x.getparent().tag] # the SoC node + parent.appendRow( + [ + QStandardItem(x.attrib["block"]), + QStandardItem(""), + QStandardItem(""), + QStandardItem(""), + ] + ) + + # record the tree node for the block + self.nodes_dict[x.attrib["block"]] = parent.child( + parent.rowCount() - 1 + ) + + # Add metric node to the Block node + parent = self.nodes_dict[x.attrib["block"]] + metric_name = QStandardItem(x.attrib["name"]) + metric_name.setCheckable(True) + parent.appendRow( + [ + metric_name, + QStandardItem(x.attrib["block"]), + QStandardItem(x.attrib["event"]), + QStandardItem(x.attrib["descr"]), + ] + ) + + self.nodes_dict[x.attrib["name"]] = parent.child(parent.rowCount() - 1) + + +if __name__ == "__main__": + app = QApplication(sys.argv) + app.setStyle("Fusion") + + # populate the view with GFX metrics.xml + window = mainWindow() + + # show the view + window.setGeometry(300, 100, 600, 300) + # view.setWindowTitle('GFX Perfmon Counters') + window.show() + + # start the application + sys.exit(app.exec_()) diff --git a/src/utils/perfagg.py b/src/utils/perfagg.py index f40f242699..0606b4dc4b 100755 --- a/src/utils/perfagg.py +++ b/src/utils/perfagg.py @@ -1,5 +1,7 @@ -################################################################################ -# Copyright (c) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. +##############################################################################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 @@ -8,17 +10,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +##############################################################################el import sys, os, pathlib, shutil, subprocess, argparse, glob, re import numpy as np diff --git a/src/utils/remove_workload.py b/src/utils/remove_workload.py index 11cb5df256..02ba864f59 100755 --- a/src/utils/remove_workload.py +++ b/src/utils/remove_workload.py @@ -1,7 +1,9 @@ #!/usr/bin/env python3 -################################################################################ -# Copyright (c) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. +##############################################################################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 @@ -10,17 +12,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +##############################################################################el import argparse import getpass diff --git a/src/utils/resources.py b/src/utils/resources.py index fce329d13d..4986394811 100644 --- a/src/utils/resources.py +++ b/src/utils/resources.py @@ -1,5 +1,7 @@ -################################################################################ -# Copyright (c) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. +##############################################################################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 @@ -8,17 +10,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +##############################################################################el import pathlib import sys diff --git a/src/utils/specs.py b/src/utils/specs.py index 4c95194406..a040fcbf68 100644 --- a/src/utils/specs.py +++ b/src/utils/specs.py @@ -1,7 +1,9 @@ """Get host/gpu specs.""" -################################################################################ -# Copyright (c) 2021 - 2022 Advanced Micro Devices, Inc. All rights reserved. +##############################################################################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 @@ -10,17 +12,17 @@ # 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 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 +# 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. -################################################################################ +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +##############################################################################el import os import re diff --git a/utils/update_license.py b/utils/update_license.py new file mode 100755 index 0000000000..353c4a7eba --- /dev/null +++ b/utils/update_license.py @@ -0,0 +1,130 @@ +#!/usr/bin/env python3 +# ------------------------------------------------------------------------------- +# Support script for license header management. +# ------------------------------------------------------------------------------- + +import argparse +import logging +import glob +import os +import sys +import re +import filecmp +import shutil + +begDelim = "######bl$" +endDelim = "######el$" +maxHeaderLines = 200 + + +def cacheLicenseFile(infile, comment="#"): + if not os.path.isfile(infile): + logging.error("Unable to access license file - >%s" % infile) + sys.exit(1) + + license = "" + with open(infile, "r") as file_in: + for line in file_in: + license += comment + if line.strip() != "": + license += " " + license += line + return license + + +parser = argparse.ArgumentParser() +parser.add_argument("--license", required=True, help="License File") +parser.add_argument("--source", required=True, help="Source directory") +parser.add_argument("--dryrun", help="enable dryrun mode", action="store_true") + +group = parser.add_mutually_exclusive_group(required=True) +group.add_argument("--extension", help="file extension to parse") +group.add_argument("--files", help="specific file(s) to parse") + +logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.INFO) + +args = parser.parse_args() + +srcDir = args.source +fileExtension = None +specificFiles = None +if args.extension: + fileExtension = args.extension +if args.files: + specificFiles = args.files.split(",") + +print("") +logging.info("Source directory = %s" % srcDir) +if fileExtension: + logging.info("File extension = %s" % fileExtension) +if specificFiles: + logging.info("Specific files = %s" % specificFiles) + +# cache license file +license = cacheLicenseFile(args.license) + +# Scan files in provided source directory... +for filename in glob.iglob(srcDir + "/**", recursive=True): + # skip directories + if os.path.isdir(filename): + continue + + # File matching options: + + # (1) filter non-matching extensions + if fileExtension: + if not filename.endswith(fileExtension): + continue + + # or, (2) filter for specific filename + if specificFiles: + found = False + for file in specificFiles: + fullPath = os.path.join(srcDir, file) + if fullPath == filename: + found = True + break + if not found: + continue + + logging.debug("Examining %s for license..." % filename) + + # Update license header contents if delimiters are found + with open(filename, "r") as file_in: + baseName = os.path.basename(filename) + dirName = os.path.dirname(filename) + tmpFile = dirName + "/." + baseName + ".tmp" + + file_out = open(tmpFile, "w") + for line in file_in: + if re.search(begDelim, line): + logging.debug("Found beginning delimiter") + file_out.write(line) + file_out.write(license) + + foundEnd = False + + for i in range(maxHeaderLines): + line = file_in.readline() + if re.search(endDelim, line): + logging.debug("Found ending delimiter") + file_out.write(line) + foundEnd = True + break + if not foundEnd: + logging.error("Unable to find end of delimited header") + sys.exit(1) + + else: + file_out.write(line) + + file_out.close() + + # Check if file changed and update + if not filecmp.cmp(filename, tmpFile, shallow=False): + logging.info("%s changed" % filename) + shutil.copystat(filename, tmpFile) + if not args.dryrun: + os.rename(tmpFile, filename) + else: + os.unlink(tmpFile)