Skip to content

docs(rocprofiler-sdk): note why kernel replay keeps restoring constant symbols - #12605

Closed
amd-vkale wants to merge 4 commits into
developfrom
users/vkale/kr-perf-1-skip-constant-symbols--with-cursor-help
Closed

amd-vkale wants to merge 4 commits into
developfrom
users/vkale/kr-perf-1-skip-constant-symbols--with-cursor-help

Conversation

@amd-vkale

Copy link
Copy Markdown
Contributor

First PR of the kernel replay host-side perf stack: leave constant symbols out of the snapshot, since kernels cannot write them and restoring them can fault read-only pages. JIRA AIPROFSDK-68.

cursoragent and others added 2 commits October 1, 2026 00:42
Co-authored-by: Vivek Kale <vivek.kale@amd.com>
(cherry picked from commit c61850d)
…apshot test kernels

Co-authored-by: Vivek Kale <vivek.kale@amd.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation project: rocprofiler-sdk labels Oct 1, 2026
@therock-pr-bot

therock-pr-bot Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

❌ PR Check — Action Required

Check Status Details
📝 PR Description ❌ Fail Error: PR description must reference a JIRA ID, ISSUE ID, or a GitHub closing keyword.
Expected: include a JIRA ID / ISSUE ID line (separator : or -, or omitted; value may be a JIRA key, a number with/without #, or a link), OR a closing keyword + issue reference. Accepted examples:
• JIRA ID : TESTAUTO-6039
• JIRA ID - #330
• JIRA ID #330
• JIRA ID (on separate line)
ROCM-25757
• ISSUE ID : TESTUTO-3334
• ISSUE ID #3334
• ISSUE ID - TESTAUTO-3433
• ISSUE ID (on separate line)
AIRUNTIME-2352
• ISSUE ID : https://github.com/<org_name>/<repo_name>/issues/1234
• Closes #10
• Fixes octo-org/octo-repo#100
• Resolves: #123
• #123
• https://github.com/<org_name>/<repo_name>/issues/123
Current: no valid JIRA/ISSUE/closing-keyword reference found
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ⚠️ Warning Error: Source/code files changed without an accompanying unit test.
Expected: add at least one test file named like test_<name>.py / test_<name>.cpp (or <name>_test.*).
Current: code file(s) changed: projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/kernel_replay/memory_snapshot.cpp; no test file found
🔎 pre-commit ⏳ Pending ⏳ Still running…
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —

⚠️ 1 policy check(s) failed. Please address the issues above before this PR can be Reviewed.

🚫 Please fix the failed policies

  • ❌ PR Description

The Not ready to Review label was added to this PR. Once all policies pass, the label is removed automatically.

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

@therock-pr-bot

therock-pr-bot Bot commented Oct 1, 2026

Copy link
Copy Markdown

🚫 Please fix the failed policies before requesting reviews.

The following policy checks failed:

  • ❌ PR Description

The Not ready to Review label has been added to this PR.
Once all policies pass, the label will be removed automatically.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The repository’s ROCr reports the constant attribute with inverted semantics, causing the filter to skip writable globals while retaining non-writable symbols.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Updates kernel replay snapshots to exclude constant symbols, aiming to avoid restoring data to protected GPU pages.

Changes:

  • Adds filtering based on the HSA constant-symbol attribute.
  • Adds a constant-symbol fixture and exclusion regression test.
  • Updates snapshot documentation and API guidance.
File Description
projects/​rocprofiler-sdk/​source/​lib/​rocprofiler-sdk/​kernel_replay/​tests/​snap_restore.cpp Tests constant exclusion and restore.
projects/​rocprofiler-sdk/​source/​lib/​rocprofiler-sdk/​kernel_replay/​tests/​snap_kernels.hpp Declares the constant-address helper.
projects/​rocprofiler-sdk/​source/​lib/​rocprofiler-sdk/​kernel_replay/​tests/​snap_kernels.cpp Adds the constant fixture and helper.
projects/​rocprofiler-sdk/​source/​lib/​rocprofiler-sdk/​kernel_replay/​memory_snapshot.hpp Documents writable-only module capture.
projects/​rocprofiler-sdk/​source/​lib/​rocprofiler-sdk/​kernel_replay/​memory_snapshot.cpp Filters symbols using constant metadata.
projects/​rocprofiler-sdk/​source/​include/​rocprofiler-sdk/​experimental/​kernel_replay.h Updates public snapshot guidance.
projects/​rocprofiler-sdk/​source/​docs/​how-to/​using-rocprofv3.rst Revises CLI snapshot limitations.
projects/​rocprofiler-sdk/​source/​docs/​how-to/​using-kernel-replay.rst Clarifies restored memory categories.
projects/​rocprofiler-sdk/​source/​docs/​how-to/​using-kernel-replay-rocprofv3.rst Documents constant exclusion.
projects/​rocprofiler-sdk/​source/​docs/​conceptual/​kernel_replay/​kernel_replay_memory_snapshot.md Explains symbol filtering.
projects/​rocprofiler-sdk/​CHANGELOG.md Updates snapshot coverage notes.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Revert the HSA_EXECUTABLE_SYMBOL_INFO_VARIABLE_IS_CONST filter from
02c1fdd, and the test-kernel alignment from 08b2ce0 that came with
it. ROCr reports that attribute inverted: Symbol::IsConst() returns true
when the ELF section has SHF_WRITE. HIP places __device__ globals in
.data/.bss and __constant__ ones in .rodata, so the filter dropped the
writable globals that replay must restore and kept the constants. CI
failed the four module-variable snapshot unit tests and both kernel
replay generate tests in every job.

Restoring constants is harmless: on MI325 the exclusion test's restore()
succeeded with the __constant__ fixture still in the snapshot. Leave a
comment so the attribute is not used for this again.

Co-authored-by: Vivek Kale <vivek.kale@amd.com>
@cursor cursor Bot changed the title fix(rocprofiler-sdk): skip constant symbols during kernel replay restore docs(rocprofiler-sdk): note why kernel replay keeps restoring constant symbols Oct 5, 2026
@amd-vkale

Copy link
Copy Markdown
Contributor Author

@copilot Fix the code for all comments in this review thread.

When a review comment includes a suggested change, apply the suggestion exactly.

Do not make changes beyond what is described in the linked review thread.

Co-authored-by: amd-vkale <291155109+amd-vkale@users.noreply.github.com>

Copilot AI commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

@copilot Fix the code for all comments in this review thread.

When a review comment includes a suggested change, apply ...

Updated module-variable filtering to use HSA_VARIABLE_SEGMENT_READONLY instead of VARIABLE_IS_CONST, and fail closed if segment data is unavailable or unrecognized. Commit: 5072c178.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

The conflicting scope and safety claims need author clarification before approval.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
Resolved since last review (1)


if(kind != HSA_SYMBOL_KIND_VARIABLE) return HSA_STATUS_SUCCESS;

// __constant__ variables are captured too; restoring them is harmless. Do not skip them via
cursor Bot pushed a commit that referenced this pull request Oct 6, 2026
…constant comment

Where __constant__ variables land depends on the compiler. Ubuntu clang 18
puts a __constant__ int in .data, but the amdclang++ 23 that CI builds with
puts it in a non-writable section: on #12605 the IS_CONST filter left the
excludes_read_only_module_constant fixture in the snapshot, which only
happens when its section lacks SHF_WRITE.

Neither placement sets SHF_AMDGPU_HSA_READONLY, so the comment's reasons
for not filtering on IS_CONST or VARIABLE_SEGMENT hold either way. State
those reasons without the placement claim.

Co-authored-by: Vivek Kale <vivek.kale@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.

4 participants