rocprofiler_kernel_dispatch_info_t + header record for buffered counter collection (#758)
* Update include/rocprofiler-sdk
- defines.h
- ROCPROFILER_VERSION_10_0 -> ROCPROFILER_SDK_VERSION_0_0
- fwd.h
- rocprofiler_counter_record_kind_t
- rocprofiler_kernel_dispatch_info_t
- rocprofiler_record_counter_t
- has dispatch id instead of correlation id
- rocprofiler_counter_info_v0_t
- added rocprofiler_counter_id_t field
- added is_constant field
- reordered better packing
- dispatch_profile.h
- added rocprofiler_profile_counting_dispatch_record_t for use as a header record for rocprofiler_profile_counting_dispatch_data_t
- callback_tracing.h
- rocprofiler_callback_tracing_kernel_dispatch_data_t uses rocprofiler_kernel_dispatch_info_t
- buffer_tracing.h
- rocprofiler_buffer_tracing_kernel_dispatch_record_t uses rocprofiler_kernel_dispatch_info_t
* Update lib/rocprofiler-sdk/*
- transition to rocprofiler_kernel_dispatch_info_t
- set id and is_constant values for rocprofiler_counter_info_v0_t in rocprofiler_query_counter_info
* Update lib/rocprofiler-sdk-tool
- transition to rocprofiler_kernel_dispatch_info_t
* Update lib/rocprofiler-sdk/counters/tests/core.cpp
- transition to rocprofiler_kernel_dispatch_info_t
* Update samples
- transition to rocprofiler_kernel_dispatch_info_t
- transition to rocprofiler_counter_record_kind_t
* Update tests
- transition to rocprofiler_kernel_dispatch_info_t
- transition to rocprofiler_counter_record_kind_t
- improve integration test validation for counter-collection
- update serialization for new/additional types
* Fix tests/counter-collection/validate.py
- loosen restrictions on the length of counter description
* Update include/rocprofiler-sdk/buffer_tracing.h
- remove accidental packed attribute
* Update lib/rocprofiler-sdk/counters/xml/derived_counters.xml
- Add description for TCC_TAG_STALL_sum (reference: https://rocm.docs.amd.com/en/develop/conceptual/gpu-arch/mi300-mi200-performance-counters.html)
* Update tests/page-migration/validate.py
[ROCm/rocprofiler-sdk commit: 07537b6231]
This commit is contained in:
committed by
GitHub
parent
4f99edbad5
commit
2aef3c3d15
@@ -60,6 +60,7 @@
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <thread>
|
||||
@@ -222,19 +223,22 @@ tool_tracing_callback(rocprofiler_context_id_t context,
|
||||
|
||||
auto info = std::stringstream{};
|
||||
|
||||
info << "agent_id=" << record->agent_id.handle
|
||||
<< ", queue_id=" << record->queue_id.handle << ", kernel_id=" << record->kernel_id
|
||||
<< ", kernel=" << client_kernels.at(record->kernel_id).kernel_name
|
||||
info << "agent_id=" << record->dispatch_info.agent_id.handle
|
||||
<< ", queue_id=" << record->dispatch_info.queue_id.handle
|
||||
<< ", kernel_id=" << record->dispatch_info.kernel_id
|
||||
<< ", kernel=" << client_kernels.at(record->dispatch_info.kernel_id).kernel_name
|
||||
<< ", context=" << context.handle << ", buffer_id=" << buffer_id.handle
|
||||
<< ", cid=" << record->correlation_id.internal
|
||||
<< ", extern_cid=" << record->correlation_id.external.value
|
||||
<< ", kind=" << record->kind << ", start=" << record->start_timestamp
|
||||
<< ", stop=" << record->end_timestamp
|
||||
<< ", private_segment_size=" << record->private_segment_size
|
||||
<< ", group_segment_size=" << record->group_segment_size << ", workgroup_size=("
|
||||
<< record->workgroup_size.x << "," << record->workgroup_size.y << ","
|
||||
<< record->workgroup_size.z << "), grid_size=(" << record->grid_size.x << ","
|
||||
<< record->grid_size.y << "," << record->grid_size.z << ")";
|
||||
<< ", private_segment_size=" << record->dispatch_info.private_segment_size
|
||||
<< ", group_segment_size=" << record->dispatch_info.group_segment_size
|
||||
<< ", workgroup_size=(" << record->dispatch_info.workgroup_size.x << ","
|
||||
<< record->dispatch_info.workgroup_size.y << ","
|
||||
<< record->dispatch_info.workgroup_size.z << "), grid_size=("
|
||||
<< record->dispatch_info.grid_size.x << "," << record->dispatch_info.grid_size.y
|
||||
<< "," << record->dispatch_info.grid_size.z << ")";
|
||||
|
||||
if(record->start_timestamp > record->end_timestamp)
|
||||
throw std::runtime_error("kernel dispatch: start > end");
|
||||
@@ -267,7 +271,10 @@ tool_tracing_callback(rocprofiler_context_id_t context,
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error{"unexpected rocprofiler_record_header_t category + kind"};
|
||||
auto _msg = std::stringstream{};
|
||||
_msg << "unexpected rocprofiler_record_header_t category + kind: (" << header->category
|
||||
<< " + " << header->kind << ")";
|
||||
throw std::runtime_error{_msg.str()};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,12 +74,13 @@ record_callback(rocprofiler_profile_counting_dispatch_data_t dispatch_data,
|
||||
void* callback_data_args)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "Kernel_id " << dispatch_data.kernel_id << ": ";
|
||||
ss << "Dispatch_Id=" << dispatch_data.dispatch_info.dispatch_id
|
||||
<< ", Kernel_id=" << dispatch_data.dispatch_info.kernel_id
|
||||
<< ", Corr_Id=" << dispatch_data.correlation_id.internal << ": ";
|
||||
for(size_t i = 0; i < record_count; ++i)
|
||||
{
|
||||
ss << "(Id: " << record_data[i].id << " Value [D]: " << record_data[i].counter_value
|
||||
<< " Corr_Id: " << record_data[i].correlation_id.internal << "),";
|
||||
}
|
||||
<< "),";
|
||||
|
||||
auto* output_stream = static_cast<std::ostream*>(callback_data_args);
|
||||
if(!output_stream) throw std::runtime_error{"nullptr to output stream"};
|
||||
*output_stream << "[" << __FUNCTION__ << "] " << ss.str() << "\n";
|
||||
@@ -110,7 +111,8 @@ dispatch_callback(rocprofiler_profile_counting_dispatch_data_t dispatch_data,
|
||||
static std::unordered_map<uint64_t, rocprofiler_profile_config_id_t> profile_cache = {};
|
||||
|
||||
auto search_cache = [&]() {
|
||||
if(auto pos = profile_cache.find(dispatch_data.agent_id.handle); pos != profile_cache.end())
|
||||
if(auto pos = profile_cache.find(dispatch_data.dispatch_info.agent_id.handle);
|
||||
pos != profile_cache.end())
|
||||
{
|
||||
*config = pos->second;
|
||||
return true;
|
||||
@@ -133,7 +135,7 @@ dispatch_callback(rocprofiler_profile_counting_dispatch_data_t dispatch_data,
|
||||
|
||||
// Iterate through the agents and get the counters available on that agent
|
||||
ROCPROFILER_CALL(rocprofiler_iterate_agent_supported_counters(
|
||||
dispatch_data.agent_id,
|
||||
dispatch_data.dispatch_info.agent_id,
|
||||
[](rocprofiler_agent_id_t,
|
||||
rocprofiler_counter_id_t* counters,
|
||||
size_t num_counters,
|
||||
@@ -167,12 +169,13 @@ dispatch_callback(rocprofiler_profile_counting_dispatch_data_t dispatch_data,
|
||||
|
||||
// Create a colleciton profile for the counters
|
||||
rocprofiler_profile_config_id_t profile;
|
||||
ROCPROFILER_CALL(
|
||||
rocprofiler_create_profile_config(
|
||||
dispatch_data.agent_id, collect_counters.data(), collect_counters.size(), &profile),
|
||||
"Could not construct profile cfg");
|
||||
ROCPROFILER_CALL(rocprofiler_create_profile_config(dispatch_data.dispatch_info.agent_id,
|
||||
collect_counters.data(),
|
||||
collect_counters.size(),
|
||||
&profile),
|
||||
"Could not construct profile cfg");
|
||||
|
||||
profile_cache.emplace(dispatch_data.agent_id.handle, profile);
|
||||
profile_cache.emplace(dispatch_data.dispatch_info.agent_id.handle, profile);
|
||||
// Return the profile to collect those counters for this dispatch
|
||||
*config = profile;
|
||||
}
|
||||
|
||||
@@ -95,12 +95,23 @@ buffered_callback(rocprofiler_context_id_t,
|
||||
for(size_t i = 0; i < num_headers; ++i)
|
||||
{
|
||||
auto* header = headers[i];
|
||||
if(header->category == ROCPROFILER_BUFFER_CATEGORY_COUNTERS && header->kind == 0)
|
||||
if(header->category == ROCPROFILER_BUFFER_CATEGORY_COUNTERS &&
|
||||
header->kind == ROCPROFILER_COUNTER_RECORD_PROFILE_COUNTING_DISPATCH_HEADER)
|
||||
{
|
||||
// Print the returned counter data.
|
||||
auto* record =
|
||||
static_cast<rocprofiler_profile_counting_dispatch_record_t*>(header->payload);
|
||||
ss << "[Dispatch_Id: " << record->dispatch_info.dispatch_id
|
||||
<< " Kernel_ID: " << record->dispatch_info.kernel_id
|
||||
<< " Corr_Id: " << record->correlation_id.internal << ")]\n";
|
||||
}
|
||||
else if(header->category == ROCPROFILER_BUFFER_CATEGORY_COUNTERS &&
|
||||
header->kind == ROCPROFILER_COUNTER_RECORD_VALUE)
|
||||
{
|
||||
// Print the returned counter data.
|
||||
auto* record = static_cast<rocprofiler_record_counter_t*>(header->payload);
|
||||
ss << "(Id: " << record->id << " Value [D]: " << record->counter_value
|
||||
<< " Corr_Id: " << record->correlation_id.internal << "),";
|
||||
ss << " (Dispatch_Id: " << record->dispatch_id << " Id: " << record->id
|
||||
<< " Value [D]: " << record->counter_value << "),";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +144,8 @@ dispatch_callback(rocprofiler_profile_counting_dispatch_data_t dispatch_data,
|
||||
static std::unordered_map<uint64_t, rocprofiler_profile_config_id_t> profile_cache = {};
|
||||
|
||||
auto search_cache = [&]() {
|
||||
if(auto pos = profile_cache.find(dispatch_data.agent_id.handle); pos != profile_cache.end())
|
||||
if(auto pos = profile_cache.find(dispatch_data.dispatch_info.agent_id.handle);
|
||||
pos != profile_cache.end())
|
||||
{
|
||||
*config = pos->second;
|
||||
return true;
|
||||
@@ -156,7 +168,7 @@ dispatch_callback(rocprofiler_profile_counting_dispatch_data_t dispatch_data,
|
||||
|
||||
// Iterate through the agents and get the counters available on that agent
|
||||
ROCPROFILER_CALL(rocprofiler_iterate_agent_supported_counters(
|
||||
dispatch_data.agent_id,
|
||||
dispatch_data.dispatch_info.agent_id,
|
||||
[](rocprofiler_agent_id_t,
|
||||
rocprofiler_counter_id_t* counters,
|
||||
size_t num_counters,
|
||||
@@ -190,12 +202,13 @@ dispatch_callback(rocprofiler_profile_counting_dispatch_data_t dispatch_data,
|
||||
|
||||
// Create a colleciton profile for the counters
|
||||
rocprofiler_profile_config_id_t profile;
|
||||
ROCPROFILER_CALL(
|
||||
rocprofiler_create_profile_config(
|
||||
dispatch_data.agent_id, collect_counters.data(), collect_counters.size(), &profile),
|
||||
"Could not construct profile cfg");
|
||||
ROCPROFILER_CALL(rocprofiler_create_profile_config(dispatch_data.dispatch_info.agent_id,
|
||||
collect_counters.data(),
|
||||
collect_counters.size(),
|
||||
&profile),
|
||||
"Could not construct profile cfg");
|
||||
|
||||
profile_cache.emplace(dispatch_data.agent_id.handle, profile);
|
||||
profile_cache.emplace(dispatch_data.dispatch_info.agent_id.handle, profile);
|
||||
// Return the profile to collect those counters for this dispatch
|
||||
*config = profile;
|
||||
}
|
||||
|
||||
@@ -170,7 +170,8 @@ buffered_callback(rocprofiler_context_id_t,
|
||||
for(size_t i = 0; i < num_headers; ++i)
|
||||
{
|
||||
auto* header = headers[i];
|
||||
if(header->category == ROCPROFILER_BUFFER_CATEGORY_COUNTERS && header->kind == 0)
|
||||
if(header->category == ROCPROFILER_BUFFER_CATEGORY_COUNTERS &&
|
||||
header->kind == ROCPROFILER_COUNTER_RECORD_VALUE)
|
||||
{
|
||||
// Record the counters we have in the buffer and the number of instances of
|
||||
// the counter we have seen.
|
||||
@@ -242,7 +243,7 @@ dispatch_callback(rocprofiler_profile_counting_dispatch_data_t dispatch_data,
|
||||
{
|
||||
std::vector<rocprofiler_counter_id_t> counters_needed;
|
||||
ROCPROFILER_CALL(rocprofiler_iterate_agent_supported_counters(
|
||||
dispatch_data.agent_id,
|
||||
dispatch_data.dispatch_info.agent_id,
|
||||
[](rocprofiler_agent_id_t,
|
||||
rocprofiler_counter_id_t* counters,
|
||||
size_t num_counters,
|
||||
@@ -269,7 +270,7 @@ dispatch_callback(rocprofiler_profile_counting_dispatch_data_t dispatch_data,
|
||||
cap.expected_counter_names.emplace(found_counter.handle, std::string(version.name));
|
||||
size_t expected = 0;
|
||||
ROCPROFILER_CALL(rocprofiler_query_counter_instance_count(
|
||||
dispatch_data.agent_id, found_counter, &expected),
|
||||
dispatch_data.dispatch_info.agent_id, found_counter, &expected),
|
||||
"COULD NOT QUERY INSTANCES");
|
||||
cap.remaining.push_back(found_counter);
|
||||
cap.expected.emplace(found_counter.handle, expected);
|
||||
@@ -297,8 +298,9 @@ dispatch_callback(rocprofiler_profile_counting_dispatch_data_t dispatch_data,
|
||||
}
|
||||
if(cap.expected.empty())
|
||||
{
|
||||
std::clog << "No counters found for agent " << dispatch_data.agent_id.handle << " ("
|
||||
<< agents.at(dispatch_data.agent_id.handle)->name << ")";
|
||||
std::clog << "No counters found for agent "
|
||||
<< dispatch_data.dispatch_info.agent_id.handle << " ("
|
||||
<< agents.at(dispatch_data.dispatch_info.agent_id.handle)->name << ")";
|
||||
}
|
||||
}
|
||||
if(cap.remaining.empty()) return;
|
||||
@@ -306,9 +308,10 @@ dispatch_callback(rocprofiler_profile_counting_dispatch_data_t dispatch_data,
|
||||
rocprofiler_profile_config_id_t profile;
|
||||
|
||||
// Select the next counter to collect.
|
||||
ROCPROFILER_CALL(rocprofiler_create_profile_config(
|
||||
dispatch_data.agent_id, &(cap.remaining.back()), 1, &profile),
|
||||
"Could not construct profile cfg");
|
||||
ROCPROFILER_CALL(
|
||||
rocprofiler_create_profile_config(
|
||||
dispatch_data.dispatch_info.agent_id, &(cap.remaining.back()), 1, &profile),
|
||||
"Could not construct profile cfg");
|
||||
|
||||
cap.remaining.pop_back();
|
||||
*config = profile;
|
||||
|
||||
Reference in New Issue
Block a user