Callback tracing for kernel dispatches + External correlation ID request service (#682)

* Support ROCPROFILER_CALLBACK_TRACING_KERNEL_DISPATCH

* Fix doxygen

* Update callback tracing

- temporary hacks for kind operation name and iterate kind operations

* Update source/include/rocprofiler-sdk

- introduce sequence id for kernel dispatches

* Update lib/rocprofiler-sdk (seq id)

- support sequence id passing

* Update tests (seq id)

- testing for sequence ids

* Cleanup include/rocprofiler-sdk/fwd.h

* Misc cleanup

* External Correlation ID Request Service (#699)

* External correlation ID request service

- callback requesting an external correlation ID instead of fetching from top of pushed external correlation ID stack

* Update external correlation id request support

- pass internal correlation ID in callback
- async copy generates a correlation ID if none already exists
- added external correlation ID request support for scratch memory tracing
- updated scratch memory tracing to use tracing:: functions

* Update hsa/queue.hpp

- new line at EOF

* Misc tweaks

- remove unnecessary logging in agent.cpp
- correlation_id::add_ref_count check for retirement
- finalization check in HSA queue AsyncSignalHandler

* Improve assertion failure logging in misc tests

* Update include/rocprofiler-sdk/fwd.h

- remove rocprofiler_record_counter_header_t

* Move lib/rocprofiler-sdk/tracing.hpp into lib/rocprofiler-sdk/tracing/ folder

* Update lib/rocprofiler-sdk/hsa/*

- hsa::get_hsa_status_string
- queue_info_session.hpp header
- rocprofiler_packet.hpp

* Update lib/rocprofiler-sdk/{counters,hip,marker}

- execute_phase_exit_callbacks tweaks
- queue_info_session tweaks

* Move rocprofiler_kernel_dispatch_operation_t to include/rocprofiler-sdk/fwd.h

* Update rocprofiler_buffer_tracing_kernel_dispatch_record_t

- add operation field and thread_id field

* Add lib/rocprofiler-sdk/kernel_dispatch

- enum <-> string mapping for kernel dispatch
- tracing implementations

* Update lib/rocprofiler-sdk/CMakeLists.txt

- tracing and kernel dispatch sub-directories

* Update lib/rocprofiler-sdk/{buffer,callback}_tracing.cpp

- invoke rocprofiler::kernel_tracing functions

* Update tests/common/serialization.hpp

- support operation and thread_id fields for rocprofiler_buffer_tracing_kernel_dispatch_record_t

* Update tests/tools/json-tool.cpp

- use external correlation id request service

* Rename sequence_id to dispatch_id
This commit is contained in:
Jonathan R. Madsen
2024-04-11 19:49:49 -05:00
committato da GitHub
parent 0f5c575435
commit 56030018dc
46 ha cambiato i file con 2297 aggiunte e 955 eliminazioni
+17 -18
Vedi File
@@ -266,7 +266,8 @@ queue_cb(const context::context* ctx,
const std::shared_ptr<counter_callback_info>& info,
const hsa::Queue& queue,
const hsa::rocprofiler_packet& pkt,
uint64_t kernel_id,
rocprofiler_kernel_id_t kernel_id,
rocprofiler_dispatch_id_t dispatch_id,
rocprofiler_user_data_t* user_data,
const hsa::Queue::queue_info_session_t::external_corr_id_map_t& extern_corr_ids,
const context::correlation_id* correlation_id)
@@ -326,6 +327,7 @@ queue_cb(const context::context* ctx,
common::init_public_api_struct(rocprofiler_profile_counting_dispatch_data_t{});
dispatch_data.kernel_id = kernel_id;
dispatch_data.dispatch_id = dispatch_id;
dispatch_data.agent_id = CHECK_NOTNULL(queue.get_agent().get_rocp_agent())->id;
dispatch_data.queue_id = queue.get_id();
dispatch_data.correlation_id = _corr_id_v;
@@ -375,7 +377,7 @@ queue_cb(const context::context* ctx,
void
completed_cb(const context::context* ctx,
const std::shared_ptr<counter_callback_info>& info,
const hsa::Queue& queue,
const hsa::Queue& /*queue*/,
hsa::rocprofiler_packet,
const hsa::Queue::queue_info_session_t& session,
inst_pkt_t& pkts)
@@ -432,8 +434,8 @@ completed_cb(const context::context* ctx,
if(const auto* _corr_id = session.correlation_id)
{
_corr_id_v.internal = _corr_id->internal;
if(const auto* external =
rocprofiler::common::get_val(session.extern_corr_ids, info->internal_context))
if(const auto* external = rocprofiler::common::get_val(
session.tracing_data.external_correlation_ids, info->internal_context))
{
_corr_id_v.external = *external;
}
@@ -463,20 +465,15 @@ completed_cb(const context::context* ctx,
auto dispatch_data =
common::init_public_api_struct(rocprofiler_profile_counting_dispatch_data_t{});
const auto& kernel_dispatch_pkt = session.kernel_pkt.kernel_dispatch;
dispatch_data.kernel_id = session.kernel_id;
dispatch_data.agent_id = CHECK_NOTNULL(queue.get_agent().get_rocp_agent())->id;
dispatch_data.queue_id = queue.get_id();
dispatch_data.kernel_id = session.callback_record.kernel_id;
dispatch_data.dispatch_id = session.callback_record.dispatch_id;
dispatch_data.agent_id = session.callback_record.agent_id;
dispatch_data.queue_id = session.callback_record.queue_id;
dispatch_data.correlation_id = _corr_id_v;
dispatch_data.private_segment_size = kernel_dispatch_pkt.private_segment_size;
dispatch_data.group_segment_size = kernel_dispatch_pkt.group_segment_size;
dispatch_data.workgroup_size = {kernel_dispatch_pkt.workgroup_size_x,
kernel_dispatch_pkt.workgroup_size_y,
kernel_dispatch_pkt.workgroup_size_z};
dispatch_data.grid_size = {kernel_dispatch_pkt.grid_size_x,
kernel_dispatch_pkt.grid_size_y,
kernel_dispatch_pkt.grid_size_z};
dispatch_data.private_segment_size = session.callback_record.private_segment_size;
dispatch_data.group_segment_size = session.callback_record.group_segment_size;
dispatch_data.workgroup_size = session.callback_record.workgroup_size;
dispatch_data.grid_size = session.callback_record.grid_size;
info->record_callback(
dispatch_data, out.data(), out.size(), session.user_data, info->record_callback_args);
@@ -509,7 +506,8 @@ start_context(const context::context* ctx)
std::nullopt,
[=](const hsa::Queue& q,
const hsa::rocprofiler_packet& kern_pkt,
uint64_t kernel_id,
rocprofiler_kernel_id_t kernel_id,
rocprofiler_dispatch_id_t dispatch_id,
rocprofiler_user_data_t* user_data,
const hsa::Queue::queue_info_session_t::external_corr_id_map_t& extern_corr_ids,
const context::correlation_id* correlation_id) {
@@ -518,6 +516,7 @@ start_context(const context::context* ctx)
q,
kern_pkt,
kernel_id,
dispatch_id,
user_data,
extern_corr_ids,
correlation_id);