rocDecode API Tracing Support (#49)

* rocDecode API Tracing support

* Test bin file added to rocdecode. Need to add validate python methods

* Added option to not make rocDecode tests

* Added rocdecode and rocprofv3 tests

* Added csv test

* Address PR comments. Changed tests to use built-in rocstreambit decoder to remove ffmpeg dependancy. Changed cmake option to disbale tests rather than not build them. Tests work locally, but will fail until rocDecode is built with tracing enabled on CI

* Add option to avoid building rocdecode tests

* Added option to avoid building rocdecode bin file

* Merge conflict error

* CMake files changed in response to review comments. Attempting to implement callbacks.

* Turned off test building for rocdecode

* Minor fixes for review comments

* Review comments

* Updated formatting

* Document changes and format.hpp reversion. Need to remove iterate args support for now for later update.

* Remove iterate args support

* Remove iterate-args

* enforce abi versioning in macro if

* Fix doc error

* removed spaces to fix indentation error

---------

Co-authored-by: Madsen, Jonathan <Jonathan.Madsen@amd.com>
Este commit está contenido en:
Trowbridge, Ian
2025-01-17 16:42:25 -06:00
cometido por GitHub
padre 1f01526eed
commit e307b89ca4
Se han modificado 73 ficheros con 7486 adiciones y 45 borrados
+2
Ver fichero
@@ -163,5 +163,7 @@ using counter_records_buffered_output_t =
using pc_sampling_host_trap_buffered_output_t =
buffered_output<rocprofiler::tool::rocprofiler_tool_pc_sampling_host_trap_record_t,
domain_type::PC_SAMPLING_HOST_TRAP>;
using rocdecode_buffered_output_t =
buffered_output<rocprofiler_buffer_tracing_rocdecode_api_record_t, domain_type::ROCDECODE>;
} // namespace tool
} // namespace rocprofiler
+1
Ver fichero
@@ -61,6 +61,7 @@ DEFINE_BUFFER_TYPE_NAME(PC_SAMPLING_HOST_TRAP,
"PC_SAMPLING_HOST_TRAP",
"pc_sampling_host_trap",
"pc_sampling_host_trap_stats")
DEFINE_BUFFER_TYPE_NAME(ROCDECODE, "ROCDECODE_API", "rocdecode_api_trace", "rocdecode_api_stats")
#undef DEFINE_BUFFER_TYPE_NAME
+1
Ver fichero
@@ -37,6 +37,7 @@ enum class domain_type
MEMORY_ALLOCATION,
COUNTER_VALUES,
PC_SAMPLING_HOST_TRAP,
ROCDECODE,
LAST,
};
+42
Ver fichero
@@ -722,6 +722,48 @@ generate_csv(const output_config& cfg,
}
}
void
generate_csv(const output_config& cfg,
const metadata& tool_metadata,
const generator<rocprofiler_buffer_tracing_rocdecode_api_record_t>& data,
const stats_entry_t& stats)
{
if(data.empty()) return;
if(cfg.stats && stats)
write_stats(get_stats_output_file(cfg, domain_type::ROCDECODE), stats.entries);
auto ofs = tool::csv_output_file{cfg,
domain_type::ROCDECODE,
tool::csv::api_csv_encoder{},
{"Domain",
"Function",
"Process_Id",
"Thread_Id",
"Correlation_Id",
"Start_Timestamp",
"End_Timestamp"}};
for(auto ditr : data)
{
for(auto record : data.get(ditr))
{
auto row_ss = std::stringstream{};
auto api_name = tool_metadata.get_operation_name(record.kind, record.operation);
rocprofiler::tool::csv::api_csv_encoder::write_row(
row_ss,
tool_metadata.get_kind_name(record.kind),
api_name,
tool_metadata.process_id,
record.thread_id,
record.correlation_id.internal,
record.start_timestamp,
record.end_timestamp);
ofs << row_ss.str();
}
}
}
void
generate_csv(const output_config& cfg,
const metadata& tool_metadata,
+6
Ver fichero
@@ -87,6 +87,12 @@ generate_csv(const output_config& cfg,
const generator<rocprofiler_buffer_tracing_rccl_api_record_t>& data,
const stats_entry_t& stats);
void
generate_csv(const output_config& cfg,
const metadata& tool_metadata,
const generator<rocprofiler_buffer_tracing_rocdecode_api_record_t>& data,
const stats_entry_t& stats);
void
generate_csv(const output_config& cfg,
const metadata& tool_metadata,
+3 -1
Ver fichero
@@ -187,7 +187,8 @@ write_json(json_output& json_ar,
generator<rocprofiler_buffer_tracing_scratch_memory_record_t> scratch_memory_gen,
generator<rocprofiler_buffer_tracing_rccl_api_record_t> rccl_api_gen,
generator<rocprofiler_buffer_tracing_memory_allocation_record_t> memory_allocation_gen,
generator<rocprofiler_tool_pc_sampling_host_trap_record_t> pc_sampling_gen)
generator<rocprofiler_tool_pc_sampling_host_trap_record_t> pc_sampling_gen,
generator<rocprofiler_buffer_tracing_rocdecode_api_record_t> rocdecode_api_gen)
{
// summary
@@ -229,6 +230,7 @@ write_json(json_output& json_ar,
json_ar(cereal::make_nvp("memory_allocation", memory_allocation_gen));
json_ar(cereal::make_nvp("scratch_memory", scratch_memory_gen));
json_ar(cereal::make_nvp("pc_sample_host_trap", pc_sampling_gen));
json_ar(cereal::make_nvp("rocdecode_api", rocdecode_api_gen));
json_ar.finishNode();
}
}
+3 -1
Ver fichero
@@ -94,6 +94,8 @@ write_json(json_output& json
generator<rocprofiler_buffer_tracing_scratch_memory_record_t> scratch_memory_gen,
generator<rocprofiler_buffer_tracing_rccl_api_record_t> rccl_api_gen,
generator<rocprofiler_buffer_tracing_memory_allocation_record_t> memory_allocation_gen,
generator<rocprofiler_tool_pc_sampling_host_trap_record_t> pc_sampling_gen);
generator<rocprofiler_tool_pc_sampling_host_trap_record_t> pc_sampling_gen,
generator<rocprofiler_buffer_tracing_rocdecode_api_record_t> rocdecode_api_gen);
} // namespace tool
} // namespace rocprofiler
+5 -1
Ver fichero
@@ -367,7 +367,8 @@ write_otf2(
std::deque<rocprofiler_buffer_tracing_marker_api_record_t>* marker_api_data,
std::deque<rocprofiler_buffer_tracing_scratch_memory_record_t>* /*scratch_memory_data*/,
std::deque<rocprofiler_buffer_tracing_rccl_api_record_t>* rccl_api_data,
std::deque<rocprofiler_buffer_tracing_memory_allocation_record_t>* memory_allocation_data)
std::deque<rocprofiler_buffer_tracing_memory_allocation_record_t>* memory_allocation_data,
std::deque<rocprofiler_buffer_tracing_rocdecode_api_record_t>* rocdecode_api_data)
{
namespace sdk = ::rocprofiler::sdk;
@@ -418,6 +419,8 @@ write_otf2(
tids.emplace(itr.thread_id);
for(auto itr : *rccl_api_data)
tids.emplace(itr.thread_id);
for(auto itr : *rocdecode_api_data)
tids.emplace(itr.thread_id);
for(auto itr : *memory_copy_data)
{
@@ -614,6 +617,7 @@ write_otf2(
add_event_data(hip_api_data, sdk::category::hip_api{});
add_event_data(marker_api_data, sdk::category::marker_api{});
add_event_data(rccl_api_data, sdk::category::rccl_api{});
add_event_data(rocdecode_api_data, sdk::category::rocdecode_api{});
}
for(auto itr : *memory_copy_data)
+2 -1
Ver fichero
@@ -46,6 +46,7 @@ write_otf2(
std::deque<rocprofiler_buffer_tracing_marker_api_record_t>* marker_api_data,
std::deque<rocprofiler_buffer_tracing_scratch_memory_record_t>* scratch_memory_data,
std::deque<rocprofiler_buffer_tracing_rccl_api_record_t>* rccl_api_data,
std::deque<rocprofiler_buffer_tracing_memory_allocation_record_t>* memory_allocation_data);
std::deque<rocprofiler_buffer_tracing_memory_allocation_record_t>* memory_allocation_data,
std::deque<rocprofiler_buffer_tracing_rocdecode_api_record_t>* rocdecode_api_data);
} // namespace tool
} // namespace rocprofiler
+36 -1
Ver fichero
@@ -72,7 +72,8 @@ write_perfetto(
const generator<rocprofiler_buffer_tracing_marker_api_record_t>& marker_api_gen,
const generator<rocprofiler_buffer_tracing_scratch_memory_record_t>& /*scratch_memory_gen*/,
const generator<rocprofiler_buffer_tracing_rccl_api_record_t>& rccl_api_gen,
const generator<rocprofiler_buffer_tracing_memory_allocation_record_t>& memory_allocation_gen)
const generator<rocprofiler_buffer_tracing_memory_allocation_record_t>& memory_allocation_gen,
const generator<rocprofiler_buffer_tracing_rocdecode_api_record_t>& rocdecode_api_gen)
{
namespace sdk = ::rocprofiler::sdk;
@@ -168,6 +169,9 @@ write_perfetto(
for(auto ditr : rccl_api_gen)
for(auto itr : rccl_api_gen.get(ditr))
tids.emplace(itr.thread_id);
for(auto ditr : rocdecode_api_gen)
for(auto itr : rocdecode_api_gen.get(ditr))
tids.emplace(itr.thread_id);
for(auto ditr : memory_copy_gen)
for(auto itr : memory_copy_gen.get(ditr))
@@ -399,6 +403,37 @@ write_perfetto(
tracing_session->FlushBlocking();
}
for(auto ditr : rocdecode_api_gen)
for(auto itr : rocdecode_api_gen.get(ditr))
{
auto name = buffer_names.at(itr.kind, itr.operation);
auto& track = thread_tracks.at(itr.thread_id);
TRACE_EVENT_BEGIN(sdk::perfetto_category<sdk::category::rocdecode_api>::name,
::perfetto::StaticString(name.data()),
track,
itr.start_timestamp,
::perfetto::Flow::ProcessScoped(itr.correlation_id.internal),
"begin_ns",
itr.start_timestamp,
"end_ns",
itr.end_timestamp,
"delta_ns",
(itr.end_timestamp - itr.start_timestamp),
"tid",
itr.thread_id,
"kind",
itr.kind,
"operation",
itr.operation,
"corr_id",
itr.correlation_id.internal);
TRACE_EVENT_END(sdk::perfetto_category<sdk::category::rocdecode_api>::name,
track,
itr.end_timestamp);
tracing_session->FlushBlocking();
}
for(auto ditr : memory_copy_gen)
for(auto itr : memory_copy_gen.get(ditr))
{
+2 -1
Ver fichero
@@ -46,6 +46,7 @@ write_perfetto(
const generator<rocprofiler_buffer_tracing_marker_api_record_t>& marker_api_gen,
const generator<rocprofiler_buffer_tracing_scratch_memory_record_t>& scratch_memory_gen,
const generator<rocprofiler_buffer_tracing_rccl_api_record_t>& rccl_api_gen,
const generator<rocprofiler_buffer_tracing_memory_allocation_record_t>& memory_allocation_gen);
const generator<rocprofiler_buffer_tracing_memory_allocation_record_t>& memory_allocation_gen,
const generator<rocprofiler_buffer_tracing_rocdecode_api_record_t>& rocdecode_api_gen);
} // namespace tool
} // namespace rocprofiler
+18
Ver fichero
@@ -228,6 +228,24 @@ generate_stats(const output_config& /*cfg*/,
return get_stats(rccl_stats);
}
stats_entry_t
generate_stats(const output_config& /*cfg*/,
const metadata& tool_metadata,
const generator<rocprofiler_buffer_tracing_rocdecode_api_record_t>& data)
{
auto rocdecode_stats = stats_map_t{};
for(auto ditr : data)
{
for(auto record : data.get(ditr))
{
auto api_name = tool_metadata.get_operation_name(record.kind, record.operation);
rocdecode_stats[api_name] += (record.end_timestamp - record.start_timestamp);
}
}
return get_stats(rocdecode_stats);
}
namespace
{
void
+5
Ver fichero
@@ -75,6 +75,11 @@ generate_stats(const output_config& cfg,
const metadata& tool_metadata,
const generator<rocprofiler_buffer_tracing_memory_allocation_record_t>& data);
stats_entry_t
generate_stats(const output_config& cfg,
const metadata& tool_metadata,
const generator<rocprofiler_buffer_tracing_rocdecode_api_record_t>& data);
stats_entry_t
generate_stats(const output_config& cfg,
const metadata& tool_metadata,