Skip to content

[rocprofiler-sdk] Enable region argument annotation in perfetto output trace#3854

Open
mcao59 wants to merge 11 commits intodevelopfrom
users/mcao/perfetto_event_id
Open

[rocprofiler-sdk] Enable region argument annotation in perfetto output trace#3854
mcao59 wants to merge 11 commits intodevelopfrom
users/mcao/perfetto_event_id

Conversation

@mcao59
Copy link
Copy Markdown
Member

@mcao59 mcao59 commented Mar 7, 2026

Motivation

This PR enables function argument annotation in Perfetto with --annotate-args.
Without info like event ID arg value, it may be hard to follow event dependencies and debug HIP event synchronization.
The goal is disambiguating waits across multiple events/streams: when a stream waits on different events originating from different streams, having the event ID allows them to correlate hipStreamWaitEvent with the corresponding hipEventRecord calls and identify which event (and thus which upstream stream/work) is actually blocking execution.

With this PR: When --annotate-args (introduced in #340) is used in rocpd to perfetto conversion, the function arguments get annotated

Technical Details

  • Enabling arg annotation in perfetto.cpp:
  • Tests
    • added separate execution and validation tests for perfetto output converted with --annotate-args
    • Test checks for annotations. Test will fail if expected annotations are not found

JIRA ID

Resolves AIPROFSDK-195

Test Plan

Local testing:

$ pytest -s validate_annotations.py   --pftrace-input=rocpd-output-data-annotations/out_results.pftrace 
===== test session starts =====
platform linux -- Python 3.10.12, pytest-9.0.2, pluggy-1.6.0
rootdir: /home/mcao/my_proj/rocm-systems/projects/rocprofiler-sdk/tests/rocprofv3/rocpd
configfile: pytest.ini
plugins: metadata-3.1.1, json-report-1.5.0, allure-pytest-2.15.3, rerunfailures-16.1
collected 1 item                                                                                                                                                                                                                                                     

../../../../projects/rocprofiler-sdk/tests/rocprofv3/rocpd/validate_annotations.py 
Validation passed: Found 14019 argument annotations
  - 11 unique API calls annotated
  - 1 categories: ['hip_api']
  - 12 unique argument types
  - Sample argument names: ['debug.count', 'debug.deviceId', 'debug.stream', 'debug.event', 'debug.function_address', 'debug.numBlocks', 'debug.dimBlocks', 'debug.args', 'debug.sharedMemBytes', 'debug.ms']
.

====== PASSES =====
 ======slowest 20 durations =========
3.25s setup    validate_annotations.py::test_arg_annotations
2.96s call     validate_annotations.py::test_arg_annotations

(1 durations < 0.005s hidden.  Use -vv to show these durations.)
===== short test summary info =====
PASSED ../../../../projects/rocprofiler-sdk/tests/rocprofv3/rocpd/validate_annotations.py::test_arg_annotations
====== 1 passed in 6.21s =====

Test Result

hipevent_latest

Submission Checklist

@mcao59 mcao59 requested review from a team as code owners March 7, 2026 04:12
@mcao59 mcao59 force-pushed the users/mcao/perfetto_event_id branch 2 times, most recently from fd77ad6 to bb0e3fe Compare March 11, 2026 23:36
@mcao59 mcao59 force-pushed the users/mcao/perfetto_event_id branch from bb0e3fe to 88e23bf Compare March 12, 2026 20:10
@mcao59 mcao59 force-pushed the users/mcao/perfetto_event_id branch from 88e23bf to 239c4c9 Compare March 16, 2026 21:46
Copy link
Copy Markdown
Contributor

@yhuiYH yhuiYH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. CI tests are queued because the pool has been re-purposed. But it was passing before and I checked the tests locally, seems to be passing.

@mcao59 mcao59 changed the title [rocprofiler-sdk] Add Event ID in perfetto output trace [rocprofiler-sdk] Add Event ID in perfetto output trace for HIP event APIs Mar 17, 2026
Copy link
Copy Markdown
Contributor

@jrmadsen jrmadsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just annotate all the rocpd_args associated with the event_id? Wouldn't this include the event handle?

@mcao59 mcao59 force-pushed the users/mcao/perfetto_event_id branch from 4a2cee2 to 8137764 Compare March 17, 2026 21:56
@mcao59
Copy link
Copy Markdown
Member Author

mcao59 commented Mar 17, 2026

Why not just annotate all the rocpd_args associated with the event_id? Wouldn't this include the event handle?

@jrmadsen sure, please see enable arg annotation for all instead of only event ID. Updated tests as well to validate --annotate-args

@mcao59 mcao59 changed the title [rocprofiler-sdk] Add Event ID in perfetto output trace for HIP event APIs [rocprofiler-sdk] Enable argument annotation in perfetto output trace Mar 17, 2026
@mcao59 mcao59 changed the title [rocprofiler-sdk] Enable argument annotation in perfetto output trace [rocprofiler-sdk] Enable region argument annotation in perfetto output trace Mar 17, 2026
@mcao59 mcao59 force-pushed the users/mcao/perfetto_event_id branch 2 times, most recently from 1fe0a46 to ca1ea6e Compare March 18, 2026 15:33
@mcao59 mcao59 force-pushed the users/mcao/perfetto_event_id branch 3 times, most recently from 486c4da to d8d4995 Compare March 26, 2026 16:25
@mcao59 mcao59 force-pushed the users/mcao/perfetto_event_id branch from 23ce49d to a043db3 Compare March 31, 2026 15:33
@ammarwa ammarwa requested review from jrmadsen and yhuiYH March 31, 2026 15:37
@mcao59 mcao59 removed the request for review from yhuiYH April 1, 2026 15:38
@mcao59 mcao59 force-pushed the users/mcao/perfetto_event_id branch from a043db3 to bdd2285 Compare April 1, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants