Skip to content

Add function args serialization to RCCL buffer records #184

Closed
systems-assistant[bot] wants to merge 8 commits into
developfrom
import/develop/ROCm_rocprofiler-sdk/mkuriche_rccl-api-args
Closed

Add function args serialization to RCCL buffer records #184
systems-assistant[bot] wants to merge 8 commits into
developfrom
import/develop/ROCm_rocprofiler-sdk/mkuriche_rccl-api-args

Conversation

@systems-assistant

Copy link
Copy Markdown
Contributor

PR Details

Adds RCCL function parameter serialization. Requested by RCCL team.

No ticket yet, but they asked if nvtx ranges were supported. This request is not in this ticket / pr, but wanted to add this here.

Associated Jira Ticket Number/Link

SWDEV-528449
SWDEV-527517

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update
  • Continuous Integration

Technical details

Adds RCCL function parameter serialization

Added/updated tests?

  • Yes
  • No, Does not apply to this PR.

Updated CHANGELOG?

  • Yes
  • No, Does not apply to this PR.

Added/Updated documentation?

  • Yes
  • No, Does not apply to this PR.

🔁 Imported from ROCm/rocprofiler-sdk#129
🧑‍💻 Originally authored by @rocm-devops

abchoudh-amd pushed a commit that referenced this pull request Aug 8, 2025
* Initialize extremes to max and min values

* Address review comment

* Adding clang format

[ROCm/rocprofiler-sdk commit: 90ae424]
jayhawk-commits pushed a commit that referenced this pull request Aug 18, 2025
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Aug 26, 2025
@MythreyaK
MythreyaK force-pushed the import/develop/ROCm_rocprofiler-sdk/mkuriche_rccl-api-args branch 10 times, most recently from a942283 to 6e78ba0 Compare September 8, 2025 20:45
@MythreyaK
MythreyaK force-pushed the import/develop/ROCm_rocprofiler-sdk/mkuriche_rccl-api-args branch from 6e78ba0 to 67fdb0c Compare September 9, 2025 20:05
@bgopesh bgopesh added the WIP label Sep 16, 2025
@MythreyaK

Copy link
Copy Markdown
Member

PR waiting for IOMMU support on CI.

ammallya pushed a commit that referenced this pull request Jan 21, 2026
@jrmadsen

Copy link
Copy Markdown
Contributor

@MythreyaK Can we update this PR?

@MythreyaK

Copy link
Copy Markdown
Member

Closing, will reopen with a rebase/updates soon.

@MythreyaK MythreyaK closed this May 7, 2026
@MythreyaK

Copy link
Copy Markdown
Member

(do not delete branch)

dgaliffiAMD added a commit that referenced this pull request Jun 27, 2026
…7618)

## Motivation

<!-- Explain the purpose of this PR and the goals it aims to achieve.
-->

This is the improved other half of #6116

`ROCPROFSYS_TRACE_LEGACY` encodes information that is missing from debug
args when trace cache is used. For example, with `pthread_create`, we
currently see:
<img width="764" height="105" alt="image"
src="https://github.com/user-attachments/assets/5b21f817-565f-4628-b546-787d3c51c3a2"
/>

But with `ROCPROFSYS_TRACE_LEGACY=ON`, we see:
<img width="766" height="198" alt="image"
src="https://github.com/user-attachments/assets/b591831e-c867-475c-ac44-908ae9588495"
/>

There is a clear disconnect.

## Technical Details

<!-- Explain the changes along with any relevant GitHub links. -->
`category_region.hpp`
Cache gotcha/perfetto region arguments into the trace cache.
Category-independent helpers now live in a policy-templated helper
`rocprofsys::utility::category_region<Policy>`, composed by
`category_region<CategoryT>` via using `region_cache =
utility::category_region<>`. The cache lifecycle's system seams (clock,
trace-cache sink, thread metadata) are injected as value members through
a Policy bundle

- `serialize_name_value_pairs`: serializes the gotcha {"name", value}
pairs into the wire format (idx;;type;;name;;value;;).
- `serialize_annotation_args / serialize_return_arg`: serialize gotcha
audit arguments (synthesized arg{N}-{type} names) and return values.
- `has_trace_cache_arg_pairs_v`: detects the gotcha pair convention
(even count, string-like name slots).
- `next_arg_index`: derives the next index from the last record instead
of storing a count.
- `renumber_serialized_args`: renumbers an appended batch in a single
string pass.
- The above are static helpers; the stateful cache lifecycle
(`cache_start` / `cache_stop` / `append_cache_args` /
`flush_pending_cached_entries`) are instance methods reached through a
per-thread `instance()`.
- `append_cache_args`: appends a batch to the open entry (adopts the
first batch as-is, else renumbers).
 - `start / start_with_args` now funnel through one start_impl.
- Hooked gotcha audit incoming/outgoing paths to cache argument and
return values.

`regions.cpp`:
 -  Adjust `flush` call signature.

Added unit tests

Added pytests
- two new binaries: `annotations.cpp` and `pthread.cpp`. The first tests
perfetto annotations and the second verifies that gotcha arguments are
captured.
 - Both ROCpd and perfetto outputs are verified.

**OTHER**
`test_shmem_gotcha.cpp`: Drop `name` and `[this]`. It was causing
workflow to fail:

https://github.com/ROCm/rocm-systems/actions/runs/27972186388/job/82780906185

## JIRA ID

<!-- If applicable, mention the JIRA ID resolved by this PR (Example:
Resolves SWDEV-12345). -->
<!-- Do not post any JIRA links here. -->

Jira ID : AIPROFSYST-519

## Test Plan

New unit tests
New pytests:
```
minimal-pthreads-binary-rewrite
minimal-pthreads-runtime-instrument
minimal-pthreads-sys-run
```

<!-- Explain any relevant testing done to verify this PR. -->

## Test Result

Unit tests pass:
```
Note: Google Test filter = category_region*
[==========] Running 29 tests from 3 test suites.

...

[----------] Global test environment tear-down
[==========] 38 tests from 4 test suites ran. (0 ms total)
[  PASSED  ] 38 tests.
```
New pytests pass:
```
    Start 182: minimal-pthreads-binary-rewrite
2/5 Test #182: minimal-pthreads-binary-rewrite .......   Passed    5.19 sec
    Start 183: minimal-pthreads-runtime-instrument
3/5 Test #183: minimal-pthreads-runtime-instrument ...   Passed    6.69 sec
    Start 184: minimal-pthreads-sys-run
4/5 Test #184: minimal-pthreads-sys-run ..............   Passed    2.14 sec
```

For `pthreads`:
<img width="817" height="209" alt="image"
src="https://github.com/user-attachments/assets/fa1330b8-aab7-4141-bb85-96d789da1f6e"
/>


<!-- Briefly summarize test outcomes. -->

## Submission Checklist

- [x] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.

---------

Co-authored-by: David Galiffi <David.Galiffi@amd.com>
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.

6 participants