Skip to content

[rocprofiler-sdk] : report SPM shader array and WGP dimensions - #12212

Merged
sauverma93 merged 5 commits into
developfrom
users/sauverma/spm-sa-wgp
Oct 13, 2026
Merged

sauverma93 merged 5 commits into
developfrom
users/sauverma/spm-sa-wgp

Conversation

@sauverma93

@sauverma93 sauverma93 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

gfx1250 SPM samples deliver shader-engine topology as one packed integer, (wgp << 24) | (sa << 16) | se. The SDK decode path treated that integer as a shader-engine index and dropped the shader array and workgroup processor.

Technical Details

  • Decode the packed value with aqlprofile_spm_decode_shader_engine() and store shader array and workgroup processor on the SPM sample.
  • Encode both into the counter instance id, next to XCC, shader engine, and instance.
  • Agents without packed topology report shader array 0 and workgroup processor 0. Global samples leave both unset.
  • Allow gfx1250 in the aqlprofile SPM event-support check and enable the SPM test suite for gfx1250.
  • This pull request does not change the rocPD schema, views, or CSV. Recording shader array and workgroup processor in rocPD is [rocprofiler-sdk] : rocpd changes; Store SPM counter location on rocpd_info_pmc. #12913.

Issue Tracking

ISSUE ID: AIPROFSDK-1151

Test Plan

  • spm_core.decode_shader_topology: packed (wgp=2, sa=1, se=3), plain shader engine 4 (shader array 0, workgroup processor 0), and global -1.
  • On gfx1250 hardware: confirm decoded shader-array and workgroup-processor values, and that existing SPM rocpd and JSON tests still pass.

Test Result

Local unit test spm_core.decode_shader_topology passed. Validated on gfx1250: decoded shader-array and workgroup-processor values are reported, and the existing SPM rocpd and JSON tests pass.

Submission Checklist

gfx1250 follow-up

Three existing SPM integration tests fail on gfx1250. The JSON tool requests two TA counters, and validate.py requires both, but gfx1250 has no metric definition for them, so they never appear in the samples. This will be addressed in a later PR.

Test
775 tests.integration.validate.test-spm-dispatch-collection-validate.test_spm_counter_values
776 tests.integration.validate.test-spm-dispatch-collection-validate.test_spm_counter_consistency
778 tests.integration.validate.test-spm-dispatch-buffer-collection-validate.test_spm_counter_values
Counter What it counts Known event gfx1250
TA_TA_BUSY TA block is busy Block TA, event 15 on gfx12 / gfx1200 / gfx1201. Event 13 on gfx940–gfx950 No metric definition
TA_TOTAL_WAVEFRONTS Total wavefronts processed by TA Block TA, event 32 on gfx908 / gfx90a. Event 29 on gfx940–gfx950 No metric definition on gfx12 or gfx1250

gfx1250 does not reuse the gfx1201 event numbers. SQC_ICACHE_REQ is event 301 on gfx1201 and event 641 on gfx1250, so a gfx1250 TA_TA_BUSY needs its own TA event ID from the MI450 docs.

These three counters were collected and are not the problem: SQC_ICACHE_REQ, SQC_ICACHE_HITS, SQC_ICACHE_MISSES.

Base automatically changed from users/bingma/gfx12-spm-support-aqlprofile to develop September 24, 2026 20:07
@therock-pr-bot

therock-pr-bot Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

✅ All Policy Checks Passed

Check Status Details
📝 PR Description ✅ Pass —
⛔ 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/aqlprofile/core/spm_v2.cpp, projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/spm/decode.cpp, projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/spm/decode.hpp, projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/spm/interface.cpp, projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/spm/interface.hpp (+2 more); no test file found
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —

🎉 All policy checks passed!

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

🙋 Wish to Override Policy?

@therock-pr-bot

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.

@sauverma93
sauverma93 force-pushed the users/sauverma/spm-sa-wgp branch from 5df993f to 7782227 Compare September 28, 2026 14:55
@sauverma93
sauverma93 added this pull request to stack #12455 September 29, 2026 08:13
@sauverma93
sauverma93 marked this pull request as ready for review September 29, 2026 11:34
@sauverma93
sauverma93 requested review from a team as code owners September 29, 2026 11:34
@sauverma93 sauverma93 changed the title report SPM shader array and WGP dimensions [rocprofiler-sdk] report SPM shader array and WGP dimensions Sep 29, 2026
@sauverma93 sauverma93 changed the title [rocprofiler-sdk] report SPM shader array and WGP dimensions [rocprofiler-sdk] : report SPM shader array and WGP dimensions Sep 29, 2026
@sauverma93
sauverma93 force-pushed the users/sauverma/spm-sa-wgp branch 2 times, most recently from 68c538e to 68f3d6b Compare October 10, 2026 10:10
@sauverma93
sauverma93 force-pushed the users/sauverma/spm-sa-wgp branch from 6747cda to d1d6f1f Compare October 12, 2026 05:14
@sauverma93
sauverma93 force-pushed the users/sauverma/spm-sa-wgp branch 2 times, most recently from c542317 to 3c3933f Compare October 12, 2026 16:41

@SrirakshaNag SrirakshaNag 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.

Please address the one comment and with that addressed it looks good to me

@bing-ma bing-ma 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.

I second Sriraksha’s latest comment. spm/tests/device_counting.cpp looks stale relative to the current support expansion.

@sauverma93
sauverma93 force-pushed the users/sauverma/spm-sa-wgp branch 2 times, most recently from 1247347 to d0ef6ea Compare October 12, 2026 20:42
@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage Report

Code Coverage Report

Tests Only

code coverage tests.png

Samples Only

code coverage samples.png

Tests + Samples

code coverage all.png

@bing-ma bing-ma 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.

Looks good to me.

@sauverma93
sauverma93 force-pushed the users/sauverma/spm-sa-wgp branch from d0ef6ea to fbe5ecf Compare October 13, 2026 00:40
gfx1250 SPM samples deliver a packed shader_engine value
(wgp << 24 | sa << 16 | se) rather than a plain shader-engine index, so
the SDK decode path reported packed values as shader engines and dropped
the shader-array and WGP topology entirely.

Decode the value with aqlprofile_spm_decode_shader_engine(), carry the
shader array and WGP on spm_sample_t, and encode both into the counter
instance id alongside XCC, shader engine, and instance. The dimensions
are persisted as shader_array and wgp columns on rocpd_pmc_event,
exposed through the spm_counters view, and included in the rocpd CSV
counter name as counter_name[XCC:, Instance:, SE:, SA:, WGP:].

Agents without packed topology decode to shader array 0 and WGP 0;
global samples leave both dimensions unset.

Lift the aqlprofile gfx1250 SPM event-support gate and enable the SPM test
suite for gfx1250 now that the SDK consumes the packed encoding.

Add a spm_core unit test covering packed, shader-engine-only, and global
decode, and extend the rocprofv3 SPM rocpd validation to assert the new
columns and the CSV counter-name format.
The shared GFX12 id is supported in aqlprofile, and the SPM tests run on those GPUs alongside gfx1250.
@sauverma93
sauverma93 force-pushed the users/sauverma/spm-sa-wgp branch from fbe5ecf to c8b1bfd Compare October 13, 2026 13:08
@sauverma93
sauverma93 merged commit 45df1af into develop Oct 13, 2026
209 of 215 checks passed
@sauverma93
sauverma93 deleted the users/sauverma/spm-sa-wgp branch October 13, 2026 17:02
@sauverma93
sauverma93 restored the users/sauverma/spm-sa-wgp branch October 13, 2026 17:05
venkat1361 added a commit that referenced this pull request Oct 14, 2026
…d_info_pmc. (#12913)

## Summary

rocPD layout for SPM shader array (SA) and workgroup processor (WGP).
The rocPD changes live in this pull request.
#12212 decodes the dimensions and does not change rocPD.

gfx1250 SPM samples pack those dimensions into `shader_engine` as `(wgp
<< 24) | (sa << 16) | se`. #12212 decodes that into a shader engine, a
shader array, and a WGP, and carries them with XCC and instance on the
SPM sample and the counter instance id. A decoded 0 is a real index when
the counter has that dimension. A dimension the counter does not have is
stored as NULL, not 0. See Absent location dimensions.

Those five fields are the counter location. Schema 3.0.4 already stores
XCC, shader engine, and instance on every `rocpd_pmc_event` row. 3.0.4
is also the schema that added HIP event records, so released 3.0.4
databases have to keep loading unchanged. SA and WGP therefore need a
new schema.

This pull request bumps the schema to 3.0.5 and stores the location on
`rocpd_info_pmc`, one pmc id per counter location. `rocpd_pmc_event`
keeps the sample id, that pmc id, and the value. An earlier version of
#12212 wrote `shader_array` and `wgp` on `rocpd_pmc_event`; that change
was removed from #12212, and this pull request does not put it back.
#12655 is the other layout: it leaves the location on `rocpd_pmc_event`
and adds `shader_array` and `wgp` there. The sample table stays free of
hardware-location columns, so a later GPU can add a location field
without widening every sample row.

The branch is based on `users/sauverma/spm-sa-wgp` (#12212). The diff
against that branch is the 3.0.5 layout.

## Technical Details

- Register rocPD schema 3.0.5 and point it at the live SQL files.
- Freeze the released 3.0.4 SQL under `versions/3.0.4/` and point the
3.0.4 entry there. That snapshot still has `xcc`, `shader_engine`, and
`instance` on `rocpd_pmc_event`, and it does not have `shader_array` or
`wgp`.
- `rocpd_info_pmc` gains `xcc`, `shader_engine`, `shader_array`, `wgp`,
and `instance`. The existing `instance_id` column is unchanged. The SPM
instance is the new `instance` column.
- The original counter row stays, with those five columns null. An
ordinary PMC record still points at that row.
- Each agent, counter, and location gets its own `rocpd_info_pmc` row.
Later samples of the same key reuse that pmc id. See Location keys and
pmc ids.
- `rocpd_pmc_event` no longer has the location columns. Each SPM sample
stores `sample_id`, the location's `pmc_id`, and the value.
- The `spm_counters` view reads the location from `rocpd_info_pmc`.
- rocprofv3 writes schema 3.0.5 by default.
- CSV conversion checks the database schema through the
`spm_counter_location` feature, which starts at 3.0.5:
  - 3.0.5 and newer: `counter_name[XCC:, Instance:, SE:, SA:, WGP:]`.
- 3.0.4 and older: `counter_name[XCC:, SE:, Instance:]`. The query does
not reference `shader_array` or `wgp`.
- rocPD backward-compatibility tests cover 3.0.0 through 3.0.5. SA and
WGP are absent from CSV counter names before 3.0.5 and present from
3.0.5. The rocprofv3 SPM rocpd check requires the five location columns
on `rocpd_info_pmc` and requires them to be absent from
`rocpd_pmc_event`.
- The bump is noted in `versions.yml` and the changelog.

## Location keys and pmc ids

An SPM location row is keyed by the sample's GPU agent, the counter id,
and five location dimensions: XCC, shader engine, shader array, WGP, and
instance. A dimension is part of the key only when that counter's
dimension list on that agent contains it. The stored value is then the
decoded index, and 0 is a real index. A dimension the counter does not
provide stays absent in the key and is written as SQL `NULL`. The same
counter and numeric location on two GPUs are different keys, and the row
keeps the metadata of the sample's agent.

New location pmc ids start at `0x7100000000000000` and increase by one
for each new key. KFD event rows start at `0x7000000000000000` and
increase from there, skipping ids already in use. The location range
begins `0x0100000000000000` above the KFD start, so a location id does
not collide with a KFD row or with an ordinary counter id.
`0x7100000000000000` also fits in a signed 64-bit integer.

## Absent location dimensions

A dimension the counter does not have is SQL `NULL` in rocPD and blank
in the CSV name. A dimension the counter has is stored even when the
index is 0. Presence comes from that counter's dimension list on the
agent. It is not inferred from the architecture name, and a decoded 0 is
not treated as missing.

A gfx942 `SQ_CYCLES` sample on shader engine 2 has an XCC and a shader
engine. It does not have a shader array or a WGP.

- rocPD: `xcc = 0`, `shader_engine = 2`, `shader_array = NULL`, `wgp =
NULL`, `instance = 0`
- CSV: `SQ_CYCLES[XCC: 0, Instance: 0, SE: 2, SA: , WGP: ]`

A gfx1200 `SQ_WAVES` sample at shader array 1 and WGP 2 has one XCC, so
XCC is absent. Shader engine, shader array, and WGP are present,
including shader engine 0.

- rocPD: `xcc = NULL`, `shader_engine = 0`, `shader_array = 1`, `wgp =
2`, `instance = 0`
- CSV: `SQ_WAVES[XCC: , Instance: 0, SE: 0, SA: 1, WGP: 2]`

A global counter such as `TCC_HIT` has no shader engine, shader array,
or WGP.

- rocPD: `shader_engine = NULL`, `shader_array = NULL`, `wgp = NULL`
- CSV: `TCC_HIT[XCC: 0, Instance: 0, SE: , SA: , WGP: ]`

The base counter row still leaves all five location columns `NULL`. A
location whose dimension is `NULL` and a location whose same dimension
is 0 get different pmc ids.

## Issue Tracking

AIPROFSDK-1151

## Test Plan

- [ ] rocPD back-compat tests for 3.0.0 through 3.0.5: SA and WGP absent
before 3.0.5, present from 3.0.5
- [ ] A new database has the location columns on `rocpd_info_pmc` and
not on `rocpd_pmc_event`
- [ ] Repeated samples of one location share one pmc id
- [ ] An ordinary PMC record still uses the base counter row
- [ ] An older 3.0.3 or 3.0.4 database still converts with the previous
counter name
- [ ] A dimension the counter does not have is NULL in rocPD and blank
in the CSV name, and a real index of 0 stays 0

## Test Result

The 3.0.5 table SQL loads in SQLite. Back-compat ctests and an
on-hardware SPM run have not been executed. Row counts and write and
query cost are not measured yet.

## Submission Checklist

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

---------

Co-authored-by: Venkateshwar Reddy Kandula <Venkateshwarreddy.Kandula@amd.com>
@systems-assistant

Copy link
Copy Markdown
Contributor

TheRock Submodule Bump Activity

Newest first

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