diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..422c0f7 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,6 @@ +# Default owner for everything +* @mwootton + +# Python +/rocpd_python/ @mwootton +/tools/ @mwootton diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..71971fc --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,23 @@ +name: Bug Report +description: Something isn't working as expected. +body: + - type: textarea + id: what-happened + attributes: + label: What happened? + validations: + required: true + + - type: textarea + id: expected + attributes: + label: What did you expect? + validations: + required: true + + - type: textarea + id: repro + attributes: + label: Steps to reproduce + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..0086358 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: true diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..e389971 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,9 @@ +name: Feature Request +description: Suggest something new or different. +body: + - type: textarea + id: suggestion + attributes: + label: What do you want, and why? + validations: + required: true diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..5454c77 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,5 @@ +## Purpose + +## What does this PR do? + +## How was it tested? diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..fb8f5fb --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,22 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install dependencies + run: sudo apt-get install -y sqlite3 libsqlite3-dev libfmt-dev nlohmann-json3-dev libzstd-dev xxd + + - name: Build + run: make diff --git a/.gitignore b/.gitignore index c78bc69..936b8d3 100644 --- a/.gitignore +++ b/.gitignore @@ -213,7 +213,14 @@ tags # rpd stuff *.rpd +*.rpd-shm +*.rpd-wal *.json *.o +# data / output files +*.csv +*.dif +*.html + # End of https://www.gitignore.io/api/vim,python,django diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..41e1b71 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,27 @@ +# Contributing to rocmProfileData + +Contributions are welcome. This document covers how to build, test, and submit changes. + +## Building + +Dependencies are installed and the project is built via the provided script: + +```sh +sudo bash install.sh +``` + +This installs system dependencies and builds all components. Components that require ROCm hardware (such as `rpd_tracer`) will build partially and skip GPU-dependent features if ROCm is not present. + +## Submitting changes + +- Open a GitHub issue before starting significant work, so we can discuss the approach. +- Fork the repository and submit a pull request against `main`. +- Keep commits focused; one logical change per PR where practical. + +## Code review + +All pull requests require review from a code owner before merging. Reviewers will be assigned automatically via CODEOWNERS. + +## Reporting issues + +Use the GitHub issue tracker. Include steps to reproduce, observed behaviour, and expected behaviour. diff --git a/LICENSE.txt b/LICENSE similarity index 91% rename from LICENSE.txt rename to LICENSE index e32ad88..4d43ac8 100644 --- a/LICENSE.txt +++ b/LICENSE @@ -1,22 +1,21 @@ -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. - +MIT License + +Copyright (C) Advanced Micro Devices, Inc. + +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. diff --git a/README.md b/README.md index df6909f..7458eaf 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Rocm Profile Data +[![CI](https://github.com/ROCm/rocmProfileData/actions/workflows/ci.yml/badge.svg)](https://github.com/ROCm/rocmProfileData/actions/workflows/ci.yml) + -------------------------------------------------------------------------------- ROCm Profile Data is a collection of tools for tracing and analyzing gpu related activity on a system. This is represented by a timeline of api calls, app log messages, async gpu operations, and related interactions/dependencies. diff --git a/remote/Remote.cpp b/remote/Remote.cpp index 828c2dd..6d7bc94 100644 --- a/remote/Remote.cpp +++ b/remote/Remote.cpp @@ -1,24 +1,5 @@ -/********************************************************************************* -* Copyright (c) 2021 - 2024 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #include #include #include diff --git a/rocpd/models.py b/rocpd/models.py index a637e98..f9a5ab7 100644 --- a/rocpd/models.py +++ b/rocpd/models.py @@ -1,25 +1,6 @@ -################################################################################ -# 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. -################################################################################ +# Copyright (C) Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT from django.db import models diff --git a/rocpd/util/autogradKernelList.py b/rocpd/util/autogradKernelList.py index ef153b6..db52d45 100644 --- a/rocpd/util/autogradKernelList.py +++ b/rocpd/util/autogradKernelList.py @@ -1,189 +1,170 @@ -################################################################################ -# 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. -################################################################################ - -# -# Format sqlite trace data as json for chrome:tracing -# - -import sys -import os -import sqlite3 -import argparse - - -def generateKernelList(outfile, args): - - connection = sqlite3.connect(args.input_rpd) - - outfile.write(""" - - - - - - - -

Kernels by Autograd Operator

-

- - - - - - - - - - - - - - """) - - - last_labels = ["",""] - group_active = [False, False] - - for row in connection.execute('select "0" as ordinal, count(*) as count, autogradName, "" as kernelName, "" as Sizes, sum(calls) as calls, sum(avg_gpu) as avg_gpu, sum(total_gpu) as total_gpu from autogradKernel group by autogradName UNION ALL select "1" as ordinal, count(*) as count, autogradName, kernelName, "" as Sizes, sum(calls) as calls, sum(avg_gpu) as avg_gpu, sum(total_gpu) as total_gpu from autogradKernel group by autogradName, kernelName UNION ALL select "2" as ordinal, count(*) as count, autogradName, kernelName, Sizes, sum(calls) as calls, sum(avg_gpu) as avg_gpu, sum(total_gpu) as total_gpu from autogradKernel group by autogradName, kernelName, sizes order by autogradName, kernelName, ordinal'): - - depth = int(row[0]) - count = int(row[1]) - labels = [row[2], row[3]] - - #outfile.write(f' {depth} {count} {labels[0][:80]} {labels[1][:80]}') - #doit = "now"; - - # Detect start of groupings - #for i in [0,1]: - # if depth == i and count > 1: - # outfile.write("") - # group_active[i] = True - - # Detect end of groupings - for i in [1,0]: - changed = False - for j in range(i + 1): - if labels[i] != last_labels[i]: - changed = True - if changed and group_active[i]: - outfile.write("") - group_active[i] = False - - # Detect start of groupings - for i in [0,1]: - if depth == i and count > 1: - outfile.write("") - group_active[i] = True - - # Don't outfile.write out single leaf branches - if depth < 2 and count < 2: - continue - - # supress labels for duplicates - for i in [0,1]: - if group_active[i] and labels[i] == last_labels[i]: - labels[i] = "" - else: - last_labels[i] = labels[i] - - class_string = ">') - - #clean up groupings - for i in [1,0]: - if group_active[i]: - outfile.write("") - group_active[i] = False - - outfile.write(""" -
- Autograd OperatorKernel NameSizesTotal CallAverage GPUTotal GPU
{labels[0]}{labels[1][:60]}{row[4]}{row[5]}{row[6]}{row[7]}
- - - - """) - - outfile.write("\n") - connection.close() - - -if __name__ == "__main__": - - parser = argparse.ArgumentParser(description='Format autograd kernel usage as html') - parser.add_argument('input_rpd', type=str, help="input rpd db") - parser.add_argument('output_html', type=str, help="html output") - args = parser.parse_args() - - outfile = open(args.output_html, 'w', encoding="utf-8") - - generateKernelList(outfile, args) - - outfile.close() +# Copyright (C) Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT + +# +# Format sqlite trace data as json for chrome:tracing +# + +import sys +import os +import sqlite3 +import argparse + + +def generateKernelList(outfile, args): + + connection = sqlite3.connect(args.input_rpd) + + outfile.write(""" + + + + + + + +

Kernels by Autograd Operator

+

+ + + + + + + + + + + + + + """) + + + last_labels = ["",""] + group_active = [False, False] + + for row in connection.execute('select "0" as ordinal, count(*) as count, autogradName, "" as kernelName, "" as Sizes, sum(calls) as calls, sum(avg_gpu) as avg_gpu, sum(total_gpu) as total_gpu from autogradKernel group by autogradName UNION ALL select "1" as ordinal, count(*) as count, autogradName, kernelName, "" as Sizes, sum(calls) as calls, sum(avg_gpu) as avg_gpu, sum(total_gpu) as total_gpu from autogradKernel group by autogradName, kernelName UNION ALL select "2" as ordinal, count(*) as count, autogradName, kernelName, Sizes, sum(calls) as calls, sum(avg_gpu) as avg_gpu, sum(total_gpu) as total_gpu from autogradKernel group by autogradName, kernelName, sizes order by autogradName, kernelName, ordinal'): + + depth = int(row[0]) + count = int(row[1]) + labels = [row[2], row[3]] + + #outfile.write(f' {depth} {count} {labels[0][:80]} {labels[1][:80]}') + #doit = "now"; + + # Detect start of groupings + #for i in [0,1]: + # if depth == i and count > 1: + # outfile.write("") + # group_active[i] = True + + # Detect end of groupings + for i in [1,0]: + changed = False + for j in range(i + 1): + if labels[i] != last_labels[i]: + changed = True + if changed and group_active[i]: + outfile.write("") + group_active[i] = False + + # Detect start of groupings + for i in [0,1]: + if depth == i and count > 1: + outfile.write("") + group_active[i] = True + + # Don't outfile.write out single leaf branches + if depth < 2 and count < 2: + continue + + # supress labels for duplicates + for i in [0,1]: + if group_active[i] and labels[i] == last_labels[i]: + labels[i] = "" + else: + last_labels[i] = labels[i] + + class_string = ">') + + #clean up groupings + for i in [1,0]: + if group_active[i]: + outfile.write("") + group_active[i] = False + + outfile.write(""" +
+ Autograd OperatorKernel NameSizesTotal CallAverage GPUTotal GPU
{labels[0]}{labels[1][:60]}{row[4]}{row[5]}{row[6]}{row[7]}
+ + + + """) + + outfile.write("\n") + connection.close() + + +if __name__ == "__main__": + + parser = argparse.ArgumentParser(description='Format autograd kernel usage as html') + parser.add_argument('input_rpd', type=str, help="input rpd db") + parser.add_argument('output_html', type=str, help="html output") + args = parser.parse_args() + + outfile = open(args.output_html, 'w', encoding="utf-8") + + generateKernelList(outfile, args) + + outfile.close() diff --git a/rocpd/util/chrometracing.py b/rocpd/util/chrometracing.py index a6e3c56..5ef5cd0 100644 --- a/rocpd/util/chrometracing.py +++ b/rocpd/util/chrometracing.py @@ -1,338 +1,319 @@ -################################################################################ -# 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. -################################################################################ - -# -# Format sqlite trace data as json for chrome:tracing -# - -import sys -import os -import csv -import re -import sqlite3 -from collections import defaultdict -from datetime import datetime -import argparse - - -def generateJson(outfile, args): - - connection = sqlite3.connect(args.input_rpd) - - if args.format == "object": - outfile.write("{\"traceEvents\": ") - - outfile.write("[ {}\n"); - - for row in connection.execute("select distinct gpuId from rocpd_op"): - try: - outfile.write(",{\"name\": \"process_name\", \"ph\": \"M\", \"pid\":\"%s\",\"args\":{\"name\":\"%s\"}}\n"%(row[0], "GPU"+str(row[0]))) - outfile.write(",{\"name\": \"process_sort_index\", \"ph\": \"M\", \"pid\":\"%s\",\"args\":{\"sort_index\":\"%s\"}}\n"%(row[0], row[0] + 1000000)) - except ValueError: - outfile.write("") - - for row in connection.execute("select distinct pid, tid from rocpd_api"): - try: - outfile.write(',{"name":"thread_name","ph":"M","pid":"%s","tid":"%s","args":{"name":"%s"}}\n'%(row[0], row[1], "Hip " + str(row[1]))) - outfile.write(',{"name":"thread_sort_index","ph":"M","pid":"%s","tid":"%s","args":{"sort_index":"%s"}}\n'%(row[0], row[1], row[1] * 2)) - except ValueError: - outfile.write("") - - try: - # FIXME - these aren't rendering correctly in chrome://tracing - for row in connection.execute("select distinct pid, tid from rocpd_hsaApi"): - try: - outfile.write(',{"name":"thread_name","ph":"M","pid":"%s","tid":"%s","args":{"name":"%s"}}\n'%(row[0], row[1], "HSA " + str(row[1]))) - outfile.write(',{"name":"thread_sort_index","ph":"M","pid":"%s","tid":"%s","args":{"sort_index":"%s"}}\n'%(row[0], row[1], row[1] * 2 - 1)) - except ValueError: - outfile.write("") - except: - pass - - rangeStringApi = "" - rangeStringOp = "" - min_time = connection.execute("select MIN(start) from rocpd_api;").fetchall()[0][0] - max_time = connection.execute("select MAX(end) from rocpd_api;").fetchall()[0][0] - if (min_time == None): - raise Exception("Trace file is empty.") - - print("Timestamps:") - print(f"\t first: \t{min_time/1000} us") - print(f"\t last: \t{max_time/1000} us") - print(f"\t duration: \t{(max_time-min_time) / 1000000000} seconds") - - start_time = min_time/1000 - end_time = max_time/1000 - - if args.start: - if "%" in args.start: - start_time = ( (max_time - min_time) * ( int( args.start.replace("%","") )/100 ) + min_time )/1000 - else: - start_time = int(args.start) - rangeStringApi = "where rocpd_api.start/1000 >= %s"%(start_time) - rangeStringOp = "where rocpd_op.start/1000 >= %s"%(start_time) - if args.end: - if "%" in args.end: - end_time = ( (max_time - min_time) * ( int( args.end.replace("%","") )/100 ) + min_time )/1000 - else: - end_time = int(args.end) - - rangeStringApi = rangeStringApi + " and rocpd_api.start/1000 <= %s"%(end_time) if args.start != None else "where rocpd_api.start/1000 <= %s"%(end_time) - rangeStringOp = rangeStringOp + " and rocpd_op.start/1000 <= %s"%(end_time) if args.start != None else "where rocpd_op.start/1000 <= %s"%(end_time) - - print("\nFilter: %s"%(rangeStringApi)) - print(f"Output duration: {(end_time-start_time)/1000000} seconds") - - # Output Ops - ''' - # Hack for busted rocprofiler that can't populate kernel names - for row in connection.execute("select A.string as optype, B.string as description, C.string as arg, gpuId, queueId, rocpd_op.start/1000, (rocpd_op.end-rocpd_op.start) / 1000 from rocpd_op LEFT JOIN rocpd_api_ops on op_id = rocpd_op.id INNER JOIN rocpd_api on api_id = rocpd_api.id INNER JOIN rocpd_string A on A.id = rocpd_op.opType_id INNER Join rocpd_string B on B.id = rocpd_op.description_id INNER JOIN rocpd_string C on C.id = rocpd_api.args_id %s"%(rangeString)): - try: - name = row[0] if len(row[2])==0 else row[2] - outfile.write(",{\"pid\":\"%s\",\"tid\":\"%s\",\"name\":\"%s\",\"ts\":\"%s\",\"dur\":\"%s\",\"ph\":\"X\",\"args\":{\"desc\":\"%s\"}}\n"%(row[3], row[4], name, row[5], row[6], row[0])) - except ValueError: - outfile.write("") - ''' - - for row in connection.execute("select A.string as optype, B.string as description, gpuId, queueId, rocpd_op.start/1000, (rocpd_op.end-rocpd_op.start) / 1000 from rocpd_op INNER JOIN rocpd_string A on A.id = rocpd_op.opType_id INNER Join rocpd_string B on B.id = rocpd_op.description_id %s"%(rangeStringOp)): - try: - name = row[0] if len(row[1])==0 else row[1] - outfile.write(",{\"pid\":\"%s\",\"tid\":\"%s\",\"name\":\"%s\",\"ts\":\"%s\",\"dur\":\"%s\",\"ph\":\"X\",\"args\":{\"desc\":\"%s\"}}\n"%(row[2], row[3], name, row[4], row[5], row[0])) - except ValueError: - outfile.write("") - - #Output Graph executions on GPU - try: - for row in connection.execute('select graphExec, gpuId, queueId, min(start)/1000, (max(end)-min(start))/1000, count(*) from rocpd_graphLaunchapi A join rocpd_api_ops B on B.api_id = A.api_ptr_id join rocpd_op C on C.id = B.op_id group by api_ptr_id'): - try: - outfile.write(",{\"pid\":\"%s\",\"tid\":\"%s\",\"name\":\"%s\",\"ts\":\"%s\",\"dur\":\"%s\",\"ph\":\"X\",\"args\":{\"kernels\":\"%s\"}}\n"%(row[1], row[2], f'Graph {row[0]}', row[3], row[4], row[5])) - except ValueError: - outfile.write("") - except: - pass - - #Output apis - for row in connection.execute("select A.string as apiName, B.string as args, pid, tid, rocpd_api.start/1000, (rocpd_api.end-rocpd_api.start) / 1000, (rocpd_api.end != rocpd_api.start) as has_duration from rocpd_api INNER JOIN rocpd_string A on A.id = rocpd_api.apiName_id INNER Join rocpd_string B on B.id = rocpd_api.args_id %s order by rocpd_api.id"%(rangeStringApi)): - try: - if row[0]=="UserMarker": - if row[6] == 0: # instantanuous "mark" messages - outfile.write(",{\"pid\":\"%s\",\"tid\":\"%s\",\"name\":\"%s\",\"ts\":\"%s\",\"ph\":\"i\",\"s\":\"p\",\"args\":{\"desc\":\"%s\"}}\n"%(row[2], row[3], row[1].replace('"',''), row[4], row[1].replace('"',''))) - else: - outfile.write(",{\"pid\":\"%s\",\"tid\":\"%s\",\"name\":\"%s\",\"ts\":\"%s\",\"dur\":\"%s\",\"ph\":\"X\",\"args\":{\"desc\":\"%s\"}}\n"%(row[2], row[3], row[1].replace('"',''), row[4], row[5], row[1].replace('"',''))) - else: - outfile.write(",{\"pid\":\"%s\",\"tid\":\"%s\",\"name\":\"%s\",\"ts\":\"%s\",\"dur\":\"%s\",\"ph\":\"X\",\"args\":{\"desc\":\"%s\"}}\n"%(row[2], row[3], row[0], row[4], row[5], row[1].replace('"','').replace('\t',''))) - except ValueError: - outfile.write("") - - #Output api->op linkage - for row in connection.execute("select rocpd_api_ops.id, pid, tid, gpuId, queueId, rocpd_api.end/1000 - 2, rocpd_op.start/1000 from rocpd_api_ops INNER JOIN rocpd_api on rocpd_api_ops.api_id = rocpd_api.id INNER JOIN rocpd_op on rocpd_api_ops.op_id = rocpd_op.id %s"%(rangeStringApi)): - try: - fromtime = row[5] if row[5] < row[6] else row[6] - outfile.write(",{\"pid\":\"%s\",\"tid\":\"%s\",\"cat\":\"api_op\",\"name\":\"api_op\",\"ts\":\"%s\",\"id\":\"%s\",\"ph\":\"s\"}\n"%(row[1], row[2], fromtime, row[0])) - outfile.write(",{\"pid\":\"%s\",\"tid\":\"%s\",\"cat\":\"api_op\",\"name\":\"api_op\",\"ts\":\"%s\",\"id\":\"%s\",\"ph\":\"f\", \"bp\":\"e\"}\n"%(row[3], row[4], row[6], row[0])) - except ValueError: - outfile.write("") - - try: - for row in connection.execute("select A.string as apiName, B.string as args, pid, tid, rocpd_hsaApi.start/1000, (rocpd_hsaApi.end-rocpd_hsaApi.start) / 1000 from rocpd_hsaApi INNER JOIN rocpd_string A on A.id = rocpd_hsaApi.apiName_id INNER Join rocpd_string B on B.id = rocpd_hsaApi.args_id %s order by rocpd_hsaApi.id"%(rangeStringApi)): - try: - outfile.write(",{\"pid\":\"%s\",\"tid\":\"%s\",\"name\":\"%s\",\"ts\":\"%s\",\"dur\":\"%s\",\"ph\":\"X\",\"args\":{\"desc\":\"%s\"}}\n"%(row[2], row[3]+1, row[0], row[4], row[5], row[1].replace('"',''))) - except ValueError: - outfile.write("") - except: - pass - - - # - # Counters - # - - # Counters should extend to the last event in the trace. This means they need to have a value at Tend. - # Figure out when that is - - T_end = 0 - for row in connection.execute("SELECT max(end)/1000 from (SELECT end from rocpd_api UNION ALL SELECT end from rocpd_op)"): - T_end = int(row[0]) - - # Loop over GPU for per-gpu counters - gpuIdsPresent = [] - for row in connection.execute("SELECT DISTINCT gpuId FROM rocpd_op"): - gpuIdsPresent.append(row[0]) - - for gpuId in gpuIdsPresent: - #print(f"Creating counters for: {gpuId}") - - #Create the queue depth counter - depth = 0 - idle = 1 - for row in connection.execute("select * from (select rocpd_api.start/1000 as ts, \"1\" from rocpd_api_ops INNER JOIN rocpd_api on rocpd_api_ops.api_id = rocpd_api.id INNER JOIN rocpd_op on rocpd_api_ops.op_id = rocpd_op.id AND rocpd_op.gpuId = %s %s UNION ALL select rocpd_op.end/1000, \"-1\" from rocpd_api_ops INNER JOIN rocpd_api on rocpd_api_ops.api_id = rocpd_api.id INNER JOIN rocpd_op on rocpd_api_ops.op_id = rocpd_op.id AND rocpd_op.gpuId = %s %s) order by ts"%(gpuId, rangeStringOp, gpuId, rangeStringOp)): - try: - if idle and int(row[1]) > 0: - idle = 0 - outfile.write(',{"pid":"%s","name":"Idle","ph":"C","ts":%s,"args":{"idle":%s}}\n'%(gpuId, row[0], idle)) - if depth == 1 and int(row[1]) < 0: - idle = 1 - outfile.write(',{"pid":"%s","name":"Idle","ph":"C","ts":%s,"args":{"idle":%s}}\n'%(gpuId, row[0], idle)) - depth = depth + int(row[1]) - outfile.write(',{"pid":"%s","name":"QueueDepth","ph":"C","ts":%s,"args":{"depth":%s}}\n'%(gpuId, row[0], depth)) - except ValueError: - outfile.write("") - if T_end > 0: - outfile.write(',{"pid":"%s","name":"Idle","ph":"C","ts":%s,"args":{"idle":%s}}\n'%(gpuId, T_end, idle)) - outfile.write(',{"pid":"%s","name":"QueueDepth","ph":"C","ts":%s,"args":{"depth":%s}}\n'%(gpuId, T_end, depth)) - - # Create SMI counters - try: - for row in connection.execute("select deviceId, monitorType, start/1000, value from rocpd_monitor"): - outfile.write(',{"pid":"%s","name":"%s","ph":"C","ts":%s,"args":{"%s":%s}}\n'%(row[0], row[1], row[2], row[1], row[3])) - # Output the endpoints of the last range - for row in connection.execute("select distinct deviceId, monitorType, max(end)/1000, value from rocpd_monitor group by deviceId, monitorType"): - outfile.write(',{"pid":"%s","name":"%s","ph":"C","ts":%s,"args":{"%s":%s}}\n'%(row[0], row[1], row[2], row[1], row[3])) - except: - print("Did not find SMI data") - - #Create the (global) memory counter - sizes = {} # address -> size - totalSize = 0 - exp = re.compile("^ptr\((.*)\)\s+size\((.*)\)$") - exp2 = re.compile("^ptr\((.*)\)$") - for row in connection.execute("SELECT rocpd_api.end/1000 as ts, B.string, '1' FROM rocpd_api INNER JOIN rocpd_string A ON A.id=rocpd_api.apiName_id INNER JOIN rocpd_string B ON B.id=rocpd_api.args_id WHERE A.string='hipFree' UNION ALL SELECT rocpd_api.start/1000, B.string, '0' FROM rocpd_api INNER JOIN rocpd_string A ON A.id=rocpd_api.apiName_id INNER JOIN rocpd_string B ON B.id=rocpd_api.args_id WHERE A.string='hipMalloc' ORDER BY ts asc"): - try: - if row[2] == '0': #malloc - m = exp.match(row[1]) - if m: - size = int(m.group(2), 16) - totalSize = totalSize + size - sizes[m.group(1)] = size - outfile.write(',{"pid":"0","name":"Allocated Memory","ph":"C","ts":%s,"args":{"depth":%s}}\n'%(row[0],totalSize)) - else: #free - m = exp2.match(row[1]) - if m: - try: # Sometimes free addresses are not valid or listed - size = sizes[m.group(1)] - sizes[m.group(1)] = 0 - totalSize = totalSize - size; - outfile.write(',{"pid":"0","name":"Allocated Memory","ph":"C","ts":%s,"args":{"depth":%s}}\n'%(row[0],totalSize)) - except KeyError: - pass - except ValueError: - outfile.write("") - if T_end > 0: - outfile.write(',{"pid":"0","name":"Allocated Memory","ph":"C","ts":%s,"args":{"depth":%s}}\n'%(T_end,totalSize)) - - #Create "faux calling stack frame" on gpu ops traceS - stacks = {} # Call stacks built from UserMarker entres. Key is 'pid,tid' - currentFrame = {} #"Current GPU frame" (id, name, start, end). Key is 'pid,tid' - - class GpuFrame: - def __init__(self): - self.id = 0 - self.name = '' - self.start = 0 - self.end = 0 - self.gpus = [] - self.totalOps = 0 - - # FIXME: include 'start' (in ns) so we can ORDER BY it and break ties? - for row in connection.execute("SELECT '0', start/1000, pid, tid, B.string as label, '','','', '' from rocpd_api INNER JOIN rocpd_string A on A.id = rocpd_api.apiName_id AND A.string = 'UserMarker' INNER JOIN rocpd_string B on B.id = rocpd_api.args_id AND rocpd_api.start/1000 != rocpd_api.end/1000 %s UNION ALL SELECT '1', end/1000, pid, tid, B.string as label, '','','', '' from rocpd_api INNER JOIN rocpd_string A on A.id = rocpd_api.apiName_id AND A.string = 'UserMarker' INNER JOIN rocpd_string B on B.id = rocpd_api.args_id AND rocpd_api.start/1000 != rocpd_api.end/1000 %s UNION ALL SELECT '2', rocpd_api.start/1000, pid, tid, '' as label, gpuId, queueId, rocpd_op.start/1000, rocpd_op.end/1000 from rocpd_api_ops INNER JOIN rocpd_api ON rocpd_api_ops.api_id = rocpd_api.id INNER JOIN rocpd_op ON rocpd_api_ops.op_id = rocpd_op.id %s ORDER BY start/1000 asc"%(rangeStringApi, rangeStringApi, rangeStringApi)): - try: - key = (row[2], row[3]) # Key is 'pid,tid' - if row[0] == '0': # Frame start - if key not in stacks: - stacks[key] = [] - stack = stacks[key].append((row[1], row[4])) - #print(f"0: new api frame: pid_tid={key} -> stack={stacks}") - - elif row[0] == '1': #Frame end - completed = stacks[key].pop() - #print(f"1: end api frame: pid_tid={key} -> stack={stacks}") - - elif row[0] == '2': # API + Op - if key in stacks and len(stacks[key]) > 0: - frame = stacks[key][-1] - #print(f"2: Op on {frame} ({len(stacks[key])})") - gpuFrame = None - if key not in currentFrame: # First op under the current api frame - gpuFrame = GpuFrame() - gpuFrame.id = frame[0] - gpuFrame.name = frame[1] - gpuFrame.start = row[7] - gpuFrame.end = row[8] - gpuFrame.gpus.append((row[5], row[6])) - gpuFrame.totalOps = 1 - #print(f"2a: new frame: {gpuFrame.gpus} {gpuFrame.start} {gpuFrame.end} {gpuFrame.end - gpuFrame.start}") - else: - gpuFrame = currentFrame[key] - # Another op under the same frame -> union them (but only if they are butt together) - if gpuFrame.id == frame[0] and gpuFrame.name == frame[1] and (abs(row[7] - gpuFrame.end) < 200 or abs(gpuFrame.start - row[8]) < 200): - #if gpuFrame.id == frame[0] and gpuFrame.name == frame[1]: # Another op under the same frame -> union them - #if False: # Turn off frame joining - if row[7] < gpuFrame.start: gpuFrame.start = row[7] - if row[8] > gpuFrame.end: gpuFrame.end = row[8] - if (row[5], row[6]) not in gpuFrame.gpus: gpuFrame.gpus.append((row[5], row[6])) - gpuFrame.totalOps = gpuFrame.totalOps + 1 - #print(f"2c: union frame: {gpuFrame.gpus} {gpuFrame.start} {gpuFrame.end} {gpuFrame.end - gpuFrame.start}") - - else: #This is a new frame - dump the last and make new - gpuFrame = currentFrame[key] - for dest in gpuFrame.gpus: - #print(f"2: OUTPUT: dest={dest} time={gpuFrame.start} -> {gpuFrame.end} Duration={gpuFrame.end - gpuFrame.start} TotalOps={gpuFrame.totalOps}") - outfile.write(',{"pid":"%s","tid":"%s","name":"%s","ts":"%s","dur":"%s","ph":"X","args":{"desc":"%s"}}\n'%(dest[0], dest[1], gpuFrame.name.replace('"',''), gpuFrame.start - 1, gpuFrame.end - gpuFrame.start + 1, f"UserMarker frame: {gpuFrame.totalOps} ops")) - currentFrame.pop(key) - - # make the first op under the new frame - gpuFrame = GpuFrame() - gpuFrame.id = frame[0] - gpuFrame.name = frame[1] - gpuFrame.start = row[7] - gpuFrame.end = row[8] - gpuFrame.gpus.append((row[5], row[6])) - gpuFrame.totalOps = 1 - #print(f"2b: new frame: {gpuFrame.gpus} {gpuFrame.start} {gpuFrame.end} {gpuFrame.end - gpuFrame.start}") - - currentFrame[key] = gpuFrame - - except ValueError: - outfile.write("") - - outfile.write("]\n") - - if args.format == "object": - outfile.write("} \n") - - connection.close() - -if __name__ == "__main__": - - parser = argparse.ArgumentParser(description='convert RPD to json for chrome tracing') - parser.add_argument('input_rpd', type=str, help="input rpd db") - parser.add_argument('output_json', type=str, help="chrome tracing json output") - parser.add_argument('--start', type=str, help="start time - default us or percentage %%. Number only is interpreted as us. Number with %% is interpreted as percentage") - parser.add_argument('--end', type=str, help="end time - default us or percentage %%. See help for --start") - parser.add_argument('--format', type=str, default="object", help="chome trace format, array or object") - args = parser.parse_args() - - outfile = open(args.output_json, 'w', encoding="utf-8") - - generateJson(outfile, args) - - outfile.close() +# Copyright (C) Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT + +# +# Format sqlite trace data as json for chrome:tracing +# + +import sys +import os +import csv +import re +import sqlite3 +from collections import defaultdict +from datetime import datetime +import argparse + + +def generateJson(outfile, args): + + connection = sqlite3.connect(args.input_rpd) + + if args.format == "object": + outfile.write("{\"traceEvents\": ") + + outfile.write("[ {}\n"); + + for row in connection.execute("select distinct gpuId from rocpd_op"): + try: + outfile.write(",{\"name\": \"process_name\", \"ph\": \"M\", \"pid\":\"%s\",\"args\":{\"name\":\"%s\"}}\n"%(row[0], "GPU"+str(row[0]))) + outfile.write(",{\"name\": \"process_sort_index\", \"ph\": \"M\", \"pid\":\"%s\",\"args\":{\"sort_index\":\"%s\"}}\n"%(row[0], row[0] + 1000000)) + except ValueError: + outfile.write("") + + for row in connection.execute("select distinct pid, tid from rocpd_api"): + try: + outfile.write(',{"name":"thread_name","ph":"M","pid":"%s","tid":"%s","args":{"name":"%s"}}\n'%(row[0], row[1], "Hip " + str(row[1]))) + outfile.write(',{"name":"thread_sort_index","ph":"M","pid":"%s","tid":"%s","args":{"sort_index":"%s"}}\n'%(row[0], row[1], row[1] * 2)) + except ValueError: + outfile.write("") + + try: + # FIXME - these aren't rendering correctly in chrome://tracing + for row in connection.execute("select distinct pid, tid from rocpd_hsaApi"): + try: + outfile.write(',{"name":"thread_name","ph":"M","pid":"%s","tid":"%s","args":{"name":"%s"}}\n'%(row[0], row[1], "HSA " + str(row[1]))) + outfile.write(',{"name":"thread_sort_index","ph":"M","pid":"%s","tid":"%s","args":{"sort_index":"%s"}}\n'%(row[0], row[1], row[1] * 2 - 1)) + except ValueError: + outfile.write("") + except: + pass + + rangeStringApi = "" + rangeStringOp = "" + min_time = connection.execute("select MIN(start) from rocpd_api;").fetchall()[0][0] + max_time = connection.execute("select MAX(end) from rocpd_api;").fetchall()[0][0] + if (min_time == None): + raise Exception("Trace file is empty.") + + print("Timestamps:") + print(f"\t first: \t{min_time/1000} us") + print(f"\t last: \t{max_time/1000} us") + print(f"\t duration: \t{(max_time-min_time) / 1000000000} seconds") + + start_time = min_time/1000 + end_time = max_time/1000 + + if args.start: + if "%" in args.start: + start_time = ( (max_time - min_time) * ( int( args.start.replace("%","") )/100 ) + min_time )/1000 + else: + start_time = int(args.start) + rangeStringApi = "where rocpd_api.start/1000 >= %s"%(start_time) + rangeStringOp = "where rocpd_op.start/1000 >= %s"%(start_time) + if args.end: + if "%" in args.end: + end_time = ( (max_time - min_time) * ( int( args.end.replace("%","") )/100 ) + min_time )/1000 + else: + end_time = int(args.end) + + rangeStringApi = rangeStringApi + " and rocpd_api.start/1000 <= %s"%(end_time) if args.start != None else "where rocpd_api.start/1000 <= %s"%(end_time) + rangeStringOp = rangeStringOp + " and rocpd_op.start/1000 <= %s"%(end_time) if args.start != None else "where rocpd_op.start/1000 <= %s"%(end_time) + + print("\nFilter: %s"%(rangeStringApi)) + print(f"Output duration: {(end_time-start_time)/1000000} seconds") + + # Output Ops + ''' + # Hack for busted rocprofiler that can't populate kernel names + for row in connection.execute("select A.string as optype, B.string as description, C.string as arg, gpuId, queueId, rocpd_op.start/1000, (rocpd_op.end-rocpd_op.start) / 1000 from rocpd_op LEFT JOIN rocpd_api_ops on op_id = rocpd_op.id INNER JOIN rocpd_api on api_id = rocpd_api.id INNER JOIN rocpd_string A on A.id = rocpd_op.opType_id INNER Join rocpd_string B on B.id = rocpd_op.description_id INNER JOIN rocpd_string C on C.id = rocpd_api.args_id %s"%(rangeString)): + try: + name = row[0] if len(row[2])==0 else row[2] + outfile.write(",{\"pid\":\"%s\",\"tid\":\"%s\",\"name\":\"%s\",\"ts\":\"%s\",\"dur\":\"%s\",\"ph\":\"X\",\"args\":{\"desc\":\"%s\"}}\n"%(row[3], row[4], name, row[5], row[6], row[0])) + except ValueError: + outfile.write("") + ''' + + for row in connection.execute("select A.string as optype, B.string as description, gpuId, queueId, rocpd_op.start/1000, (rocpd_op.end-rocpd_op.start) / 1000 from rocpd_op INNER JOIN rocpd_string A on A.id = rocpd_op.opType_id INNER Join rocpd_string B on B.id = rocpd_op.description_id %s"%(rangeStringOp)): + try: + name = row[0] if len(row[1])==0 else row[1] + outfile.write(",{\"pid\":\"%s\",\"tid\":\"%s\",\"name\":\"%s\",\"ts\":\"%s\",\"dur\":\"%s\",\"ph\":\"X\",\"args\":{\"desc\":\"%s\"}}\n"%(row[2], row[3], name, row[4], row[5], row[0])) + except ValueError: + outfile.write("") + + #Output Graph executions on GPU + try: + for row in connection.execute('select graphExec, gpuId, queueId, min(start)/1000, (max(end)-min(start))/1000, count(*) from rocpd_graphLaunchapi A join rocpd_api_ops B on B.api_id = A.api_ptr_id join rocpd_op C on C.id = B.op_id group by api_ptr_id'): + try: + outfile.write(",{\"pid\":\"%s\",\"tid\":\"%s\",\"name\":\"%s\",\"ts\":\"%s\",\"dur\":\"%s\",\"ph\":\"X\",\"args\":{\"kernels\":\"%s\"}}\n"%(row[1], row[2], f'Graph {row[0]}', row[3], row[4], row[5])) + except ValueError: + outfile.write("") + except: + pass + + #Output apis + for row in connection.execute("select A.string as apiName, B.string as args, pid, tid, rocpd_api.start/1000, (rocpd_api.end-rocpd_api.start) / 1000, (rocpd_api.end != rocpd_api.start) as has_duration from rocpd_api INNER JOIN rocpd_string A on A.id = rocpd_api.apiName_id INNER Join rocpd_string B on B.id = rocpd_api.args_id %s order by rocpd_api.id"%(rangeStringApi)): + try: + if row[0]=="UserMarker": + if row[6] == 0: # instantanuous "mark" messages + outfile.write(",{\"pid\":\"%s\",\"tid\":\"%s\",\"name\":\"%s\",\"ts\":\"%s\",\"ph\":\"i\",\"s\":\"p\",\"args\":{\"desc\":\"%s\"}}\n"%(row[2], row[3], row[1].replace('"',''), row[4], row[1].replace('"',''))) + else: + outfile.write(",{\"pid\":\"%s\",\"tid\":\"%s\",\"name\":\"%s\",\"ts\":\"%s\",\"dur\":\"%s\",\"ph\":\"X\",\"args\":{\"desc\":\"%s\"}}\n"%(row[2], row[3], row[1].replace('"',''), row[4], row[5], row[1].replace('"',''))) + else: + outfile.write(",{\"pid\":\"%s\",\"tid\":\"%s\",\"name\":\"%s\",\"ts\":\"%s\",\"dur\":\"%s\",\"ph\":\"X\",\"args\":{\"desc\":\"%s\"}}\n"%(row[2], row[3], row[0], row[4], row[5], row[1].replace('"','').replace('\t',''))) + except ValueError: + outfile.write("") + + #Output api->op linkage + for row in connection.execute("select rocpd_api_ops.id, pid, tid, gpuId, queueId, rocpd_api.end/1000 - 2, rocpd_op.start/1000 from rocpd_api_ops INNER JOIN rocpd_api on rocpd_api_ops.api_id = rocpd_api.id INNER JOIN rocpd_op on rocpd_api_ops.op_id = rocpd_op.id %s"%(rangeStringApi)): + try: + fromtime = row[5] if row[5] < row[6] else row[6] + outfile.write(",{\"pid\":\"%s\",\"tid\":\"%s\",\"cat\":\"api_op\",\"name\":\"api_op\",\"ts\":\"%s\",\"id\":\"%s\",\"ph\":\"s\"}\n"%(row[1], row[2], fromtime, row[0])) + outfile.write(",{\"pid\":\"%s\",\"tid\":\"%s\",\"cat\":\"api_op\",\"name\":\"api_op\",\"ts\":\"%s\",\"id\":\"%s\",\"ph\":\"f\", \"bp\":\"e\"}\n"%(row[3], row[4], row[6], row[0])) + except ValueError: + outfile.write("") + + try: + for row in connection.execute("select A.string as apiName, B.string as args, pid, tid, rocpd_hsaApi.start/1000, (rocpd_hsaApi.end-rocpd_hsaApi.start) / 1000 from rocpd_hsaApi INNER JOIN rocpd_string A on A.id = rocpd_hsaApi.apiName_id INNER Join rocpd_string B on B.id = rocpd_hsaApi.args_id %s order by rocpd_hsaApi.id"%(rangeStringApi)): + try: + outfile.write(",{\"pid\":\"%s\",\"tid\":\"%s\",\"name\":\"%s\",\"ts\":\"%s\",\"dur\":\"%s\",\"ph\":\"X\",\"args\":{\"desc\":\"%s\"}}\n"%(row[2], row[3]+1, row[0], row[4], row[5], row[1].replace('"',''))) + except ValueError: + outfile.write("") + except: + pass + + + # + # Counters + # + + # Counters should extend to the last event in the trace. This means they need to have a value at Tend. + # Figure out when that is + + T_end = 0 + for row in connection.execute("SELECT max(end)/1000 from (SELECT end from rocpd_api UNION ALL SELECT end from rocpd_op)"): + T_end = int(row[0]) + + # Loop over GPU for per-gpu counters + gpuIdsPresent = [] + for row in connection.execute("SELECT DISTINCT gpuId FROM rocpd_op"): + gpuIdsPresent.append(row[0]) + + for gpuId in gpuIdsPresent: + #print(f"Creating counters for: {gpuId}") + + #Create the queue depth counter + depth = 0 + idle = 1 + for row in connection.execute("select * from (select rocpd_api.start/1000 as ts, \"1\" from rocpd_api_ops INNER JOIN rocpd_api on rocpd_api_ops.api_id = rocpd_api.id INNER JOIN rocpd_op on rocpd_api_ops.op_id = rocpd_op.id AND rocpd_op.gpuId = %s %s UNION ALL select rocpd_op.end/1000, \"-1\" from rocpd_api_ops INNER JOIN rocpd_api on rocpd_api_ops.api_id = rocpd_api.id INNER JOIN rocpd_op on rocpd_api_ops.op_id = rocpd_op.id AND rocpd_op.gpuId = %s %s) order by ts"%(gpuId, rangeStringOp, gpuId, rangeStringOp)): + try: + if idle and int(row[1]) > 0: + idle = 0 + outfile.write(',{"pid":"%s","name":"Idle","ph":"C","ts":%s,"args":{"idle":%s}}\n'%(gpuId, row[0], idle)) + if depth == 1 and int(row[1]) < 0: + idle = 1 + outfile.write(',{"pid":"%s","name":"Idle","ph":"C","ts":%s,"args":{"idle":%s}}\n'%(gpuId, row[0], idle)) + depth = depth + int(row[1]) + outfile.write(',{"pid":"%s","name":"QueueDepth","ph":"C","ts":%s,"args":{"depth":%s}}\n'%(gpuId, row[0], depth)) + except ValueError: + outfile.write("") + if T_end > 0: + outfile.write(',{"pid":"%s","name":"Idle","ph":"C","ts":%s,"args":{"idle":%s}}\n'%(gpuId, T_end, idle)) + outfile.write(',{"pid":"%s","name":"QueueDepth","ph":"C","ts":%s,"args":{"depth":%s}}\n'%(gpuId, T_end, depth)) + + # Create SMI counters + try: + for row in connection.execute("select deviceId, monitorType, start/1000, value from rocpd_monitor"): + outfile.write(',{"pid":"%s","name":"%s","ph":"C","ts":%s,"args":{"%s":%s}}\n'%(row[0], row[1], row[2], row[1], row[3])) + # Output the endpoints of the last range + for row in connection.execute("select distinct deviceId, monitorType, max(end)/1000, value from rocpd_monitor group by deviceId, monitorType"): + outfile.write(',{"pid":"%s","name":"%s","ph":"C","ts":%s,"args":{"%s":%s}}\n'%(row[0], row[1], row[2], row[1], row[3])) + except: + print("Did not find SMI data") + + #Create the (global) memory counter + sizes = {} # address -> size + totalSize = 0 + exp = re.compile("^ptr\((.*)\)\s+size\((.*)\)$") + exp2 = re.compile("^ptr\((.*)\)$") + for row in connection.execute("SELECT rocpd_api.end/1000 as ts, B.string, '1' FROM rocpd_api INNER JOIN rocpd_string A ON A.id=rocpd_api.apiName_id INNER JOIN rocpd_string B ON B.id=rocpd_api.args_id WHERE A.string='hipFree' UNION ALL SELECT rocpd_api.start/1000, B.string, '0' FROM rocpd_api INNER JOIN rocpd_string A ON A.id=rocpd_api.apiName_id INNER JOIN rocpd_string B ON B.id=rocpd_api.args_id WHERE A.string='hipMalloc' ORDER BY ts asc"): + try: + if row[2] == '0': #malloc + m = exp.match(row[1]) + if m: + size = int(m.group(2), 16) + totalSize = totalSize + size + sizes[m.group(1)] = size + outfile.write(',{"pid":"0","name":"Allocated Memory","ph":"C","ts":%s,"args":{"depth":%s}}\n'%(row[0],totalSize)) + else: #free + m = exp2.match(row[1]) + if m: + try: # Sometimes free addresses are not valid or listed + size = sizes[m.group(1)] + sizes[m.group(1)] = 0 + totalSize = totalSize - size; + outfile.write(',{"pid":"0","name":"Allocated Memory","ph":"C","ts":%s,"args":{"depth":%s}}\n'%(row[0],totalSize)) + except KeyError: + pass + except ValueError: + outfile.write("") + if T_end > 0: + outfile.write(',{"pid":"0","name":"Allocated Memory","ph":"C","ts":%s,"args":{"depth":%s}}\n'%(T_end,totalSize)) + + #Create "faux calling stack frame" on gpu ops traceS + stacks = {} # Call stacks built from UserMarker entres. Key is 'pid,tid' + currentFrame = {} #"Current GPU frame" (id, name, start, end). Key is 'pid,tid' + + class GpuFrame: + def __init__(self): + self.id = 0 + self.name = '' + self.start = 0 + self.end = 0 + self.gpus = [] + self.totalOps = 0 + + # FIXME: include 'start' (in ns) so we can ORDER BY it and break ties? + for row in connection.execute("SELECT '0', start/1000, pid, tid, B.string as label, '','','', '' from rocpd_api INNER JOIN rocpd_string A on A.id = rocpd_api.apiName_id AND A.string = 'UserMarker' INNER JOIN rocpd_string B on B.id = rocpd_api.args_id AND rocpd_api.start/1000 != rocpd_api.end/1000 %s UNION ALL SELECT '1', end/1000, pid, tid, B.string as label, '','','', '' from rocpd_api INNER JOIN rocpd_string A on A.id = rocpd_api.apiName_id AND A.string = 'UserMarker' INNER JOIN rocpd_string B on B.id = rocpd_api.args_id AND rocpd_api.start/1000 != rocpd_api.end/1000 %s UNION ALL SELECT '2', rocpd_api.start/1000, pid, tid, '' as label, gpuId, queueId, rocpd_op.start/1000, rocpd_op.end/1000 from rocpd_api_ops INNER JOIN rocpd_api ON rocpd_api_ops.api_id = rocpd_api.id INNER JOIN rocpd_op ON rocpd_api_ops.op_id = rocpd_op.id %s ORDER BY start/1000 asc"%(rangeStringApi, rangeStringApi, rangeStringApi)): + try: + key = (row[2], row[3]) # Key is 'pid,tid' + if row[0] == '0': # Frame start + if key not in stacks: + stacks[key] = [] + stack = stacks[key].append((row[1], row[4])) + #print(f"0: new api frame: pid_tid={key} -> stack={stacks}") + + elif row[0] == '1': #Frame end + completed = stacks[key].pop() + #print(f"1: end api frame: pid_tid={key} -> stack={stacks}") + + elif row[0] == '2': # API + Op + if key in stacks and len(stacks[key]) > 0: + frame = stacks[key][-1] + #print(f"2: Op on {frame} ({len(stacks[key])})") + gpuFrame = None + if key not in currentFrame: # First op under the current api frame + gpuFrame = GpuFrame() + gpuFrame.id = frame[0] + gpuFrame.name = frame[1] + gpuFrame.start = row[7] + gpuFrame.end = row[8] + gpuFrame.gpus.append((row[5], row[6])) + gpuFrame.totalOps = 1 + #print(f"2a: new frame: {gpuFrame.gpus} {gpuFrame.start} {gpuFrame.end} {gpuFrame.end - gpuFrame.start}") + else: + gpuFrame = currentFrame[key] + # Another op under the same frame -> union them (but only if they are butt together) + if gpuFrame.id == frame[0] and gpuFrame.name == frame[1] and (abs(row[7] - gpuFrame.end) < 200 or abs(gpuFrame.start - row[8]) < 200): + #if gpuFrame.id == frame[0] and gpuFrame.name == frame[1]: # Another op under the same frame -> union them + #if False: # Turn off frame joining + if row[7] < gpuFrame.start: gpuFrame.start = row[7] + if row[8] > gpuFrame.end: gpuFrame.end = row[8] + if (row[5], row[6]) not in gpuFrame.gpus: gpuFrame.gpus.append((row[5], row[6])) + gpuFrame.totalOps = gpuFrame.totalOps + 1 + #print(f"2c: union frame: {gpuFrame.gpus} {gpuFrame.start} {gpuFrame.end} {gpuFrame.end - gpuFrame.start}") + + else: #This is a new frame - dump the last and make new + gpuFrame = currentFrame[key] + for dest in gpuFrame.gpus: + #print(f"2: OUTPUT: dest={dest} time={gpuFrame.start} -> {gpuFrame.end} Duration={gpuFrame.end - gpuFrame.start} TotalOps={gpuFrame.totalOps}") + outfile.write(',{"pid":"%s","tid":"%s","name":"%s","ts":"%s","dur":"%s","ph":"X","args":{"desc":"%s"}}\n'%(dest[0], dest[1], gpuFrame.name.replace('"',''), gpuFrame.start - 1, gpuFrame.end - gpuFrame.start + 1, f"UserMarker frame: {gpuFrame.totalOps} ops")) + currentFrame.pop(key) + + # make the first op under the new frame + gpuFrame = GpuFrame() + gpuFrame.id = frame[0] + gpuFrame.name = frame[1] + gpuFrame.start = row[7] + gpuFrame.end = row[8] + gpuFrame.gpus.append((row[5], row[6])) + gpuFrame.totalOps = 1 + #print(f"2b: new frame: {gpuFrame.gpus} {gpuFrame.start} {gpuFrame.end} {gpuFrame.end - gpuFrame.start}") + + currentFrame[key] = gpuFrame + + except ValueError: + outfile.write("") + + outfile.write("]\n") + + if args.format == "object": + outfile.write("} \n") + + connection.close() + +if __name__ == "__main__": + + parser = argparse.ArgumentParser(description='convert RPD to json for chrome tracing') + parser.add_argument('input_rpd', type=str, help="input rpd db") + parser.add_argument('output_json', type=str, help="chrome tracing json output") + parser.add_argument('--start', type=str, help="start time - default us or percentage %%. Number only is interpreted as us. Number with %% is interpreted as percentage") + parser.add_argument('--end', type=str, help="end time - default us or percentage %%. See help for --start") + parser.add_argument('--format', type=str, default="object", help="chome trace format, array or object") + args = parser.parse_args() + + outfile = open(args.output_json, 'w', encoding="utf-8") + + generateJson(outfile, args) + + outfile.close() diff --git a/rocpd_python/rocpd/autograd.py b/rocpd_python/rocpd/autograd.py index ee954e3..a1aa670 100644 --- a/rocpd_python/rocpd/autograd.py +++ b/rocpd_python/rocpd/autograd.py @@ -1,24 +1,5 @@ -################################################################################ -# 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. -################################################################################ +# Copyright (C) Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT # Create subclass table for autograd operators # diff --git a/rocpd_python/rocpd/call_stacks.py b/rocpd_python/rocpd/call_stacks.py index bb1063c..9e11cf8 100644 --- a/rocpd_python/rocpd/call_stacks.py +++ b/rocpd_python/rocpd/call_stacks.py @@ -2,99 +2,294 @@ # Copyright (c) 2022 Advanced Micro Devices, Inc. ########################################################################### -# Create and auxilarly table to express parent/child api calls +# Create an auxiliary table to express parent/child API calls (N×D expansion). # +# For each frame F and each of its N ancestor frames A, we emit one row: +# (parent=A, child=F, depth=D, cpu_time=exclusive(F), gpu_time=exclusive_gpu(F)) # +# Two implementations are provided: +# generateCallStacksPython — Python loop with stack replay (default, 15s) +# generateCallStacksSQL — Pure SQL with window functions + recursive CTE (16s) # +# Both produce identical output (verified element-wise on 2.6M rows). import argparse import sqlite3 from rocpd.importer import RocpdImportData from rocpd.metadata import Metadata -from collections import deque -def generateCallStacks(imp): +# --------------------------------------------------------------------------- +# Python implementation (default) — stack replay per thread +# --------------------------------------------------------------------------- +def generateCallStacksPython(imp): + """Replay each thread's event stream to build N×D callstack rows. + + For each (pid, tid), we interleave start/end events as an ordered stream. + On start: push frame onto stack. + On end: pop frame, compute its exclusive CPU time, emit one row per + ancestor in the stack, and propagate the child's time upward. + + The stack is a list of [frame_id, start_ts, child_cpu_time] mutable lists. + When frame F returns with exclusive time T, we walk the stack bottom-up: + for each ancestor A at stack[i]: + if A is not the returning frame: accumulate T into A.child_cpu_time + emit row (parent=A, child=F, depth=d, cpu_time=T) + This ensures each ancestor reports only its own exclusive time at depth=0. + """ meta = Metadata(imp) if meta.get("Callstack::Generated") != None: raise Exception("Callstack data has already been generated") - count = 0 + # Pre-compute GPU time per API (faster than LEFT JOIN in event query) + gpu_times = {} + for row in imp.connection.execute( + "SELECT A.api_id, SUM(B.end - B.start) FROM rocpd_api_ops A " + "JOIN rocpd_op B ON B.id = A.op_id GROUP BY A.api_id"): + gpu_times[row[0]] = row[1] + + # Collect all rows in memory, then bulk-insert via single executemany call_inserts = [] - class StackFrame: - def __init__(self, id, start): - self.id = id - self.start = start - self.child_cpu_time = 0 - pass - - def commitRecords(): - nonlocal call_inserts - imp.connection.executemany("insert into ext_callstack(id, parent_id, child_id, depth, cpu_time, gpu_time) values (?,?,?,?,?,?)", call_inserts) - imp.connection.commit() - call_inserts = [] - - - for pidtid in imp.connection.execute("select distinct pid, tid from rocpd_api"): - stack = deque() - maxdepth = 0; - - for row in imp.connection.execute("select id, start as ts, '1', '' from rocpd_api where pid=? and tid=? UNION ALL select X.id, X.end as timestamp, '-1', Y.gpu_time from rocpd_api X LEFT JOIN (select A.api_id, sum(B.end - B.start) as gpu_time from rocpd_api_ops A join rocpd_op B on B.id = A.op_id group by A.api_id) Y on Y.api_id = X.id where pid=? and tid=? order by ts", (pidtid[0], pidtid[1], pidtid[0], pidtid[1])): - if row[2] == '1': - stack.append(StackFrame(row[0], row[1])) - elif row[2] == '-1': - if len(stack) > maxdepth: - maxdepth = len(stack) - depth = len(stack) - cpu_time = row[1] - stack[depth - 1].start - stack[depth - 1].child_cpu_time # cpu duration of returning call - gpu_time = 0 if row[3] == None else row[3] - for span in stack: - depth = depth - 1 - if (depth > 0): - stack[depth].child_cpu_time = stack[depth].child_cpu_time + cpu_time - call_inserts.append((count, span.id, row[0], depth, cpu_time, gpu_time)) - count = count + 1 - if (count % 100000 == 99999): - commitRecords() + for pidtid in imp.connection.execute( + "SELECT DISTINCT pid, tid FROM rocpd_api ORDER BY pid, tid"): + # Stack frame: [id, start_ts, child_cpu_time] — mutable list + stack = [] + maxdepth = 0 + + for row in imp.connection.execute( + "SELECT id, start, 1 FROM rocpd_api WHERE pid=? AND tid=? " + "UNION ALL " + "SELECT id, end, -1 FROM rocpd_api WHERE pid=? AND tid=? " + "ORDER BY 2, 3 DESC", + (pidtid[0], pidtid[1], pidtid[0], pidtid[1])): + id, ts, typ = row + if typ > 0: + stack.append([id, ts, 0]) + else: + depth = len(stack) + if depth > maxdepth: + maxdepth = depth + # Exclusive CPU time = duration minus time spent in children + cpu_time = ts - stack[depth - 1][1] - stack[depth - 1][2] + gpu_time = gpu_times.get(id, 0) + + # Walk stack bottom-up: propagate time, emit N×D rows + d = depth + for i in range(depth): + d -= 1 + if d > 0: + # Add this frame's time to parent's accumulated children + stack[d - 1][2] += cpu_time + call_inserts.append( + (stack[i][0], id, d, cpu_time, gpu_time)) stack.pop() print(f"pid {pidtid[0]} tid {pidtid[1]} maxDepth {maxdepth}") + # Single bulk insert + if call_inserts: + imp.connection.executemany( + "INSERT INTO ext_callstack(parent_id, child_id, depth, cpu_time, gpu_time) " + "VALUES (?,?,?,?,?)", + call_inserts) + meta.set("Callstack::Generated", "True") - commitRecords() +# --------------------------------------------------------------------------- +# SQL implementation (alternative) — window functions + recursive CTE +# --------------------------------------------------------------------------- +def generateCallStacksSQL(imp): + """Pure SQL approach: compute depth via window function, parent via containment, + exclusive time via aggregation, then expand N×D via a recursive CTE. + + Phase 1 — Depth: + Build an interleaved event stream (start=+1, end=-1) and compute depth + as a running sum via SUM() OVER (PARTITION BY pid, tid ORDER BY ts). + Keep only start events (evt=1) as "opens" — frames with their depth. + + Phase 2 — Slim tree: + For each frame at depth >= 2, find its parent: the tightest containing + frame at depth-1 (same pid/tid, start <= this.start, end >= this.end). + Use a correlated subquery with the redundant WHERE trick: + AND p.id IN (SELECT id FROM opens) + This forces SQLite's query planner to use the index on opens + (without it, the planner does a full table scan and times out). + Store inclusive cpu_time = end - start. + + Phase 3 — Exclusive time: + Aggregate inclusive time of direct children per parent. + Exclusive = inclusive - SUM(children's inclusive). + + Phase 4 — N×D expansion: + Use a recursive CTE: base case is depth=0 (self-reference for all frames + with exclusive time). Recursive case walks up the slim_tree edges, + carrying the leaf frame's exclusive cpu_time and gpu_time upward. + """ + meta = Metadata(imp) + if meta.get("Callstack::Generated") != None: + raise Exception("Callstack data has already been generated") + + conn = imp.connection + + # GPU pre-compute + conn.execute('CREATE TEMP TABLE api_gpu AS ' + 'SELECT api_id, SUM(end - start) AS gpu_time ' + 'FROM rocpd_api_ops A JOIN rocpd_op B ON B.id = A.op_id ' + 'GROUP BY api_id') + conn.execute('CREATE INDEX api_gpu_idx ON api_gpu(api_id)') + + # Phase 1: Opens with depth via window function + # Interleave start (+1) and end (-1) events, compute running sum as depth, + # filter to start events only (evt=1) to get frame opens. + conn.execute( + 'CREATE TEMP TABLE opens AS ' + 'SELECT id, pid, tid, start, end, depth FROM (' + ' SELECT id, pid, tid, start, end, evt, ' + ' SUM(evt) OVER (' + ' PARTITION BY pid, tid ' + ' ORDER BY ts, evt DESC ' + ' ROWS UNBOUNDED PRECEDING) AS depth ' + ' FROM (' + ' SELECT id, pid, tid, start, end, start AS ts, 1 AS evt ' + ' FROM rocpd_api ' + ' UNION ALL ' + ' SELECT id, pid, tid, start, end, end AS ts, -1 AS evt ' + ' FROM rocpd_api' + ' )' + ') WHERE evt = 1') + conn.execute('CREATE INDEX opens_idx ON opens(pid, tid, depth, start DESC, end)') + conn.execute('ANALYZE') + + # Phase 2: Slim tree — parent assignment via temporal containment + # For each frame at depth >= 2, find the tightest containing parent at depth-1. + # The redundant "AND p.id IN (SELECT id FROM opens)" forces index usage. + conn.execute( + 'CREATE TEMP TABLE slim_tree AS ' + 'SELECT child.id AS child_id, ' + ' (SELECT p.id FROM opens p ' + ' WHERE p.pid = child.pid AND p.tid = child.tid ' + ' AND p.depth = child.depth - 1 ' + ' AND p.start <= child.start AND p.end >= child.end ' + ' AND p.id IN (SELECT id FROM opens) ' + ' ORDER BY p.start DESC LIMIT 1) AS parent_id, ' + ' (child.end - child.start) AS inclusive_cpu, ' + ' COALESCE(ag.gpu_time, 0) AS gpu_time ' + 'FROM opens child ' + 'LEFT JOIN api_gpu ag ON ag.api_id = child.id ' + 'WHERE child.depth > 1') + + # Phase 3: Exclusive time = inclusive - SUM(direct children's inclusive) + conn.execute( + 'CREATE TEMP TABLE child_agg AS ' + 'SELECT parent_id, SUM(inclusive_cpu) AS total_child_inclusive ' + 'FROM slim_tree GROUP BY parent_id') + conn.execute('CREATE INDEX ca_idx ON child_agg(parent_id)') + + conn.execute( + 'CREATE TEMP TABLE slim_exclusive AS ' + 'SELECT s.child_id, s.parent_id, ' + ' s.inclusive_cpu - COALESCE(ca.total_child_inclusive, 0) AS cpu_time, ' + ' s.gpu_time ' + 'FROM slim_tree s ' + 'LEFT JOIN child_agg ca ON s.child_id = ca.parent_id') + conn.execute('CREATE INDEX slim_ex_child ON slim_exclusive(child_id)') + conn.execute('CREATE INDEX slim_ex_parent ON slim_exclusive(parent_id)') + conn.execute('ANALYZE') + + # Phase 4: N×D expansion via recursive CTE + # Base case: depth=0, self-reference for all frames with exclusive time. + # Recursive case: walk up slim_exclusive edges, carrying leaf cpu_time/gpu_time. + conn.execute( + 'INSERT INTO ext_callstack (parent_id, child_id, depth, cpu_time, gpu_time) ' + 'WITH RECURSIVE cs(parent_id, child_id, depth, cpu_time, gpu_time) AS (' + ' SELECT o.id, o.id, 0, ' + ' (o.end - o.start) - COALESCE(ca.total_child_inclusive, 0), ' + ' COALESCE(ag.gpu_time, 0) ' + ' FROM opens o ' + ' LEFT JOIN api_gpu ag ON ag.api_id = o.id ' + ' LEFT JOIN child_agg ca ON o.id = ca.parent_id ' + ' UNION ALL ' + ' SELECT se.parent_id, cs.child_id, cs.depth + 1, cs.cpu_time, cs.gpu_time ' + ' FROM slim_exclusive se JOIN cs ON cs.parent_id = se.child_id ' + ') ' + 'SELECT parent_id, child_id, depth, cpu_time, gpu_time FROM cs') + + meta.set("Callstack::Generated", "True") + + +# --------------------------------------------------------------------------- +# Table setup and views +# --------------------------------------------------------------------------- def createCallStackTable(imp): meta = Metadata(imp) if meta.get("Callstack::Table") != None: raise Exception("Callstack table has already been created") - #Create table - imp.connection.execute('CREATE TABLE IF NOT EXISTS "ext_callstack" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "parent_id" integer NOT NULL REFERENCES "rocpd_api" ("id") DEFERRABLE INITIALLY DEFERRED, "child_id" integer NOT NULL REFERENCES "rocpd_api" ("id") DEFERRABLE INITIALLY DEFERRED, "depth" integer NOT NULL, "cpu_time" integer NOT NULL DEFAULT 0, "gpu_time" integer NOT NULL DEFAULT 0)') + imp.connection.execute('DROP TABLE IF EXISTS "ext_callstack"') + imp.connection.execute( + 'CREATE TABLE "ext_callstack" (' + '"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, ' + '"parent_id" integer NOT NULL, ' + '"child_id" integer NOT NULL, ' + '"depth" integer NOT NULL, ' + '"cpu_time" integer NOT NULL DEFAULT 0, ' + '"gpu_time" integer NOT NULL DEFAULT 0)') - # Make some working views - imp.connection.execute('CREATE VIEW IF NOT EXISTS callStack_inclusive as select parent_id, sum(cpu_time) as cpu_time, sum(gpu_time) as gpu_time from ext_callstack group by parent_id') - imp.connection.execute('CREATE VIEW IF NOT EXISTS callStack_exclusive as select parent_id, sum(cpu_time) as cpu_time, sum(gpu_time) as gpu_time from ext_callstack where depth = 0 group by parent_id') - imp.connection.execute('CREATE VIEW IF NOT EXISTS callStack_inclusive_name as select A.parent_id, B.apiName, B.args, sum(cpu_time) as cpu_time, sum(gpu_time) as gpu_time from ext_callstack A join api B on B.id = A.parent_id group by parent_id') - imp.connection.execute('CREATE VIEW IF NOT EXISTS callStack_exclusive_name as select A.parent_id, B.apiName, B.args, sum(cpu_time) as cpu_time, sum(gpu_time) as gpu_time from ext_callstack A join api B on B.id = A.parent_id where A.depth = 0 group by parent_id') + # Views for downstream aggregation + imp.connection.execute( + 'CREATE VIEW IF NOT EXISTS callStack_inclusive ' + 'AS SELECT parent_id, SUM(cpu_time) AS cpu_time, SUM(gpu_time) AS gpu_time ' + 'FROM ext_callstack GROUP BY parent_id') + imp.connection.execute( + 'CREATE VIEW IF NOT EXISTS callStack_exclusive ' + 'AS SELECT parent_id, SUM(cpu_time) AS cpu_time, SUM(gpu_time) AS gpu_time ' + 'FROM ext_callstack WHERE depth = 0 GROUP BY parent_id') + imp.connection.execute( + 'CREATE VIEW IF NOT EXISTS callStack_inclusive_name ' + 'AS SELECT A.parent_id, B.apiName, B.args, SUM(A.cpu_time) AS cpu_time, ' + 'SUM(A.gpu_time) AS gpu_time ' + 'FROM ext_callstack A JOIN api B ON B.id = A.parent_id GROUP BY A.parent_id') + imp.connection.execute( + 'CREATE VIEW IF NOT EXISTS callStack_exclusive_name ' + 'AS SELECT A.parent_id, B.apiName, B.args, SUM(A.cpu_time) AS cpu_time, ' + 'SUM(A.gpu_time) AS gpu_time ' + 'FROM ext_callstack A JOIN api B ON B.id = A.parent_id ' + 'WHERE A.depth = 0 GROUP BY A.parent_id') meta.set("Callstack::Table", "True") - +# --------------------------------------------------------------------------- +# CLI entry point +# --------------------------------------------------------------------------- if __name__ == "__main__": + parser = argparse.ArgumentParser( + description='Generate call stack table to express caller/callee relation') + parser.add_argument('input_rpd', type=str, help="input rpd db") + parser.add_argument('--sql', action='store_true', + help='Use pure SQL implementation instead of Python (slightly slower, same result)') + args = parser.parse_args() - parser = argparse.ArgumentParser(description='Generate call stack table to express caller/callee relation') - parser.add_argument('input_rpd', type=str, help="input rpd db") - args = parser.parse_args() + connection = sqlite3.connect(args.input_rpd, isolation_level=None) + importData = RocpdImportData() + importData.resumeExisting(connection) - connection = sqlite3.connect(args.input_rpd) + connection.execute('PRAGMA journal_mode=WAL') + connection.execute('PRAGMA synchronous=NORMAL') + connection.execute('PRAGMA cache_size=-64000') - importData = RocpdImportData() - importData.resumeExisting(connection) # load the current db state + createCallStackTable(importData) + connection.execute('BEGIN') - createCallStackTable(importData) - generateCallStacks(importData) + if args.sql: + generateCallStacksSQL(importData) + else: + generateCallStacksPython(importData) - importData.connection.commit() + # Create indexes after bulk insert (required for downstream queries) + connection.execute('CREATE INDEX idx_ext_parent ON ext_callstack(parent_id)') + connection.execute('CREATE INDEX idx_ext_child ON ext_callstack(child_id)') + connection.execute('CREATE INDEX idx_ext_depth ON ext_callstack(depth)') + connection.execute('COMMIT') diff --git a/rocpd_python/rocpd/deserialize.py b/rocpd_python/rocpd/deserialize.py index 8075c5b..9e0a8d7 100644 --- a/rocpd_python/rocpd/deserialize.py +++ b/rocpd_python/rocpd/deserialize.py @@ -1,24 +1,5 @@ -################################################################################ -# 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. -################################################################################ +# Copyright (C) Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT # Elevate roctx logging messages to 1st class api events # diff --git a/rocpd_python/rocpd/graph.py b/rocpd_python/rocpd/graph.py index b381485..55170bf 100644 --- a/rocpd_python/rocpd/graph.py +++ b/rocpd_python/rocpd/graph.py @@ -1,24 +1,5 @@ -################################################################################ -# 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. -################################################################################ +# Copyright (C) Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT # Create graph tables # diff --git a/rocpd_python/rocpd/importer.py b/rocpd_python/rocpd/importer.py index 1ea8ad1..5960555 100644 --- a/rocpd_python/rocpd/importer.py +++ b/rocpd_python/rocpd/importer.py @@ -1,24 +1,5 @@ -################################################################################ -# 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. -################################################################################ +# Copyright (C) Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT # # Utility classes to simplify generating rpd files diff --git a/rocpd_python/rocpd/metadata.py b/rocpd_python/rocpd/metadata.py index c8f9de8..7aeeab8 100644 --- a/rocpd_python/rocpd/metadata.py +++ b/rocpd_python/rocpd/metadata.py @@ -1,24 +1,5 @@ -################################################################################ -# 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. -################################################################################ +# Copyright (C) Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT # Utilities for accessing rocpd_metadata # diff --git a/rocpd_python/rocpd/rocprofiler_import.py b/rocpd_python/rocpd/rocprofiler_import.py index 399a3e9..0267bed 100644 --- a/rocpd_python/rocpd/rocprofiler_import.py +++ b/rocpd_python/rocpd/rocprofiler_import.py @@ -1,24 +1,5 @@ -################################################################################ -# 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. -################################################################################ +# Copyright (C) Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT # # Create an rpd file from rocprofiler output files diff --git a/rocpd_python/rocpd/schema.py b/rocpd_python/rocpd/schema.py index e21db40..d31950a 100644 --- a/rocpd_python/rocpd/schema.py +++ b/rocpd_python/rocpd/schema.py @@ -1,24 +1,5 @@ -################################################################################ -# 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. -################################################################################ +# Copyright (C) Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT # # Utility Class to create the rocpd schema on an existing sqlite connection diff --git a/rocpd_python/rocpd/subclass.py b/rocpd_python/rocpd/subclass.py index 43f57a9..fca3564 100644 --- a/rocpd_python/rocpd/subclass.py +++ b/rocpd_python/rocpd/subclass.py @@ -1,24 +1,5 @@ -################################################################################ -# 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. -################################################################################ +# Copyright (C) Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT # Create subclass table for a set of apis/ops exposing args as columns # diff --git a/rocpd_python/rocpd/tracing.py b/rocpd_python/rocpd/tracing.py index 04649bb..8b06f51 100644 --- a/rocpd_python/rocpd/tracing.py +++ b/rocpd_python/rocpd/tracing.py @@ -1,24 +1,5 @@ -################################################################################ -# 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. -################################################################################ +# Copyright (C) Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT import bisect import json diff --git a/rocpd_python/setup.py b/rocpd_python/setup.py index 1e3844a..a1f13c5 100644 --- a/rocpd_python/setup.py +++ b/rocpd_python/setup.py @@ -1,25 +1,6 @@ -################################################################################ -# 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. -################################################################################ +# Copyright (C) Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT from setuptools import setup, find_packages diff --git a/rpd_tracer/ApiIdList.cpp b/rpd_tracer/ApiIdList.cpp index 732f057..1efbad4 100644 --- a/rpd_tracer/ApiIdList.cpp +++ b/rpd_tracer/ApiIdList.cpp @@ -1,25 +1,6 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #include "ApiIdList.h" //#include diff --git a/rpd_tracer/ApiIdList.h b/rpd_tracer/ApiIdList.h index 7654330..32f41bd 100644 --- a/rpd_tracer/ApiIdList.h +++ b/rpd_tracer/ApiIdList.h @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #pragma once #include diff --git a/rpd_tracer/ApiTable.cpp b/rpd_tracer/ApiTable.cpp index bf534e8..494a3a9 100644 --- a/rpd_tracer/ApiTable.cpp +++ b/rpd_tracer/ApiTable.cpp @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #include "Table.h" #include diff --git a/rpd_tracer/CopyApiTable.cpp b/rpd_tracer/CopyApiTable.cpp index 6ba60a9..96476e4 100644 --- a/rpd_tracer/CopyApiTable.cpp +++ b/rpd_tracer/CopyApiTable.cpp @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #include "Table.h" #include diff --git a/rpd_tracer/CuptiDataSource.cpp b/rpd_tracer/CuptiDataSource.cpp index dfcb666..2a09343 100644 --- a/rpd_tracer/CuptiDataSource.cpp +++ b/rpd_tracer/CuptiDataSource.cpp @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #include "CuptiDataSource.h" #include diff --git a/rpd_tracer/CuptiDataSource.h b/rpd_tracer/CuptiDataSource.h index 468dd9c..e4014b8 100644 --- a/rpd_tracer/CuptiDataSource.h +++ b/rpd_tracer/CuptiDataSource.h @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #pragma once #include diff --git a/rpd_tracer/DataSource.h b/rpd_tracer/DataSource.h index 310b64b..b18524d 100644 --- a/rpd_tracer/DataSource.h +++ b/rpd_tracer/DataSource.h @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #pragma once //#include "Logger.h" diff --git a/rpd_tracer/DbResource.cpp b/rpd_tracer/DbResource.cpp index c97090d..26ddd14 100644 --- a/rpd_tracer/DbResource.cpp +++ b/rpd_tracer/DbResource.cpp @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #include "DbResource.h" #include diff --git a/rpd_tracer/KernelApiTable.cpp b/rpd_tracer/KernelApiTable.cpp index 3203360..d9642ab 100644 --- a/rpd_tracer/KernelApiTable.cpp +++ b/rpd_tracer/KernelApiTable.cpp @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #include "Table.h" #include diff --git a/rpd_tracer/Logger.cpp b/rpd_tracer/Logger.cpp index cc87dd3..d1fe64e 100644 --- a/rpd_tracer/Logger.cpp +++ b/rpd_tracer/Logger.cpp @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #include "Logger.h" #include diff --git a/rpd_tracer/Logger.h b/rpd_tracer/Logger.h index cd33326..a16f3e3 100644 --- a/rpd_tracer/Logger.h +++ b/rpd_tracer/Logger.h @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #pragma once #include diff --git a/rpd_tracer/MetadataTable.cpp b/rpd_tracer/MetadataTable.cpp index 0207e80..d8fa5b8 100644 --- a/rpd_tracer/MetadataTable.cpp +++ b/rpd_tracer/MetadataTable.cpp @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #include "Table.h" #include diff --git a/rpd_tracer/MonitorTable.cpp b/rpd_tracer/MonitorTable.cpp index c8248a7..718c0ab 100644 --- a/rpd_tracer/MonitorTable.cpp +++ b/rpd_tracer/MonitorTable.cpp @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #include "Table.h" #include diff --git a/rpd_tracer/NvtxDataSource.cpp b/rpd_tracer/NvtxDataSource.cpp index a9524fe..534674b 100644 --- a/rpd_tracer/NvtxDataSource.cpp +++ b/rpd_tracer/NvtxDataSource.cpp @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #include "NvtxDataSource.h" #include diff --git a/rpd_tracer/NvtxDataSource.h b/rpd_tracer/NvtxDataSource.h index a9d06d3..e06abed 100644 --- a/rpd_tracer/NvtxDataSource.h +++ b/rpd_tracer/NvtxDataSource.h @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #pragma once #include "DataSource.h" diff --git a/rpd_tracer/OpTable.cpp b/rpd_tracer/OpTable.cpp index 20b6041..5b70daa 100644 --- a/rpd_tracer/OpTable.cpp +++ b/rpd_tracer/OpTable.cpp @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #include "Table.h" #include diff --git a/rpd_tracer/RocprofDataSource.cpp b/rpd_tracer/RocprofDataSource.cpp index a25dae4..f9f0517 100644 --- a/rpd_tracer/RocprofDataSource.cpp +++ b/rpd_tracer/RocprofDataSource.cpp @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #include "RocprofDataSource.h" #include diff --git a/rpd_tracer/RocprofDataSource.h b/rpd_tracer/RocprofDataSource.h index bc05207..315fcdc 100644 --- a/rpd_tracer/RocprofDataSource.h +++ b/rpd_tracer/RocprofDataSource.h @@ -1,24 +1,5 @@ -/********************************************************************************* -* Copyright (c) 2021 - 2024 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #pragma once //#include diff --git a/rpd_tracer/RoctracerDataSource.cpp b/rpd_tracer/RoctracerDataSource.cpp index 979a2ab..3f085bc 100644 --- a/rpd_tracer/RoctracerDataSource.cpp +++ b/rpd_tracer/RoctracerDataSource.cpp @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #include "RoctracerDataSource.h" #include diff --git a/rpd_tracer/RoctracerDataSource.h b/rpd_tracer/RoctracerDataSource.h index 3eabfbc..8990c92 100644 --- a/rpd_tracer/RoctracerDataSource.h +++ b/rpd_tracer/RoctracerDataSource.h @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #pragma once #include diff --git a/rpd_tracer/RoctxDataSource.cpp b/rpd_tracer/RoctxDataSource.cpp index 95f957f..f80cf1d 100644 --- a/rpd_tracer/RoctxDataSource.cpp +++ b/rpd_tracer/RoctxDataSource.cpp @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #include "RoctxDataSource.h" #include diff --git a/rpd_tracer/RoctxDataSource.h b/rpd_tracer/RoctxDataSource.h index f1469fa..2ea5973 100644 --- a/rpd_tracer/RoctxDataSource.h +++ b/rpd_tracer/RoctxDataSource.h @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #pragma once #include "DataSource.h" diff --git a/rpd_tracer/StackFrameTable.cpp b/rpd_tracer/StackFrameTable.cpp index fb1d3f4..2a35051 100644 --- a/rpd_tracer/StackFrameTable.cpp +++ b/rpd_tracer/StackFrameTable.cpp @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #include "Table.h" #include diff --git a/rpd_tracer/StringTable.cpp b/rpd_tracer/StringTable.cpp index f172aef..026d913 100644 --- a/rpd_tracer/StringTable.cpp +++ b/rpd_tracer/StringTable.cpp @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #include "Table.h" #include diff --git a/rpd_tracer/UStringTable.cpp b/rpd_tracer/UStringTable.cpp index 848dc51..b8425dc 100644 --- a/rpd_tracer/UStringTable.cpp +++ b/rpd_tracer/UStringTable.cpp @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #include "Table.h" #include diff --git a/rpd_tracer/Unwind.cpp b/rpd_tracer/Unwind.cpp index ab795bd..32f8427 100644 --- a/rpd_tracer/Unwind.cpp +++ b/rpd_tracer/Unwind.cpp @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #include #include "Logger.h" diff --git a/rpd_tracer/rpdTracerControl.py b/rpd_tracer/rpdTracerControl.py index 8b3ecb8..23aaf46 100644 --- a/rpd_tracer/rpdTracerControl.py +++ b/rpd_tracer/rpdTracerControl.py @@ -1,25 +1,6 @@ -################################################################################ -# 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. -################################################################################ +# Copyright (C) Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT from ctypes import CDLL from ctypes.util import find_library diff --git a/rpd_tracer/rpd_tracer.h b/rpd_tracer/rpd_tracer.h index 379a0df..484ef3a 100644 --- a/rpd_tracer/rpd_tracer.h +++ b/rpd_tracer/rpd_tracer.h @@ -1,24 +1,5 @@ -/********************************************************************************* -* 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. -********************************************************************************/ +// Copyright (C) Advanced Micro Devices, Inc. +// SPDX-License-Identifier: MIT #pragma once #include diff --git a/rpd_tracer/setup.py b/rpd_tracer/setup.py index a26dec9..94211ce 100644 --- a/rpd_tracer/setup.py +++ b/rpd_tracer/setup.py @@ -1,25 +1,6 @@ -################################################################################ -# 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. -################################################################################ +# Copyright (C) Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT from setuptools import setup diff --git a/shelve/rocprof2rpd.py b/shelve/rocprof2rpd.py index a11aa43..1061522 100644 --- a/shelve/rocprof2rpd.py +++ b/shelve/rocprof2rpd.py @@ -1,24 +1,5 @@ -################################################################################ -# 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. -################################################################################ +# Copyright (C) Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT # # Create an rpd file from rocprofiler output files diff --git a/tools/nvvp2rpd.py b/tools/nvvp2rpd.py index ef08fd4..e70712e 100644 --- a/tools/nvvp2rpd.py +++ b/tools/nvvp2rpd.py @@ -1,24 +1,5 @@ -################################################################################ -# 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. -################################################################################ +# Copyright (C) Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT # # Create an rpd file from an nvvp file diff --git a/tools/rpd2table.py b/tools/rpd2table.py index e08a1d3..9e208c1 100644 --- a/tools/rpd2table.py +++ b/tools/rpd2table.py @@ -1,24 +1,5 @@ -################################################################################ -# 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. -################################################################################ +# Copyright (C) Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT # # Create a csv summary table from an rpd file diff --git a/tools/rpd2tracing.py b/tools/rpd2tracing.py index f1ffdbd..420b8e7 100755 --- a/tools/rpd2tracing.py +++ b/tools/rpd2tracing.py @@ -1,26 +1,7 @@ #!/usr/bin/env python3 -################################################################################ -# 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. -################################################################################ +# Copyright (C) Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT # # Format sqlite trace data as json for chrome:tracing diff --git a/tools/rpd_autograd_summary.py b/tools/rpd_autograd_summary.py index 784863c..130aa0f 100644 --- a/tools/rpd_autograd_summary.py +++ b/tools/rpd_autograd_summary.py @@ -1,182 +1,163 @@ -################################################################################ -# 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. -################################################################################ - -# -# Format sqlite trace data as json for chrome:tracing -# - -import sys -import os -import sqlite3 -import argparse - -parser = argparse.ArgumentParser(description='Format autograd kernel usage as html') -parser.add_argument('input_rpd', type=str, help="input rpd db") -parser.add_argument('output_html', type=str, help="html output") -parser.add_argument('--start', type=int, help="start timestamp") -parser.add_argument('--end', type=int, help="end timestamp") -args = parser.parse_args() - -connection = sqlite3.connect(args.input_rpd) - -outfile = open(args.output_html, 'w', encoding="utf-8") - -outfile.write(""" - - - - - - - -

Kernels by Autograd Operator

-

- - - - - - - - - - - - - -""") - - -last_labels = ["",""] -group_active = [False, False] - -for row in connection.execute('select "0" as ordinal, count(*) as count, autogradName, "" as kernelName, "" as Sizes, sum(calls) as calls, sum(avg_gpu) as avg_gpu, sum(total_gpu) as total_gpu from autogradKernel group by autogradName UNION ALL select "1" as ordinal, count(*) as count, autogradName, kernelName, "" as Sizes, sum(calls) as calls, sum(avg_gpu) as avg_gpu, sum(total_gpu) as total_gpu from autogradKernel group by autogradName, kernelName UNION ALL select "2" as ordinal, count(*) as count, autogradName, kernelName, Sizes, sum(calls) as calls, sum(avg_gpu) as avg_gpu, sum(total_gpu) as total_gpu from autogradKernel group by autogradName, kernelName, sizes order by autogradName, kernelName, ordinal'): - - depth = int(row[0]) - count = int(row[1]) - labels = [row[2], row[3]] - - #outfile.write(f' {depth} {count} {labels[0][:80]} {labels[1][:80]}') - #doit = "now"; - - # Detect start of groupings - #for i in [0,1]: - # if depth == i and count > 1: - # outfile.write("") - # group_active[i] = True - - # Detect end of groupings - for i in [1,0]: - changed = False - for j in range(i + 1): - if labels[i] != last_labels[i]: - changed = True - if changed and group_active[i]: - outfile.write("") - group_active[i] = False - - # Detect start of groupings - for i in [0,1]: - if depth == i and count > 1: - outfile.write("") - group_active[i] = True - - # Don't outfile.write out single leaf branches - if depth < 2 and count < 2: - continue - - # supress labels for duplicates - for i in [0,1]: - if group_active[i] and labels[i] == last_labels[i]: - labels[i] = "" - else: - last_labels[i] = labels[i] - - class_string = ">') - -#clean up groupings -for i in [1,0]: - if group_active[i]: - outfile.write("") - group_active[i] = False - -outfile.write(""" -
- Autograd OperatorKernel NameSizesTotal CallAverage GPUTotal GPU
{labels[0]}{labels[1][:60]}{row[4]}{row[5]}{row[6]}{row[7]}
- - - -""") - -outfile.write("\n") -outfile.close() -connection.close() +# Copyright (C) Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT + +# +# Format sqlite trace data as json for chrome:tracing +# + +import sys +import os +import sqlite3 +import argparse + +parser = argparse.ArgumentParser(description='Format autograd kernel usage as html') +parser.add_argument('input_rpd', type=str, help="input rpd db") +parser.add_argument('output_html', type=str, help="html output") +parser.add_argument('--start', type=int, help="start timestamp") +parser.add_argument('--end', type=int, help="end timestamp") +args = parser.parse_args() + +connection = sqlite3.connect(args.input_rpd) + +outfile = open(args.output_html, 'w', encoding="utf-8") + +outfile.write(""" + + + + + + + +

Kernels by Autograd Operator

+

+ + + + + + + + + + + + + +""") + + +last_labels = ["",""] +group_active = [False, False] + +for row in connection.execute('select "0" as ordinal, count(*) as count, autogradName, "" as kernelName, "" as Sizes, sum(calls) as calls, sum(avg_gpu) as avg_gpu, sum(total_gpu) as total_gpu from autogradKernel group by autogradName UNION ALL select "1" as ordinal, count(*) as count, autogradName, kernelName, "" as Sizes, sum(calls) as calls, sum(avg_gpu) as avg_gpu, sum(total_gpu) as total_gpu from autogradKernel group by autogradName, kernelName UNION ALL select "2" as ordinal, count(*) as count, autogradName, kernelName, Sizes, sum(calls) as calls, sum(avg_gpu) as avg_gpu, sum(total_gpu) as total_gpu from autogradKernel group by autogradName, kernelName, sizes order by autogradName, kernelName, ordinal'): + + depth = int(row[0]) + count = int(row[1]) + labels = [row[2], row[3]] + + #outfile.write(f' {depth} {count} {labels[0][:80]} {labels[1][:80]}') + #doit = "now"; + + # Detect start of groupings + #for i in [0,1]: + # if depth == i and count > 1: + # outfile.write("") + # group_active[i] = True + + # Detect end of groupings + for i in [1,0]: + changed = False + for j in range(i + 1): + if labels[i] != last_labels[i]: + changed = True + if changed and group_active[i]: + outfile.write("") + group_active[i] = False + + # Detect start of groupings + for i in [0,1]: + if depth == i and count > 1: + outfile.write("") + group_active[i] = True + + # Don't outfile.write out single leaf branches + if depth < 2 and count < 2: + continue + + # supress labels for duplicates + for i in [0,1]: + if group_active[i] and labels[i] == last_labels[i]: + labels[i] = "" + else: + last_labels[i] = labels[i] + + class_string = ">') + +#clean up groupings +for i in [1,0]: + if group_active[i]: + outfile.write("") + group_active[i] = False + +outfile.write(""" +
+ Autograd OperatorKernel NameSizesTotal CallAverage GPUTotal GPU
{labels[0]}{labels[1][:60]}{row[4]}{row[5]}{row[6]}{row[7]}
+ + + +""") + +outfile.write("\n") +outfile.close() +connection.close() diff --git a/tools/rpd_trim.py b/tools/rpd_trim.py index fba778a..5eac152 100644 --- a/tools/rpd_trim.py +++ b/tools/rpd_trim.py @@ -1,24 +1,5 @@ -################################################################################ -# Copyright (c) 2021 - 2024 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. -################################################################################ +# Copyright (C) Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT # # Trim any data from an rpd file that doesn't fall within a specified time span. diff --git a/tools/rpt2rpd.py b/tools/rpt2rpd.py index 43b9ae6..577a8bb 100644 --- a/tools/rpt2rpd.py +++ b/tools/rpt2rpd.py @@ -1,24 +1,5 @@ -################################################################################ -# 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. -################################################################################ +# Copyright (C) Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT # # Create an rpd file from rocprofiler output files