Fix ROCtx event ranges in trace output (#278)

* Fix marker api traces

* Remove space

* Formatting change

* Small change

* Update Changelog

* Add period to changelog

* Update source/lib/rocprof-sys/library/rocprofiler-sdk.cpp

Co-authored-by: David Galiffi <David.Galiffi@amd.com>

* Fix roctx tests

---------

Co-authored-by: David Galiffi <David.Galiffi@amd.com>

[ROCm/rocprofiler-systems commit: c996c23a13]
This commit is contained in:
darren-amd
2025-07-14 19:31:14 -04:00
committed by GitHub
parent 1892bdef83
commit a5ca94ab9c
3 changed files with 30 additions and 27 deletions
@@ -24,6 +24,7 @@ Full documentation for ROCm Systems Profiler is available at [https://rocm.docs.
- Fixed a build issue with CMake 4.
- Fixed incorrect kernel names shown for kernel dispatch tracks in Perfetto.
- Fixed formatting of some output logs.
- Fixed an issue where ROC-TX ranges were displayed as two separate events instead of a single spanning event.
## ROCm Systems Profiler 1.0.2 for ROCm 6.4.2
@@ -222,14 +222,16 @@ save_args(rocprofiler_callback_tracing_kind_t /*kind*/, int32_t /*operation*/,
auto&
get_marker_pushed_ranges()
{
static thread_local auto _v = std::vector<tim::hash_value_t>{};
static thread_local auto _v =
std::vector<std::pair<tim::hash_value_t, rocprofiler_timestamp_t>>{};
return _v;
}
auto&
get_marker_started_ranges()
{
static thread_local auto _v = std::vector<tim::hash_value_t>{};
static thread_local auto _v =
std::vector<std::pair<tim::hash_value_t, rocprofiler_timestamp_t>>{};
return _v;
}
@@ -237,8 +239,12 @@ template <typename CategoryT>
void
tool_tracing_callback_start(CategoryT, rocprofiler_callback_tracing_record_t record,
rocprofiler_user_data_t* /*user_data*/,
rocprofiler_timestamp_t /*ts*/)
rocprofiler_timestamp_t ts)
{
// Required because of how some compilers handle templates. This may result in an
// "unused variable" warning.
(void) ts;
auto _name = tool_data->callback_tracing_info.at(record.kind, record.operation);
if constexpr(std::is_same<CategoryT, category::rocm_marker_api>::value)
@@ -254,14 +260,14 @@ tool_tracing_callback_start(CategoryT, rocprofiler_callback_tracing_record_t rec
{
_name = _data->args.roctxRangePushA.message;
auto _hash = tim::add_hash_id(_name);
get_marker_pushed_ranges().emplace_back(_hash);
get_marker_pushed_ranges().emplace_back(_hash, ts);
break;
}
case ROCPROFILER_MARKER_CORE_API_ID_roctxRangeStartA:
{
_name = _data->args.roctxRangeStartA.message;
auto _hash = tim::add_hash_id(_name);
get_marker_started_ranges().emplace_back(_hash);
get_marker_started_ranges().emplace_back(_hash, ts);
break;
}
case ROCPROFILER_MARKER_CORE_API_ID_roctxMarkA:
@@ -294,6 +300,7 @@ tool_tracing_callback_stop(
{
auto _name = tool_data->callback_tracing_info.at(record.kind, record.operation);
uint64_t begin_ts = user_data->value;
if constexpr(std::is_same<CategoryT, category::rocm_marker_api>::value)
{
if(record.kind == ROCPROFILER_CALLBACK_TRACING_MARKER_CORE_API)
@@ -310,8 +317,9 @@ tool_tracing_callback_stop(
"roctxRangePop does not have corresponding roctxRangePush on "
"this thread");
auto _hash = get_marker_pushed_ranges().back();
auto _hash = get_marker_pushed_ranges().back().first;
_name = tim::get_hash_identifier_fast(_hash);
begin_ts = get_marker_pushed_ranges().back().second;
get_marker_pushed_ranges().pop_back();
break;
}
@@ -322,8 +330,9 @@ tool_tracing_callback_stop(
"roctxRangeStop does not have corresponding roctxRangeStart on "
"this thread");
auto _hash = get_marker_started_ranges().back();
auto _hash = get_marker_started_ranges().back().first;
_name = tim::get_hash_identifier_fast(_hash);
begin_ts = get_marker_started_ranges().back().second;
get_marker_started_ranges().pop_back();
break;
}
@@ -332,6 +341,11 @@ tool_tracing_callback_stop(
_name = _data->args.roctxMarkA.message;
break;
}
case ROCPROFILER_MARKER_CORE_API_ID_roctxRangePushA:
case ROCPROFILER_MARKER_CORE_API_ID_roctxRangeStartA:
{
return;
}
default:
{
break;
@@ -355,7 +369,7 @@ tool_tracing_callback_stop(
&args);
}
uint64_t _beg_ts = user_data->value;
uint64_t _beg_ts = begin_ts;
uint64_t _end_ts = ts;
tracing::push_perfetto_ts(
@@ -39,27 +39,19 @@ rocprofiler_systems_add_test(
)
set(ROCTX_LABEL
roctxMark_GPU_workload
roctxRangePushA
roctxRangePushA
roctxRangeStartA
roctxRangeStartA
roctxRangePush_HIP_Kernel
roctxRangePush_HIP_Kernel
roctxRangePush_run_profiling
roctxRangeStart_GPU_Compute
roctxRangeStart_GPU_Compute
roctxRangePush_HIP_Kernel
roctxRangePush_HIP_Kernel
roctxGetThreadId
roctxMark_RoctxProfilerPause_End
roctxMark_Thread_Start
roctxMark_End
roctxRangePush_run_profiling
roctxMark_Finished_GPU
)
set(ROCTX_COUNT
1
2
1
1
1
1
1
@@ -76,19 +68,15 @@ set(ROCTX_COUNT
set(ROCTX_DEPTH
1
1
2
0
3
1
0
1
0
1
0
1
1
2
2
0
0
1
1
)
rocprofiler_systems_add_validation_test(