Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Touched so rocjitsu-formatting creates the required "pre-commit" check-run for therock-pr-bot.
exclude: |
(?x)
third_party/
Expand Down
2 changes: 2 additions & 0 deletions projects/rocprofiler-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Full documentation for ROCprofiler-SDK is available at [rocm.docs.amd.com/projec

### Resolved issues

- Fixed rocpd reporting a counter at N times its value under `rocprofv3 --replay-mode kernel` when N `--pmc` groups list it, for example a sanity counter such as `SQ_WAVES` in every group. Every pass of a replayed dispatch shares the dispatch's record, so the `counters_collection` view, and the counter CSV and Perfetto output that `rocpd convert` builds from it, summed the passes. Passes after the first are now tagged with `replay_pass` in `rocpd_pmc_event.extdata`, the view averages a counter over the passes that collected it, and the `pmc_events` view reports each row's pass in a new `replay_pass` column. This behavior is identified by rocpd schema version 3.0.6.

### Known issues

### Removed
Expand Down
10 changes: 9 additions & 1 deletion projects/rocprofiler-sdk/source/bin/rocprofv3.py
Original file line number Diff line number Diff line change
Expand Up @@ -1799,11 +1799,19 @@ def _write_env_value():
f"{ROCPROF_TOOL_LIBRARY}",
append=True,
)
# Prepend this prefix. An older librocprofiler-sdk-rocpd already on
# LD_LIBRARY_PATH (a system /opt/rocm) rejects schema versions this rocprofv3
# writes, so the library next to the tool has to win.
update_env(
"LD_LIBRARY_PATH",
f"{ROCM_DIR}/lib",
append=True,
prepend=True,
)
if not app_env.get("ROCPD_SCHEMA_PATH"):
update_env(
"ROCPD_SCHEMA_PATH",
f"{ROCM_DIR}/share/rocprofiler-sdk-rocpd",
)

# -o/-d stay None so a typed option stays distinguishable from an inherited
# ROCPROF_OUTPUT_*, which the listing subprocess always inherits from below;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,20 @@ Default ``rocpd``
The default output format is ``rocpd``. Convert with ``rocpd convert`` as described in
:ref:`using-rocpd-output-format`.

The ``counters_collection`` view, which ``rocpd convert`` uses for counter CSV and Perfetto output,
has one row per dispatch and counter. A counter repeated across groups is collected by every pass
whose group lists it, and the view reports the mean of those passes, so a sanity counter such as
``SQ_WAVES`` in every group reads the same as it does in a single pass. The individual passes stay
Comment thread
Copilot marked this conversation as resolved.
Resolved
in the database: a ``rocpd_pmc_event`` row from a pass after the first carries the pass index as
``replay_pass`` in its ``extdata`` column, and a row without it belongs to pass 0. The
``pmc_events`` view, which has one row per counter instance and pass, reports it as a
``replay_pass`` column.

The mean counts only passes that contain that counter. A replay pass dedicated to another service,
such as ATT, has no PMC row and therefore does not change the counter's denominator. For a run
without kernel replay, all PMC rows are untagged, so ``counters_collection`` retains its existing
columns and continues to report the sum across hardware instances.

What is snapshotted
===================

Expand Down
11 changes: 10 additions & 1 deletion projects/rocprofiler-sdk/source/lib/output/generateRocpd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ read_schema_file(rocpd_db& db, rocpd_sql_schema_kind_t schema_kind)
{
auto _variables = common::init_public_api_struct(rocpd_sql_schema_jinja_variables_t{});
auto _options = ROCPD_SQL_OPTIONS_NONE;
auto _version = rocpd_version_triplet_t{3, 0, 5}; // default schema version
auto _version = rocpd_version_triplet_t{3, 0, 6}; // default schema version

_variables.uuid = db.uuid.c_str();
_variables.guid = db.guid.c_str();
Expand Down Expand Up @@ -1691,6 +1691,14 @@ write_rocpd(
auto dispatch_id = info.dispatch_id;

auto evt_id = dispatch_evt_ids.at(dispatch_id);
// Every kernel-replay pass of a dispatch shares its event, so counters_collection
// needs replay_pass to average a counter collected by several passes instead of
// summing them. Pass 0 keeps the column default, so non-replay rows are unchanged;
// extdata is always bound so the insert batch keeps a single column list.
const auto extdata =
(record.replay_pass == 0)
? std::string{"{}"}
: fmt::format(R"({{"replay_pass":{}}})", record.replay_pass);
for(const auto& count : record.read())
{
get_insert_statement(db,
Expand All @@ -1700,6 +1708,7 @@ write_rocpd(
insert_value("event_id", evt_id),
insert_value("pmc_id", count.id.handle),
insert_value("value", count.value),
insert_value("extdata", extdata),
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions projects/rocprofiler-sdk/source/lib/python/rocpd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ using RocpdImportData with multiple databases, these views query across the atta
| memory_allocations | Alloc/free with type, level, agent, size, queue/stream. | Memory usage. |
| scratch_memory | Scratch-only allocations (subset of memory_allocate). | GPU scratch analysis. |
| pmc_info | PMC counter metadata. | Discover available counters. |
| pmc_events | PMC values per kernel (counter name, value, duration). | Counter time series. |
| counters_collection | Aggregated PMC per dispatch/kernel/counter (e.g. SUM of value). | Counter summaries per kernel. |
| pmc_events | PMC values per kernel (counter name, value, duration, kernel-replay pass). | Counter time series. |
| counters_collection | Aggregated PMC per dispatch/kernel/counter: instances are summed, kernel-replay passes are averaged. | Counter summaries per kernel. |
| events_args | Events with argument rows (category, arg name/value). | API or event arguments. |
| stream_args | Stream arguments with stream description. | Stream-related API analysis. |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,9 @@ SELECT
K.end,
(K.end - K.start) AS duration,
PMC_I.name AS counter_name,
PMC_E.value AS counter_value
PMC_E.value AS counter_value,
-- Kernel-replay pass that collected the value. Rows without the tag are pass 0.
COALESCE(json_extract(PMC_E.extdata, '$.replay_pass'), 0) AS replay_pass
FROM
`rocpd_pmc_event` PMC_E
INNER JOIN `rocpd_info_pmc` PMC_I ON PMC_I.id = PMC_E.pmc_id
Expand Down Expand Up @@ -784,7 +786,12 @@ SELECT
PMC_I.expression,
PMC_I.value_type,
PMC_I.id AS counter_id,
SUM(PMC_E.value) AS value,
-- Kernel replay records every pass of a dispatch under the same event and tags passes after
-- the first with extdata.replay_pass. Sum the instances of each pass, then average over the
-- passes that collected the counter instead of adding the passes together.
SUM(PMC_E.value) / COUNT(
DISTINCT COALESCE(json_extract(PMC_E.extdata, '$.replay_pass'), 0)
) AS value,
Comment thread
amd-vkale marked this conversation as resolved.
Resolved
K.start,
K.end,
PMC_I.is_constant,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- RocPD schema version 3.0.5
-- RocPD schema version 3.0.6

CREATE TABLE IF NOT EXISTS
"rocpd_metadata{{uuid}}" (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ rocprofiler-sdk-rocpd:
rocpd_data_views: versions/3.0.4/data_views.sql
rocpd_summary_views: versions/3.0.4/summary_views.sql
- version: "3.0.5"
rocpd_metadata: versions/3.0.5/rocpd_metadata.sql
rocpd_tables: versions/3.0.5/rocpd_tables.sql
rocpd_views: versions/3.0.5/rocpd_views.sql
rocpd_indexes: versions/3.0.5/rocpd_indexes.sql
rocpd_data_views: versions/3.0.5/data_views.sql
rocpd_summary_views: versions/3.0.5/summary_views.sql
- version: "3.0.6"
rocpd_metadata: rocpd_metadata.sql
rocpd_tables: rocpd_tables.sql
rocpd_views: rocpd_views.sql
Expand Down Expand Up @@ -74,3 +81,8 @@ rocprofiler-sdk-rocpd:
# - SPM location dimensions not provided for a counter are stored as NULL.
# instance is always set on a location row
# - spm_counters view reads those fields from rocpd_info_pmc

# Version 3.0.6
# - Kernel-replay passes after the first tag their rocpd_pmc_event rows with replay_pass in extdata
# - counters_collection averages a counter over the passes that collected it instead of summing them
# - pmc_events reports the kernel-replay pass in a replay_pass column
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
#
#

set(rocpd_schemas data_views.sql rocpd_indexes.sql rocpd_metadata.sql rocpd_tables.sql
rocpd_views.sql summary_views.sql)

rocpd_configure_schema_files(VERSION "3.0.5" FILES ${rocpd_schemas})
Loading
Loading