rocDecode Buffer Tracing Support (#315)
* Added buffer tracing support for rocdecode and updated tests to work with buffer tracing
* Updated perfetto to output args individually rather than as a string list
* Updated docstrings and operation type, changed OTF2 code to remove warning due to change in operation type
* Updated tests for review comments
* Test args exist and return value
* Updated to use string entry
* Change function name
* Updated PR to reflect review comments
* Updated for PR review comments
* Change function name
[ROCm/rocprofiler-sdk commit: 077723337a]
This commit is contained in:
@@ -503,6 +503,8 @@ Here are the contents of ``rocdecode_api_trace.csv`` file:
|
||||
:widths: 10,10,10,10,10,20,20
|
||||
:header-rows: 1
|
||||
|
||||
Perfetto will also show rocDeocde API arguments. Pointers will not be dereferenced and only the address will be displayed.
|
||||
|
||||
rocJPEG trace
|
||||
+++++++++++++++
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include <rocprofiler-sdk/fwd.h>
|
||||
#include <rocprofiler-sdk/hip/api_args.h>
|
||||
#include <rocprofiler-sdk/kfd/page_migration_args.h>
|
||||
#include <rocprofiler-sdk/rocdecode/api_args.h>
|
||||
#include <rocprofiler-sdk/rocdecode/api_id.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -213,7 +215,7 @@ typedef struct rocprofiler_buffer_tracing_rocdecode_api_record_t
|
||||
{
|
||||
uint64_t size; ///< size of this struct
|
||||
rocprofiler_buffer_tracing_kind_t kind;
|
||||
rocprofiler_tracing_operation_t operation;
|
||||
rocprofiler_rocdecode_api_id_t operation;
|
||||
rocprofiler_correlation_id_t correlation_id; ///< correlation ids for record
|
||||
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
|
||||
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
|
||||
@@ -225,6 +227,29 @@ typedef struct rocprofiler_buffer_tracing_rocdecode_api_record_t
|
||||
/// @brief Specification of the API function, e.g., ::rocprofiler_rocdecode_api_id_t
|
||||
} rocprofiler_buffer_tracing_rocdecode_api_record_t;
|
||||
|
||||
/**
|
||||
* @brief An extended ROCProfiler rocDecode API Tracer Record which includes function arguments.
|
||||
* Pointers are not dereferenced.
|
||||
*/
|
||||
typedef struct rocprofiler_buffer_tracing_rocdecode_api_ext_record_t
|
||||
{
|
||||
uint64_t size; ///< size of this struct
|
||||
rocprofiler_buffer_tracing_kind_t kind;
|
||||
rocprofiler_rocdecode_api_id_t operation;
|
||||
rocprofiler_correlation_id_t correlation_id; ///< correlation ids for record
|
||||
rocprofiler_timestamp_t start_timestamp; ///< start time in nanoseconds
|
||||
rocprofiler_timestamp_t end_timestamp; ///< end time in nanoseconds
|
||||
rocprofiler_thread_id_t thread_id; ///< id for thread generating this record
|
||||
rocprofiler_rocdecode_api_args_t args; ///< arguments of function call
|
||||
rocprofiler_rocdecode_api_retval_t retval; ///< return value of function call
|
||||
|
||||
/// @var kind
|
||||
/// @brief ::ROCPROFILER_BUFFER_TRACING_ROCDECODE_API_EXT
|
||||
/// @var operation
|
||||
/// @brief Specification of the API function (@see
|
||||
/// ::rocprofiler_rocdecode_api_id_t)
|
||||
} rocprofiler_buffer_tracing_rocdecode_api_ext_record_t;
|
||||
|
||||
/**
|
||||
* @brief ROCProfiler Buffer rocJPEG API Record.
|
||||
*/
|
||||
@@ -241,7 +266,8 @@ typedef struct rocprofiler_buffer_tracing_rocjpeg_api_record_t
|
||||
/// @var kind
|
||||
/// @brief ::ROCPROFILER_CALLBACK_TRACING_ROCJPEG_API
|
||||
/// @var operation
|
||||
/// @brief Specification of the API function, e.g., ::rocprofiler_rocjpeg_api_id_t
|
||||
/// @brief Specification of the API function (@see
|
||||
/// ::rocprofiler_rocjpeg_api_id_t)
|
||||
} rocprofiler_buffer_tracing_rocjpeg_api_record_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -469,7 +469,7 @@ template <typename ArchiveT>
|
||||
void
|
||||
save(ArchiveT& ar, rocprofiler_rocdecode_api_retval_t data)
|
||||
{
|
||||
ROCP_SDK_SAVE_DATA_FIELD(rocDecStatus_retval);
|
||||
ROCP_SDK_SAVE_DATA_FIELD(uint64_t_retval);
|
||||
}
|
||||
|
||||
template <typename ArchiveT>
|
||||
@@ -605,6 +605,16 @@ save(ArchiveT& ar, rocprofiler_buffer_tracing_rocdecode_api_record_t data)
|
||||
save_buffer_tracing_api_record(ar, data);
|
||||
}
|
||||
|
||||
template <typename ArchiveT>
|
||||
void
|
||||
save(ArchiveT& ar, rocprofiler_buffer_tracing_rocdecode_api_ext_record_t data)
|
||||
{
|
||||
save_buffer_tracing_api_record(ar, data);
|
||||
auto args = sdk::serialization::get_buffer_tracing_args(data);
|
||||
ROCP_SDK_SAVE_VALUE("args", args);
|
||||
ROCP_SDK_SAVE_DATA_FIELD(retval);
|
||||
}
|
||||
|
||||
template <typename ArchiveT>
|
||||
void
|
||||
save(ArchiveT& ar, rocprofiler_buffer_tracing_rocjpeg_api_record_t data)
|
||||
|
||||
@@ -211,6 +211,7 @@ typedef enum rocprofiler_buffer_tracing_kind_t // NOLINT(performance-enum-size)
|
||||
ROCPROFILER_BUFFER_TRACING_HIP_STREAM, ///< @see ::rocprofiler_hip_stream_operation_t
|
||||
ROCPROFILER_BUFFER_TRACING_HIP_RUNTIME_API_EXT,
|
||||
ROCPROFILER_BUFFER_TRACING_HIP_COMPILER_API_EXT,
|
||||
ROCPROFILER_BUFFER_TRACING_ROCDECODE_API_EXT,
|
||||
ROCPROFILER_BUFFER_TRACING_LAST,
|
||||
|
||||
/// @var ROCPROFILER_BUFFER_TRACING_HIP_RUNTIME_API_EXT
|
||||
@@ -219,6 +220,9 @@ typedef enum rocprofiler_buffer_tracing_kind_t // NOLINT(performance-enum-size)
|
||||
/// @var ROCPROFILER_BUFFER_TRACING_HIP_COMPILER_API_EXT
|
||||
/// @brief Similar to ROCPROFILER_BUFFER_TRACING_HIP_COMPILER_API except the buffer record
|
||||
/// contains the function argument(s) and return value
|
||||
/// @var ROCPROFILER_BUFFER_TRACING_ROCDECODE_API_EXT
|
||||
/// @brief Similar to ROCPROFILER_BUFFER_TRACING_ROCDECODE_API except the buffer record
|
||||
/// contains the function argument(s) and return value
|
||||
} rocprofiler_buffer_tracing_kind_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,6 +51,7 @@ typedef struct rocprofiler_rocdecode_api_no_args
|
||||
|
||||
typedef union rocprofiler_rocdecode_api_retval_t
|
||||
{
|
||||
uint64_t uint64_t_retval;
|
||||
int32_t rocDecStatus_retval;
|
||||
const char* const_charp_retval;
|
||||
} rocprofiler_rocdecode_api_retval_t;
|
||||
|
||||
@@ -160,7 +160,7 @@ 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>;
|
||||
buffered_output<rocprofiler_buffer_tracing_rocdecode_api_ext_record_t, domain_type::ROCDECODE>;
|
||||
using rocjpeg_buffered_output_t =
|
||||
buffered_output<rocprofiler_buffer_tracing_rocjpeg_api_record_t, domain_type::ROCJPEG>;
|
||||
using kernel_dispatch_buffered_output_with_stream_t =
|
||||
|
||||
@@ -735,10 +735,10 @@ 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)
|
||||
generate_csv(const output_config& cfg,
|
||||
const metadata& tool_metadata,
|
||||
const generator<rocprofiler_buffer_tracing_rocdecode_api_ext_record_t>& data,
|
||||
const stats_entry_t& stats)
|
||||
{
|
||||
if(data.empty()) return;
|
||||
|
||||
|
||||
@@ -88,10 +88,10 @@ generate_csv(const output_config& cfg,
|
||||
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);
|
||||
generate_csv(const output_config& cfg,
|
||||
const metadata& tool_metadata,
|
||||
const generator<rocprofiler_buffer_tracing_rocdecode_api_ext_record_t>& data,
|
||||
const stats_entry_t& stats);
|
||||
|
||||
void
|
||||
generate_csv(const output_config& cfg,
|
||||
|
||||
@@ -196,7 +196,7 @@ 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_buffer_tracing_rocdecode_api_record_t> rocdecode_api_gen,
|
||||
generator<rocprofiler_buffer_tracing_rocdecode_api_ext_record_t> rocdecode_api_gen,
|
||||
generator<rocprofiler_buffer_tracing_rocjpeg_api_record_t> rocjpeg_api_gen,
|
||||
generator<rocprofiler_tool_pc_sampling_host_trap_record_t> pc_sampling_host_trap_gen,
|
||||
generator<rocprofiler_tool_pc_sampling_stochastic_record_t> pc_sampling_stochastic_gen)
|
||||
|
||||
@@ -94,7 +94,7 @@ write_json(json_output& j
|
||||
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_buffer_tracing_rocdecode_api_record_t> rocdecode_api_gen,
|
||||
generator<rocprofiler_buffer_tracing_rocdecode_api_ext_record_t> rocdecode_api_gen,
|
||||
generator<rocprofiler_buffer_tracing_rocjpeg_api_record_t> rocjpeg_api_gen,
|
||||
generator<rocprofiler_tool_pc_sampling_host_trap_record_t> pc_sampling_host_trap_gen,
|
||||
generator<rocprofiler_tool_pc_sampling_stochastic_record_t> pc_sampling_stochastic_gen);
|
||||
|
||||
@@ -368,7 +368,7 @@ write_otf2(
|
||||
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_rocdecode_api_record_t>* rocdecode_api_data,
|
||||
std::deque<rocprofiler_buffer_tracing_rocdecode_api_ext_record_t>* rocdecode_api_data,
|
||||
std::deque<rocprofiler_buffer_tracing_rocjpeg_api_record_t>* rocjpeg_api_data)
|
||||
{
|
||||
namespace sdk = ::rocprofiler::sdk;
|
||||
@@ -618,10 +618,31 @@ 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{});
|
||||
add_event_data(rocjpeg_api_data, sdk::category::rocjpeg_api{});
|
||||
}
|
||||
|
||||
for(auto itr : *rocdecode_api_data)
|
||||
{
|
||||
auto name = buffer_names.at(itr.kind, itr.operation);
|
||||
_hash_data.emplace(
|
||||
get_hash_id(name),
|
||||
region_info{std::string{name}, OTF2_REGION_ROLE_FUNCTION, OTF2_PARADIGM_USER});
|
||||
|
||||
auto& _evt_info = thread_event_info.at(itr.thread_id);
|
||||
_evt_info.event_count += 1;
|
||||
|
||||
_data.emplace_back(evt_data{ROCPROFILER_CALLBACK_PHASE_ENTER,
|
||||
name,
|
||||
_evt_info.get_location(),
|
||||
itr.start_timestamp,
|
||||
get_attr(sdk::category::rocdecode_api{})});
|
||||
_data.emplace_back(evt_data{ROCPROFILER_CALLBACK_PHASE_EXIT,
|
||||
name,
|
||||
_evt_info.get_location(),
|
||||
itr.end_timestamp,
|
||||
nullptr});
|
||||
}
|
||||
|
||||
for(auto itr : *memory_copy_data)
|
||||
{
|
||||
auto name = buffer_names.at(itr.kind, itr.operation);
|
||||
|
||||
@@ -48,7 +48,7 @@ write_otf2(
|
||||
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_rocdecode_api_record_t>* rocdecode_api_data,
|
||||
std::deque<rocprofiler_buffer_tracing_rocdecode_api_ext_record_t>* rocdecode_api_data,
|
||||
std::deque<rocprofiler_buffer_tracing_rocjpeg_api_record_t>* rocjpeg_api_data);
|
||||
} // namespace tool
|
||||
} // namespace rocprofiler
|
||||
|
||||
@@ -77,7 +77,7 @@ write_perfetto(
|
||||
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_rocdecode_api_record_t>& rocdecode_api_gen,
|
||||
const generator<rocprofiler_buffer_tracing_rocdecode_api_ext_record_t>& rocdecode_api_gen,
|
||||
const generator<rocprofiler_buffer_tracing_rocjpeg_api_record_t>& rocjpeg_api_gen)
|
||||
{
|
||||
namespace sdk = ::rocprofiler::sdk;
|
||||
@@ -493,8 +493,9 @@ write_perfetto(
|
||||
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);
|
||||
auto name = buffer_names.at(itr.kind, itr.operation);
|
||||
auto& track = thread_tracks.at(itr.thread_id);
|
||||
auto rocdecode_args = sdk::serialization::get_buffer_tracing_args(itr);
|
||||
|
||||
TRACE_EVENT_BEGIN(sdk::perfetto_category<sdk::category::rocdecode_api>::name,
|
||||
::perfetto::StaticString(name.data()),
|
||||
@@ -516,7 +517,14 @@ write_perfetto(
|
||||
"corr_id",
|
||||
itr.correlation_id.internal,
|
||||
"ancestor_id",
|
||||
itr.correlation_id.ancestor);
|
||||
itr.correlation_id.ancestor,
|
||||
[&](::perfetto::EventContext ctx) {
|
||||
for(const auto& rocdecode_arg : rocdecode_args)
|
||||
{
|
||||
sdk::add_perfetto_annotation(
|
||||
ctx, rocdecode_arg.name, rocdecode_arg.value);
|
||||
}
|
||||
});
|
||||
TRACE_EVENT_END(sdk::perfetto_category<sdk::category::rocdecode_api>::name,
|
||||
track,
|
||||
itr.end_timestamp);
|
||||
|
||||
@@ -49,7 +49,7 @@ write_perfetto(
|
||||
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_rocdecode_api_record_t>& rocdecode_api_gen,
|
||||
const generator<rocprofiler_buffer_tracing_rocdecode_api_ext_record_t>& rocdecode_api_gen,
|
||||
const generator<rocprofiler_buffer_tracing_rocjpeg_api_record_t>& rocjpeg_api_gen);
|
||||
} // namespace tool
|
||||
} // namespace rocprofiler
|
||||
|
||||
@@ -230,8 +230,8 @@ generate_stats(const output_config& /*cfg*/,
|
||||
|
||||
stats_entry_t
|
||||
generate_stats(const output_config& /*cfg*/,
|
||||
const metadata& tool_metadata,
|
||||
const generator<rocprofiler_buffer_tracing_rocdecode_api_record_t>& data)
|
||||
const metadata& tool_metadata,
|
||||
const generator<rocprofiler_buffer_tracing_rocdecode_api_ext_record_t>& data)
|
||||
{
|
||||
auto rocdecode_stats = stats_map_t{};
|
||||
for(auto ditr : data)
|
||||
|
||||
@@ -77,9 +77,9 @@ generate_stats(const output_config& cfg,
|
||||
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);
|
||||
generate_stats(const output_config& cfg,
|
||||
const metadata& tool_metadata,
|
||||
const generator<rocprofiler_buffer_tracing_rocdecode_api_ext_record_t>& data);
|
||||
|
||||
stats_entry_t
|
||||
generate_stats(const output_config& cfg,
|
||||
|
||||
@@ -962,9 +962,9 @@ buffered_tracing_callback(rocprofiler_context_id_t /*context*/,
|
||||
|
||||
tool::write_ring_buffer(*record, domain_type::RCCL);
|
||||
}
|
||||
else if(header->kind == ROCPROFILER_BUFFER_TRACING_ROCDECODE_API)
|
||||
else if(header->kind == ROCPROFILER_BUFFER_TRACING_ROCDECODE_API_EXT)
|
||||
{
|
||||
auto* record = static_cast<rocprofiler_buffer_tracing_rocdecode_api_record_t*>(
|
||||
auto* record = static_cast<rocprofiler_buffer_tracing_rocdecode_api_ext_record_t*>(
|
||||
header->payload);
|
||||
|
||||
tool::write_ring_buffer(*record, domain_type::ROCDECODE);
|
||||
@@ -1747,13 +1747,13 @@ tool_init(rocprofiler_client_finalize_t fini_func, void* tool_data)
|
||||
&get_buffers().rocdecode_api_trace),
|
||||
"buffer creation");
|
||||
|
||||
ROCPROFILER_CALL(
|
||||
rocprofiler_configure_buffer_tracing_service(get_client_ctx(),
|
||||
ROCPROFILER_BUFFER_TRACING_ROCDECODE_API,
|
||||
nullptr,
|
||||
0,
|
||||
get_buffers().rocdecode_api_trace),
|
||||
"buffer tracing service for ROCDecode api configure");
|
||||
ROCPROFILER_CALL(rocprofiler_configure_buffer_tracing_service(
|
||||
get_client_ctx(),
|
||||
ROCPROFILER_BUFFER_TRACING_ROCDECODE_API_EXT,
|
||||
nullptr,
|
||||
0,
|
||||
get_buffers().rocdecode_api_trace),
|
||||
"buffer tracing service for ROCDecode api configure");
|
||||
}
|
||||
|
||||
if(tool::get_config().rocjpeg_api_trace)
|
||||
|
||||
@@ -102,6 +102,7 @@ ROCPROFILER_BUFFER_TRACING_KIND_STRING(ROCJPEG_API)
|
||||
ROCPROFILER_BUFFER_TRACING_KIND_STRING(HIP_STREAM)
|
||||
ROCPROFILER_BUFFER_TRACING_KIND_STRING(HIP_RUNTIME_API_EXT)
|
||||
ROCPROFILER_BUFFER_TRACING_KIND_STRING(HIP_COMPILER_API_EXT)
|
||||
ROCPROFILER_BUFFER_TRACING_KIND_STRING(ROCDECODE_API_EXT)
|
||||
|
||||
template <size_t Idx, size_t... Tail>
|
||||
std::pair<const char*, size_t>
|
||||
@@ -302,6 +303,7 @@ rocprofiler_query_buffer_tracing_kind_operation_name(rocprofiler_buffer_tracing_
|
||||
return ROCPROFILER_STATUS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
case ROCPROFILER_BUFFER_TRACING_ROCDECODE_API:
|
||||
case ROCPROFILER_BUFFER_TRACING_ROCDECODE_API_EXT:
|
||||
{
|
||||
val =
|
||||
rocprofiler::rocdecode::name_by_id<ROCPROFILER_ROCDECODE_TABLE_ID_CORE>(operation);
|
||||
@@ -451,6 +453,7 @@ rocprofiler_iterate_buffer_tracing_kind_operations(
|
||||
return ROCPROFILER_STATUS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
case ROCPROFILER_BUFFER_TRACING_ROCDECODE_API:
|
||||
case ROCPROFILER_BUFFER_TRACING_ROCDECODE_API_EXT:
|
||||
{
|
||||
ops = rocprofiler::rocdecode::get_ids<ROCPROFILER_ROCDECODE_TABLE_ID_CORE>();
|
||||
break;
|
||||
@@ -518,6 +521,14 @@ rocprofiler_iterate_buffer_tracing_record_args(
|
||||
_payload->operation, _payload->args, callback, user_data);
|
||||
return ROCPROFILER_STATUS_SUCCESS;
|
||||
}
|
||||
case ROCPROFILER_BUFFER_TRACING_ROCDECODE_API_EXT:
|
||||
{
|
||||
auto* _payload =
|
||||
static_cast<rocprofiler_buffer_tracing_rocdecode_api_ext_record_t*>(record.payload);
|
||||
rocprofiler::rocdecode::iterate_args<ROCPROFILER_ROCDECODE_TABLE_ID_CORE>(
|
||||
_payload->operation, _payload->args, callback, user_data);
|
||||
return ROCPROFILER_STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return ROCPROFILER_STATUS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
@@ -574,6 +574,17 @@ rocprofiler_iterate_callback_tracing_kind_operation_args(
|
||||
user_data);
|
||||
return ROCPROFILER_STATUS_SUCCESS;
|
||||
}
|
||||
case ROCPROFILER_CALLBACK_TRACING_ROCDECODE_API:
|
||||
{
|
||||
rocprofiler::rocdecode::iterate_args<ROCPROFILER_ROCDECODE_TABLE_ID_CORE>(
|
||||
record.operation,
|
||||
static_cast<rocprofiler_callback_tracing_rocdecode_api_data_t*>(record.payload)
|
||||
->args,
|
||||
callback,
|
||||
max_deref,
|
||||
user_data);
|
||||
return ROCPROFILER_STATUS_SUCCESS;
|
||||
}
|
||||
case ROCPROFILER_CALLBACK_TRACING_SCRATCH_MEMORY:
|
||||
case ROCPROFILER_CALLBACK_TRACING_CODE_OBJECT:
|
||||
case ROCPROFILER_CALLBACK_TRACING_KERNEL_DISPATCH:
|
||||
@@ -581,7 +592,6 @@ rocprofiler_iterate_callback_tracing_kind_operation_args(
|
||||
case ROCPROFILER_CALLBACK_TRACING_MEMORY_ALLOCATION:
|
||||
case ROCPROFILER_CALLBACK_TRACING_RCCL_API:
|
||||
case ROCPROFILER_CALLBACK_TRACING_RUNTIME_INITIALIZATION:
|
||||
case ROCPROFILER_CALLBACK_TRACING_ROCDECODE_API:
|
||||
case ROCPROFILER_CALLBACK_TRACING_ROCJPEG_API:
|
||||
case ROCPROFILER_CALLBACK_TRACING_HIP_STREAM:
|
||||
{
|
||||
|
||||
@@ -94,9 +94,14 @@
|
||||
return &base_type::functor<RetT, Args...>; \
|
||||
} \
|
||||
\
|
||||
static std::vector<void*> as_arg_addr(callback_data_type) { return std::vector<void*>{}; } \
|
||||
static std::vector<void*> as_arg_addr(rocprofiler_rocdecode_api_args_t) \
|
||||
{ \
|
||||
return std::vector<void*>{}; \
|
||||
} \
|
||||
\
|
||||
static std::vector<common::stringified_argument> as_arg_list(callback_data_type, int32_t) \
|
||||
static std::vector<common::stringified_argument> as_arg_list( \
|
||||
rocprofiler_rocdecode_api_args_t, \
|
||||
int32_t) \
|
||||
{ \
|
||||
return {}; \
|
||||
} \
|
||||
@@ -175,16 +180,15 @@
|
||||
return &base_type::functor<RetT, Args...>; \
|
||||
} \
|
||||
\
|
||||
static std::vector<void*> as_arg_addr(callback_data_type trace_data) \
|
||||
static std::vector<void*> as_arg_addr(rocprofiler_rocdecode_api_args_t args) \
|
||||
{ \
|
||||
return std::vector<void*>{ \
|
||||
GET_ADDR_MEMBER_FIELDS(get_api_data_args(trace_data.args), __VA_ARGS__)}; \
|
||||
GET_ADDR_MEMBER_FIELDS(get_api_data_args(args), __VA_ARGS__)}; \
|
||||
} \
|
||||
static auto as_arg_list(callback_data_type trace_data, int32_t max_deref) \
|
||||
static auto as_arg_list(rocprofiler_rocdecode_api_args_t args, int32_t max_deref) \
|
||||
{ \
|
||||
return utils::stringize( \
|
||||
max_deref, \
|
||||
GET_NAMED_MEMBER_FIELDS(get_api_data_args(trace_data.args), __VA_ARGS__)); \
|
||||
max_deref, GET_NAMED_MEMBER_FIELDS(get_api_data_args(args), __VA_ARGS__)); \
|
||||
} \
|
||||
}; \
|
||||
} \
|
||||
|
||||
@@ -22,11 +22,11 @@
|
||||
|
||||
#include "lib/rocprofiler-sdk/rocdecode/rocdecode.hpp"
|
||||
#include "lib/common/defines.hpp"
|
||||
#include "lib/common/mpl.hpp"
|
||||
#include "lib/common/static_object.hpp"
|
||||
#include "lib/common/string_entry.hpp"
|
||||
#include "lib/rocprofiler-sdk/buffer.hpp"
|
||||
#include "lib/rocprofiler-sdk/context/context.hpp"
|
||||
#include "lib/rocprofiler-sdk/hip/hip.hpp"
|
||||
#include "lib/rocprofiler-sdk/hip/utils.hpp"
|
||||
#include "lib/rocprofiler-sdk/registration.hpp"
|
||||
#include "lib/rocprofiler-sdk/tracing/tracing.hpp"
|
||||
|
||||
@@ -35,11 +35,6 @@
|
||||
#include <rocprofiler-sdk/fwd.h>
|
||||
#include <rocprofiler-sdk/rocdecode/table_id.h>
|
||||
|
||||
#include <hip/driver_types.h>
|
||||
#include <hip/hip_runtime_api.h>
|
||||
// must be included after runtime api
|
||||
#include <hip/hip_deprecated.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
@@ -101,6 +96,23 @@ template <size_t TableIdx>
|
||||
auto*
|
||||
get_table();
|
||||
|
||||
template <typename Tp>
|
||||
decltype(auto)
|
||||
convert_arg(Tp&& val)
|
||||
{
|
||||
using data_type = common::mpl::unqualified_type_t<Tp>;
|
||||
if constexpr(std::is_same<data_type, const char*>::value)
|
||||
{
|
||||
return common::get_string_entry(val)->c_str();
|
||||
}
|
||||
else
|
||||
{
|
||||
static_assert(!common::mpl::is_string_type<data_type>::value,
|
||||
"argument type is a string type. preceding if constexpr is incorrect");
|
||||
return std::forward<Tp>(val);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
template <size_t TableIdx, size_t OpIdx>
|
||||
@@ -149,6 +161,7 @@ rocdecode_api_impl<TableIdx, OpIdx>::functor(Args... args)
|
||||
using info_type = rocdecode_api_info<TableIdx, OpIdx>;
|
||||
using callback_api_data_t = typename rocdecode_domain_info<TableIdx>::callback_data_type;
|
||||
using buffered_api_data_t = typename rocdecode_domain_info<TableIdx>::buffer_data_type;
|
||||
using buffered_ext_data_t = typename rocdecode_domain_info<TableIdx>::buffered_ext_data_type;
|
||||
|
||||
constexpr auto external_corr_id_domain_idx =
|
||||
rocdecode_domain_info<TableIdx>::external_correlation_id_domain_idx;
|
||||
@@ -166,6 +179,7 @@ rocdecode_api_impl<TableIdx, OpIdx>::functor(Args... args)
|
||||
auto thr_id = common::get_tid();
|
||||
auto callback_contexts = tracing::callback_context_data_vec_t{};
|
||||
auto buffered_contexts = tracing::buffered_context_data_vec_t{};
|
||||
auto extended_contexts = tracing::buffered_context_data_vec_t{};
|
||||
auto external_corr_ids = tracing::external_correlation_id_map_t{};
|
||||
|
||||
tracing::populate_contexts(info_type::callback_domain_idx,
|
||||
@@ -174,8 +188,12 @@ rocdecode_api_impl<TableIdx, OpIdx>::functor(Args... args)
|
||||
callback_contexts,
|
||||
buffered_contexts,
|
||||
external_corr_ids);
|
||||
tracing::populate_contexts(info_type::buffered_ext_domain_idx,
|
||||
info_type::operation_idx,
|
||||
extended_contexts,
|
||||
external_corr_ids);
|
||||
|
||||
if(callback_contexts.empty() && buffered_contexts.empty())
|
||||
if(callback_contexts.empty() && buffered_contexts.empty() && extended_contexts.empty())
|
||||
{
|
||||
[[maybe_unused]] auto _ret = exec(info_type::get_table_func(), std::forward<Args>(args)...);
|
||||
if constexpr(!std::is_void<RetT>::value)
|
||||
@@ -185,6 +203,7 @@ rocdecode_api_impl<TableIdx, OpIdx>::functor(Args... args)
|
||||
}
|
||||
|
||||
auto buffer_record = common::init_public_api_struct(buffered_api_data_t{});
|
||||
auto extended_record = common::init_public_api_struct(buffered_ext_data_t{});
|
||||
auto tracer_data = common::init_public_api_struct(callback_api_data_t{});
|
||||
auto* corr_id = tracing::correlation_service::construct(ref_count);
|
||||
auto internal_corr_id = corr_id->internal;
|
||||
@@ -196,11 +215,16 @@ rocdecode_api_impl<TableIdx, OpIdx>::functor(Args... args)
|
||||
info_type::operation_idx,
|
||||
internal_corr_id);
|
||||
|
||||
// set the arguments
|
||||
if(!callback_contexts.empty() || !extended_contexts.empty())
|
||||
{
|
||||
set_data_args(info_type::get_api_data_args(tracer_data.args),
|
||||
convert_arg(std::forward<Args>(args))...);
|
||||
}
|
||||
|
||||
// invoke the callbacks
|
||||
if(!callback_contexts.empty())
|
||||
{
|
||||
set_data_args(info_type::get_api_data_args(tracer_data.args), std::forward<Args>(args)...);
|
||||
|
||||
tracing::execute_phase_enter_callbacks(callback_contexts,
|
||||
thr_id,
|
||||
internal_corr_id,
|
||||
@@ -216,7 +240,7 @@ rocdecode_api_impl<TableIdx, OpIdx>::functor(Args... args)
|
||||
external_corr_ids, thr_id, external_corr_id_domain_idx);
|
||||
|
||||
// record the start timestamp as close to the function call as possible
|
||||
if(!buffered_contexts.empty())
|
||||
if(!buffered_contexts.empty() || !extended_contexts.empty())
|
||||
{
|
||||
buffer_record.start_timestamp = common::timestamp_ns();
|
||||
}
|
||||
@@ -227,15 +251,18 @@ rocdecode_api_impl<TableIdx, OpIdx>::functor(Args... args)
|
||||
auto _ret = exec(info_type::get_table_func(), std::forward<Args>(args)...);
|
||||
|
||||
// record the end timestamp as close to the function call as possible
|
||||
if(!buffered_contexts.empty())
|
||||
if(!buffered_contexts.empty() || !extended_contexts.empty())
|
||||
{
|
||||
buffer_record.end_timestamp = common::timestamp_ns();
|
||||
}
|
||||
|
||||
if(!callback_contexts.empty())
|
||||
if(!callback_contexts.empty() || !extended_contexts.empty())
|
||||
{
|
||||
set_data_retval(tracer_data.retval, _ret);
|
||||
}
|
||||
|
||||
if(!callback_contexts.empty())
|
||||
{
|
||||
tracing::execute_phase_exit_callbacks(callback_contexts,
|
||||
external_corr_ids,
|
||||
info_type::callback_domain_idx,
|
||||
@@ -255,6 +282,23 @@ rocdecode_api_impl<TableIdx, OpIdx>::functor(Args... args)
|
||||
buffer_record);
|
||||
}
|
||||
|
||||
if(!extended_contexts.empty())
|
||||
{
|
||||
extended_record.start_timestamp = buffer_record.start_timestamp;
|
||||
extended_record.end_timestamp = buffer_record.end_timestamp;
|
||||
extended_record.args = tracer_data.args;
|
||||
extended_record.retval = tracer_data.retval;
|
||||
|
||||
tracing::execute_buffer_record_emplace(extended_contexts,
|
||||
thr_id,
|
||||
internal_corr_id,
|
||||
external_corr_ids,
|
||||
ancestor_corr_id,
|
||||
info_type::buffered_ext_domain_idx,
|
||||
info_type::operation_idx,
|
||||
extended_record);
|
||||
}
|
||||
|
||||
// decrement the reference count after usage in the callback/buffers
|
||||
corr_id->sub_ref_count();
|
||||
|
||||
@@ -323,13 +367,13 @@ get_names(std::vector<const char*>& _name_list, std::index_sequence<OpIdx, OpIdx
|
||||
get_names<TableIdx>(_name_list, std::index_sequence<OpIdxTail...>{});
|
||||
}
|
||||
|
||||
template <size_t TableIdx, typename DataT, size_t OpIdx, size_t... OpIdxTail>
|
||||
template <size_t TableIdx, typename DataT, typename FuncT, size_t OpIdx, size_t... OpIdxTail>
|
||||
void
|
||||
iterate_args(const uint32_t id,
|
||||
const DataT& data,
|
||||
rocprofiler_callback_tracing_operation_args_cb_t func,
|
||||
int32_t max_deref,
|
||||
void* user_data,
|
||||
iterate_args(const uint32_t id,
|
||||
const DataT& data,
|
||||
FuncT func,
|
||||
int32_t max_deref,
|
||||
void* user_data,
|
||||
std::index_sequence<OpIdx, OpIdxTail...>)
|
||||
{
|
||||
if(OpIdx == id)
|
||||
@@ -339,16 +383,42 @@ iterate_args(const uint32_t id,
|
||||
auto&& arg_addr = info_type::as_arg_addr(data);
|
||||
for(size_t i = 0; i < std::min(arg_list.size(), arg_addr.size()); ++i)
|
||||
{
|
||||
auto ret = func(info_type::callback_domain_idx, // kind
|
||||
id, // operation
|
||||
i, // arg_number
|
||||
arg_addr.at(i), // arg_value_addr
|
||||
arg_list.at(i).indirection_level, // indirection
|
||||
arg_list.at(i).type, // arg_type
|
||||
arg_list.at(i).name, // arg_name
|
||||
arg_list.at(i).value.c_str(), // arg_value_str
|
||||
arg_list.at(i).dereference_count, // num deref in str
|
||||
user_data);
|
||||
using return_type = typename common::mpl::function_traits<FuncT>::result_type;
|
||||
|
||||
auto ret = return_type{};
|
||||
if constexpr(std::is_same<FuncT,
|
||||
rocprofiler_callback_tracing_operation_args_cb_t>::value)
|
||||
{
|
||||
ret = func(info_type::callback_domain_idx, // kind
|
||||
id, // operation
|
||||
i, // arg_number
|
||||
arg_addr.at(i), // arg_value_addr
|
||||
arg_list.at(i).indirection_level, // indirection
|
||||
arg_list.at(i).type, // arg_type
|
||||
arg_list.at(i).name, // arg_name
|
||||
arg_list.at(i).value.c_str(), // arg_value_str
|
||||
arg_list.at(i).dereference_count, // num deref in str
|
||||
user_data);
|
||||
}
|
||||
else if constexpr(std::is_same<FuncT,
|
||||
rocprofiler_buffer_tracing_operation_args_cb_t>::value)
|
||||
{
|
||||
ret = func(info_type::buffered_ext_domain_idx, // kind
|
||||
id, // operation
|
||||
i, // arg_number
|
||||
arg_addr.at(i), // arg_value_addr
|
||||
arg_list.at(i).indirection_level, // indirection
|
||||
arg_list.at(i).type, // arg_type
|
||||
arg_list.at(i).name, // arg_name
|
||||
arg_list.at(i).value.c_str(), // arg_value_str
|
||||
user_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
static_assert(common::mpl::assert_false<FuncT>::value,
|
||||
"Error! unsupported callback type");
|
||||
}
|
||||
|
||||
if(ret != 0) break;
|
||||
}
|
||||
return;
|
||||
@@ -361,6 +431,7 @@ iterate_args(const uint32_t id,
|
||||
bool
|
||||
should_wrap_functor(rocprofiler_callback_tracing_kind_t _callback_domain,
|
||||
rocprofiler_buffer_tracing_kind_t _buffered_domain,
|
||||
rocprofiler_buffer_tracing_kind_t _buffered_ext_domain,
|
||||
int _operation)
|
||||
{
|
||||
// we loop over all the *registered* contexts and see if any of them, at any point in time,
|
||||
@@ -378,6 +449,11 @@ should_wrap_functor(rocprofiler_callback_tracing_kind_t _callback_domain,
|
||||
if(itr->buffered_tracer && itr->buffered_tracer->domains(_buffered_domain) &&
|
||||
itr->buffered_tracer->domains(_buffered_domain, _operation))
|
||||
return true;
|
||||
|
||||
// if there is a buffered tracer enabled for the given domain and op, we need to wrap
|
||||
if(itr->buffered_tracer && itr->buffered_tracer->domains(_buffered_ext_domain) &&
|
||||
itr->buffered_tracer->domains(_buffered_ext_domain, _operation))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -436,8 +512,10 @@ update_table(Tp* _orig, std::integral_constant<size_t, OpIdx>)
|
||||
if(_info.offset() >= _orig->size) return;
|
||||
|
||||
// check to see if there are any contexts which enable this operation in the HIP API domain
|
||||
if(!should_wrap_functor(
|
||||
_info.callback_domain_idx, _info.buffered_domain_idx, _info.operation_idx))
|
||||
if(!should_wrap_functor(_info.callback_domain_idx,
|
||||
_info.buffered_domain_idx,
|
||||
_info.buffered_ext_domain_idx,
|
||||
_info.operation_idx))
|
||||
return;
|
||||
|
||||
ROCP_TRACE << "updating table entry for " << _info.name;
|
||||
@@ -511,11 +589,11 @@ get_names()
|
||||
|
||||
template <size_t TableIdx>
|
||||
void
|
||||
iterate_args(uint32_t id,
|
||||
const rocprofiler_callback_tracing_rocdecode_api_data_t& data,
|
||||
rocprofiler_callback_tracing_operation_args_cb_t callback,
|
||||
int32_t max_deref,
|
||||
void* user_data)
|
||||
iterate_args(uint32_t id,
|
||||
const rocprofiler_rocdecode_api_args_t& data,
|
||||
rocprofiler_callback_tracing_operation_args_cb_t callback,
|
||||
int32_t max_deref,
|
||||
void* user_data)
|
||||
{
|
||||
if(callback)
|
||||
iterate_args<TableIdx>(id,
|
||||
@@ -526,6 +604,22 @@ iterate_args(uint32_t id,
|
||||
std::make_index_sequence<rocdecode_domain_info<TableIdx>::last>{});
|
||||
}
|
||||
|
||||
template <size_t TableIdx>
|
||||
void
|
||||
iterate_args(uint32_t id,
|
||||
const rocprofiler_rocdecode_api_args_t& data,
|
||||
rocprofiler_buffer_tracing_operation_args_cb_t callback,
|
||||
void* user_data)
|
||||
{
|
||||
if(callback)
|
||||
iterate_args<TableIdx>(id,
|
||||
data,
|
||||
callback,
|
||||
0,
|
||||
user_data,
|
||||
std::make_index_sequence<rocdecode_domain_info<TableIdx>::last>{});
|
||||
}
|
||||
|
||||
template <typename TableT>
|
||||
void
|
||||
copy_table(TableT* _orig, uint64_t _tbl_instance)
|
||||
@@ -547,18 +641,21 @@ update_table(TableT* _orig)
|
||||
std::make_index_sequence<rocdecode_domain_info<TableIdx>::last>{});
|
||||
}
|
||||
|
||||
using rocdecode_api_data_t = rocprofiler_callback_tracing_rocdecode_api_data_t;
|
||||
using rocdecode_api_data_t = rocprofiler_rocdecode_api_args_t;
|
||||
using rocdecode_op_args_cb_t = rocprofiler_callback_tracing_operation_args_cb_t;
|
||||
using rocdecode_op_args_bf_t = rocprofiler_buffer_tracing_operation_args_cb_t;
|
||||
|
||||
#define INSTANTIATE_ROCDECODE_TABLE_FUNC(TABLE_TYPE, TABLE_IDX) \
|
||||
template void copy_table<TABLE_TYPE>(TABLE_TYPE * _tbl, uint64_t _instv); \
|
||||
template void update_table<TABLE_TYPE>(TABLE_TYPE * _tbl); \
|
||||
template const char* name_by_id<TABLE_IDX>(uint32_t); \
|
||||
template uint32_t id_by_name<TABLE_IDX>(const char*); \
|
||||
template std::vector<uint32_t> get_ids<TABLE_IDX>(); \
|
||||
template std::vector<const char*> get_names<TABLE_IDX>(); \
|
||||
template void iterate_args<TABLE_IDX>( \
|
||||
uint32_t, const rocdecode_api_data_t&, rocdecode_op_args_cb_t, int32_t, void*);
|
||||
#define INSTANTIATE_ROCDECODE_TABLE_FUNC(TABLE_TYPE, TABLE_IDX) \
|
||||
template void copy_table<TABLE_TYPE>(TABLE_TYPE * _tbl, uint64_t _instv); \
|
||||
template void update_table<TABLE_TYPE>(TABLE_TYPE * _tbl); \
|
||||
template const char* name_by_id<TABLE_IDX>(uint32_t); \
|
||||
template uint32_t id_by_name<TABLE_IDX>(const char*); \
|
||||
template std::vector<uint32_t> get_ids<TABLE_IDX>(); \
|
||||
template std::vector<const char*> get_names<TABLE_IDX>(); \
|
||||
template void iterate_args<TABLE_IDX>( \
|
||||
uint32_t, const rocdecode_api_data_t&, rocdecode_op_args_cb_t, int32_t, void*); \
|
||||
template void iterate_args<TABLE_IDX>( \
|
||||
uint32_t, const rocdecode_api_data_t&, rocdecode_op_args_bf_t, void*);
|
||||
|
||||
INSTANTIATE_ROCDECODE_TABLE_FUNC(rocdecode_api_func_table_t, ROCPROFILER_ROCDECODE_TABLE_ID_CORE)
|
||||
} // namespace rocdecode
|
||||
|
||||
@@ -36,21 +36,23 @@ namespace rocdecode
|
||||
template <>
|
||||
struct rocdecode_domain_info<ROCPROFILER_ROCDECODE_TABLE_ID_LAST>
|
||||
{
|
||||
using args_type = rocprofiler_rocdecode_api_args_t;
|
||||
using retval_type = rocprofiler_rocdecode_api_retval_t;
|
||||
using callback_data_type = rocprofiler_callback_tracing_rocdecode_api_data_t;
|
||||
using buffer_data_type = rocprofiler_buffer_tracing_rocdecode_api_record_t;
|
||||
using args_type = rocprofiler_rocdecode_api_args_t;
|
||||
using retval_type = rocprofiler_rocdecode_api_retval_t;
|
||||
using callback_data_type = rocprofiler_callback_tracing_rocdecode_api_data_t;
|
||||
using buffer_data_type = rocprofiler_buffer_tracing_rocdecode_api_record_t;
|
||||
using buffered_ext_data_type = rocprofiler_buffer_tracing_rocdecode_api_ext_record_t;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct rocdecode_domain_info<ROCPROFILER_ROCDECODE_TABLE_ID_CORE>
|
||||
: rocdecode_domain_info<ROCPROFILER_ROCDECODE_TABLE_ID_LAST>
|
||||
{
|
||||
using enum_type = rocprofiler_marker_core_api_id_t;
|
||||
static constexpr auto callback_domain_idx = ROCPROFILER_CALLBACK_TRACING_ROCDECODE_API;
|
||||
static constexpr auto buffered_domain_idx = ROCPROFILER_BUFFER_TRACING_ROCDECODE_API;
|
||||
static constexpr auto none = ROCPROFILER_ROCDECODE_API_ID_NONE;
|
||||
static constexpr auto last = ROCPROFILER_ROCDECODE_API_ID_LAST;
|
||||
using enum_type = rocprofiler_marker_core_api_id_t;
|
||||
static constexpr auto callback_domain_idx = ROCPROFILER_CALLBACK_TRACING_ROCDECODE_API;
|
||||
static constexpr auto buffered_domain_idx = ROCPROFILER_BUFFER_TRACING_ROCDECODE_API;
|
||||
static constexpr auto buffered_ext_domain_idx = ROCPROFILER_BUFFER_TRACING_ROCDECODE_API_EXT;
|
||||
static constexpr auto none = ROCPROFILER_ROCDECODE_API_ID_NONE;
|
||||
static constexpr auto last = ROCPROFILER_ROCDECODE_API_ID_LAST;
|
||||
static constexpr auto external_correlation_id_domain_idx =
|
||||
ROCPROFILER_EXTERNAL_CORRELATION_REQUEST_ROCDECODE_API;
|
||||
};
|
||||
|
||||
@@ -98,11 +98,18 @@ get_ids();
|
||||
|
||||
template <size_t TableIdx>
|
||||
void
|
||||
iterate_args(uint32_t id,
|
||||
const rocprofiler_callback_tracing_rocdecode_api_data_t& data,
|
||||
rocprofiler_callback_tracing_operation_args_cb_t callback,
|
||||
int32_t max_deref,
|
||||
void* user_data);
|
||||
iterate_args(uint32_t id,
|
||||
const rocprofiler_rocdecode_api_args_t& data,
|
||||
rocprofiler_callback_tracing_operation_args_cb_t callback,
|
||||
int32_t max_deref,
|
||||
void* user_data);
|
||||
|
||||
template <size_t TableIdx>
|
||||
void
|
||||
iterate_args(uint32_t id,
|
||||
const rocprofiler_rocdecode_api_args_t& data,
|
||||
rocprofiler_buffer_tracing_operation_args_cb_t callback,
|
||||
void* user_data);
|
||||
|
||||
template <typename TableT>
|
||||
void
|
||||
|
||||
@@ -32,12 +32,11 @@ def test_data_structure(input_data):
|
||||
node_exists("buffer_records", sdk_data)
|
||||
|
||||
node_exists("names", sdk_data["callback_records"])
|
||||
# Uncomment when rocprofiler register mainline supports rocdecode
|
||||
# node_exists("rocdecode_api_traces", sdk_data["callback_records"])
|
||||
node_exists("rocdecode_api_traces", sdk_data["callback_records"])
|
||||
|
||||
node_exists("names", sdk_data["buffer_records"])
|
||||
# Uncomment when rocprofiler register mainline supports rocdecode
|
||||
# node_exists("rocdecode_api_traces", sdk_data["buffer_records"])
|
||||
node_exists("rocdecode_api_traces", sdk_data["buffer_records"])
|
||||
node_exists("rocdecode_api_ext_traces", sdk_data["buffer_records"])
|
||||
|
||||
|
||||
def test_size_entries(input_data):
|
||||
@@ -88,6 +87,11 @@ def test_timestamps(input_data):
|
||||
for itr in sdk_data["buffer_records"][titr]:
|
||||
assert itr["start_timestamp"] <= itr["end_timestamp"]
|
||||
|
||||
for itr in sdk_data["buffer_records"]["rocdecode_api_ext_traces"]:
|
||||
assert itr["start_timestamp"] < itr["end_timestamp"]
|
||||
assert itr["start_timestamp"] > 0
|
||||
assert itr["end_timestamp"] > 0
|
||||
|
||||
|
||||
def test_internal_correlation_ids(input_data):
|
||||
"""Assure correlation ids are unique"""
|
||||
@@ -135,12 +139,11 @@ def test_rocdecode_traces(input_data):
|
||||
rocdecode_bf_traces = sdk_data["buffer_records"]["rocdecode_api_traces"]
|
||||
rocdecode_api_bf_ops = get_operation(buffer_records, "ROCDECODE_API")
|
||||
assert len(rocdecode_api_bf_ops[1]) == 16
|
||||
assert len(rocdecode_bf_traces) > 0
|
||||
|
||||
rocdecode_cb_traces = sdk_data["callback_records"]["rocdecode_api_traces"]
|
||||
rocdecode_api_cb_ops = get_operation(callback_records, "ROCDECODE_API")
|
||||
# If rocDecode tracing is not supported, end early
|
||||
if len(rocdecode_bf_traces) == 0:
|
||||
return pytest.skip("rocdecode tracing unavailable")
|
||||
|
||||
assert (
|
||||
rocdecode_api_bf_ops[1] == rocdecode_api_cb_ops[1]
|
||||
and len(rocdecode_api_cb_ops[1]) == 16
|
||||
@@ -177,6 +180,19 @@ def test_rocdecode_traces(input_data):
|
||||
]:
|
||||
assert call in api_calls
|
||||
|
||||
rocdecode_ext_bf_traces = sdk_data["buffer_records"]["rocdecode_api_ext_traces"]
|
||||
assert len(rocdecode_ext_bf_traces) > 0
|
||||
# Ensure that the input file path has the correct string saved
|
||||
assert len(rocdecode_ext_bf_traces[0].args) > 1
|
||||
assert rocdecode_ext_bf_traces[0].args[1].name == "input_file_path"
|
||||
assert (
|
||||
rocdecode_ext_bf_traces[0].args[1].value.split("/")[-1]
|
||||
== "AMD_driving_virtual_20-H265.265"
|
||||
)
|
||||
for api_call in rocdecode_ext_bf_traces:
|
||||
assert len(api_call["args"]) > 0
|
||||
assert (api_call.retval.uint64_t_retval in [0, 1], "Unexpected return values")
|
||||
|
||||
|
||||
def test_retired_correlation_ids(input_data):
|
||||
data = input_data
|
||||
|
||||
@@ -30,8 +30,8 @@ add_test(
|
||||
NAME rocprofv3-test-rocdecode-tracing-execute
|
||||
COMMAND
|
||||
$<TARGET_FILE:rocprofiler-sdk::rocprofv3> --rocdecode-trace -d
|
||||
${CMAKE_CURRENT_BINARY_DIR}/%tag%-trace -o out --output-format json csv
|
||||
--log-level env --
|
||||
${CMAKE_CURRENT_BINARY_DIR}/%tag%-trace -o out --output-format json csv pftrace
|
||||
otf2 --log-level env --
|
||||
$<IF:$<TARGET_EXISTS:rocdecode-demo>,$<$<TARGET_EXISTS:rocdecode-demo>:$<TARGET_FILE:rocdecode-demo>>,rocdecode-demo>
|
||||
-i ${ROCDECODE_VIDEO_FILE})
|
||||
|
||||
@@ -52,10 +52,10 @@ add_test(
|
||||
NAME rocprofv3-test-rocdecode-tracing-validate
|
||||
COMMAND
|
||||
${Python3_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/validate.py --json-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/rocdecode-trace/out_results.json --otf2-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/rocdecode-trace/out_results.otf2 --pftrace-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/rocdecode-trace/out_results.pftrace --csv-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/rocdecode-trace/out_rocdecode_api_trace.csv)
|
||||
${CMAKE_CURRENT_BINARY_DIR}/rocdecode-demo-trace/out_results.json --otf2-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/rocdecode-demo-trace/out_results.otf2 --pftrace-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/rocdecode-demo-trace/out_results.pftrace --csv-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/rocdecode-demo-trace/out_rocdecode_api_trace.csv)
|
||||
|
||||
set_tests_properties(
|
||||
rocprofv3-test-rocdecode-tracing-validate
|
||||
|
||||
@@ -15,25 +15,25 @@ def pytest_addoption(parser):
|
||||
parser.addoption(
|
||||
"--json-input",
|
||||
action="store",
|
||||
default="rocdecode-tracing/out_results.json",
|
||||
default="rocdecode-trace/rocdecode-demo-trace/out_results.json",
|
||||
help="Input JSON",
|
||||
)
|
||||
parser.addoption(
|
||||
"--otf2-input",
|
||||
action="store",
|
||||
default="rocdecode-tracing/out_results.otf2",
|
||||
default="rocdecode-trace/rocdecode-demo-trace/out_results.otf2",
|
||||
help="Input OTF2",
|
||||
)
|
||||
parser.addoption(
|
||||
"--pftrace-input",
|
||||
action="store",
|
||||
default="rocdecode-tracing/out_results.pftrace",
|
||||
default="rocdecode-trace/rocdecode-demo-trace/out_results.pftrace",
|
||||
help="Input pftrace file",
|
||||
)
|
||||
parser.addoption(
|
||||
"--csv-input",
|
||||
action="store",
|
||||
default="rocdecode-tracing/out_rocdecode_api_trace.csv",
|
||||
default="rocdecode-trace/rocdecode-demo-trace/out_rocdecode_api_trace.csv",
|
||||
help="Input CSV",
|
||||
)
|
||||
|
||||
|
||||
@@ -32,9 +32,14 @@ def test_rocdeocde(json_data):
|
||||
buffer_records = data["buffer_records"]
|
||||
|
||||
rocdecode_data = buffer_records["rocdecode_api"]
|
||||
# If rocDecode tracing is not supported, end early
|
||||
if len(rocdecode_data) == 0:
|
||||
return pytest.skip("rocdecode tracing unavailable")
|
||||
assert len(rocdecode_data) > 0
|
||||
# Ensure that the input file path has the correct string saved
|
||||
assert len(rocdecode_data[0].args) > 1
|
||||
assert rocdecode_data[0].args[1].name == "input_file_path"
|
||||
assert (
|
||||
rocdecode_data[0].args[1].value.split("/")[-1]
|
||||
== "AMD_driving_virtual_20-H265.265"
|
||||
)
|
||||
|
||||
_, bf_op_names = get_operation(data, "ROCDECODE_API")
|
||||
|
||||
@@ -50,14 +55,21 @@ def test_rocdeocde(json_data):
|
||||
assert "end_timestamp" in node
|
||||
assert "start_timestamp" in node
|
||||
assert "thread_id" in node
|
||||
assert "args" in node
|
||||
assert "retval" in node
|
||||
|
||||
assert node.size > 0
|
||||
assert node.thread_id > 0
|
||||
assert node.start_timestamp > 0
|
||||
assert node.end_timestamp > 0
|
||||
assert node.start_timestamp < node.end_timestamp
|
||||
assert len(node.args) > 0
|
||||
assert node.retval.uint64_t_retval in [0, 1], "Unexpected return values"
|
||||
|
||||
assert data.strings.buffer_records[node.kind].kind == "ROCDECODE_API"
|
||||
assert (
|
||||
data.strings.buffer_records[node.kind].kind == "ROCDECODE_API"
|
||||
or data.strings.buffer_records[node.kind].kind == "ROCDECODE_API_EXT"
|
||||
)
|
||||
assert (
|
||||
data.strings.buffer_records[node.kind].operations[node.operation]
|
||||
in bf_op_names
|
||||
@@ -65,9 +77,6 @@ def test_rocdeocde(json_data):
|
||||
|
||||
|
||||
def test_csv_data(csv_data):
|
||||
# If rocDecode tracing is not supported, end early
|
||||
if len(csv_data) == 0:
|
||||
return pytest.skip("rocdecode tracing unavailable")
|
||||
assert len(csv_data) > 0, "Expected non-empty csv data"
|
||||
|
||||
api_calls = []
|
||||
@@ -95,7 +104,7 @@ def test_csv_data(csv_data):
|
||||
|
||||
api_calls.append(row["Function"])
|
||||
|
||||
assert row["Domain"] == "ROCDECODE_API"
|
||||
assert row["Domain"] in ("ROCDECODE_API", "ROCDECODE_API_EXT")
|
||||
assert int(row["Process_Id"]) > 0
|
||||
assert int(row["Thread_Id"]) > 0
|
||||
assert int(row["Start_Timestamp"]) > 0
|
||||
@@ -122,13 +131,6 @@ def test_csv_data(csv_data):
|
||||
def test_perfetto_data(pftrace_data, json_data):
|
||||
import rocprofiler_sdk.tests.rocprofv3 as rocprofv3
|
||||
|
||||
# If rocDecode tracing is not supported, end early
|
||||
if (
|
||||
pftrace_data == None
|
||||
or len(json_data["rocprofiler-sdk-tool"]["buffer_records"]["rocdecode_api"]) == 0
|
||||
):
|
||||
return pytest.skip("rocdecode tracing unavailable")
|
||||
|
||||
rocprofv3.test_perfetto_data(
|
||||
pftrace_data,
|
||||
json_data,
|
||||
@@ -139,13 +141,6 @@ def test_perfetto_data(pftrace_data, json_data):
|
||||
def test_otf2_data(otf2_data, json_data):
|
||||
import rocprofiler_sdk.tests.rocprofv3 as rocprofv3
|
||||
|
||||
# If rocDecode tracing is not supported, end early
|
||||
if (
|
||||
otf2_data == None
|
||||
or len(json_data["rocprofiler-sdk-tool"]["buffer_records"]["rocdecode_api"]) == 0
|
||||
):
|
||||
return pytest.skip("rocdecode tracing unavailable")
|
||||
|
||||
rocprofv3.test_otf2_data(
|
||||
otf2_data,
|
||||
json_data,
|
||||
|
||||
@@ -908,8 +908,10 @@ auto corr_id_retire_records =
|
||||
std::deque<rocprofiler_buffer_tracing_correlation_id_retirement_record_t>{};
|
||||
auto rccl_api_bf_records = std::deque<rocprofiler_buffer_tracing_rccl_api_record_t>{};
|
||||
auto rocdecode_api_bf_records = std::deque<rocprofiler_buffer_tracing_rocdecode_api_record_t>{};
|
||||
auto rocjpeg_api_bf_records = std::deque<rocprofiler_buffer_tracing_rocjpeg_api_record_t>{};
|
||||
auto ompt_bf_records = std::deque<rocprofiler_buffer_tracing_ompt_record_t>{};
|
||||
auto rocdecode_api_ext_bf_records =
|
||||
std::deque<rocprofiler_buffer_tracing_rocdecode_api_ext_record_t>{};
|
||||
auto rocjpeg_api_bf_records = std::deque<rocprofiler_buffer_tracing_rocjpeg_api_record_t>{};
|
||||
auto ompt_bf_records = std::deque<rocprofiler_buffer_tracing_ompt_record_t>{};
|
||||
|
||||
void
|
||||
tool_tracing_buffered(rocprofiler_context_id_t /*context*/,
|
||||
@@ -1043,6 +1045,13 @@ tool_tracing_buffered(rocprofiler_context_id_t /*context*/,
|
||||
|
||||
rocdecode_api_bf_records.emplace_back(*record);
|
||||
}
|
||||
else if(header->kind == ROCPROFILER_BUFFER_TRACING_ROCDECODE_API_EXT)
|
||||
{
|
||||
auto* record = static_cast<rocprofiler_buffer_tracing_rocdecode_api_ext_record_t*>(
|
||||
header->payload);
|
||||
|
||||
rocdecode_api_ext_bf_records.emplace_back(*record);
|
||||
}
|
||||
else if(header->kind == ROCPROFILER_BUFFER_TRACING_ROCJPEG_API)
|
||||
{
|
||||
auto* record =
|
||||
@@ -1150,6 +1159,7 @@ rocprofiler_context_id_t runtime_init_callback_ctx = {};
|
||||
rocprofiler_context_id_t runtime_init_buffered_ctx = {};
|
||||
rocprofiler_context_id_t rocdecode_api_callback_ctx = {0};
|
||||
rocprofiler_context_id_t rocdecode_api_buffered_ctx = {0};
|
||||
rocprofiler_context_id_t rocdecode_api_ext_buffered_ctx = {0};
|
||||
rocprofiler_context_id_t rocjpeg_api_callback_ctx = {0};
|
||||
rocprofiler_context_id_t rocjpeg_api_buffered_ctx = {0};
|
||||
|
||||
@@ -1167,6 +1177,7 @@ rocprofiler_buffer_id_t scratch_memory_buffer = {};
|
||||
rocprofiler_buffer_id_t corr_id_retire_buffer = {};
|
||||
rocprofiler_buffer_id_t rccl_api_buffered_buffer = {};
|
||||
rocprofiler_buffer_id_t rocdecode_api_buffer = {};
|
||||
rocprofiler_buffer_id_t rocdecode_api_ext_buffer = {};
|
||||
rocprofiler_buffer_id_t rocjpeg_api_buffer = {};
|
||||
rocprofiler_buffer_id_t ompt_buffered_buffer = {};
|
||||
|
||||
@@ -1195,12 +1206,13 @@ auto contexts = std::unordered_map<std::string_view, rocprofiler_context_id_t*>{
|
||||
{"RCCL_API_BUFFERED", &rccl_api_buffered_ctx},
|
||||
{"ROCDECODE_API_CALLBACK", &rocdecode_api_callback_ctx},
|
||||
{"ROCDECODE_API_BUFFERED", &rocdecode_api_buffered_ctx},
|
||||
{"ROCDECODE_API_EXT_BUFFERED", &rocdecode_api_ext_buffered_ctx},
|
||||
{"ROCJPEG_API_CALLBACK", &rocjpeg_api_callback_ctx},
|
||||
{"ROCJPEG_API_BUFFERED", &rocjpeg_api_buffered_ctx},
|
||||
{"OMPT_BUFFERED", &ompt_buffered_ctx},
|
||||
};
|
||||
|
||||
auto buffers = std::array<rocprofiler_buffer_id_t*, 15>{&runtime_init_buffered_buffer,
|
||||
auto buffers = std::array<rocprofiler_buffer_id_t*, 16>{&runtime_init_buffered_buffer,
|
||||
&hsa_api_buffered_buffer,
|
||||
&hip_api_buffered_buffer,
|
||||
&marker_api_buffered_buffer,
|
||||
@@ -1214,6 +1226,7 @@ auto buffers = std::array<rocprofiler_buffer_id_t*, 15>{&runtime_init_buffered_b
|
||||
&rccl_api_buffered_buffer,
|
||||
&ompt_buffered_buffer,
|
||||
&rocdecode_api_buffer,
|
||||
&rocdecode_api_ext_buffer,
|
||||
&rocjpeg_api_buffer};
|
||||
|
||||
auto agents = std::vector<rocprofiler_agent_t>{};
|
||||
@@ -1526,6 +1539,14 @@ tool_init(rocprofiler_client_finalize_t fini_func, void* tool_data)
|
||||
tool_data,
|
||||
&rocdecode_api_buffer),
|
||||
"buffer creation");
|
||||
ROCPROFILER_CALL(rocprofiler_create_buffer(rocdecode_api_ext_buffered_ctx,
|
||||
buffer_size,
|
||||
watermark,
|
||||
ROCPROFILER_BUFFER_POLICY_LOSSLESS,
|
||||
tool_tracing_buffered,
|
||||
tool_data,
|
||||
&rocdecode_api_ext_buffer),
|
||||
"buffer creation");
|
||||
|
||||
ROCPROFILER_CALL(rocprofiler_create_buffer(rocjpeg_api_buffered_ctx,
|
||||
buffer_size,
|
||||
@@ -1668,6 +1689,14 @@ tool_init(rocprofiler_client_finalize_t fini_func, void* tool_data)
|
||||
rocdecode_api_buffer),
|
||||
"buffer tracing service for rocdecode api configure");
|
||||
|
||||
ROCPROFILER_CALL(
|
||||
rocprofiler_configure_buffer_tracing_service(rocdecode_api_ext_buffered_ctx,
|
||||
ROCPROFILER_BUFFER_TRACING_ROCDECODE_API_EXT,
|
||||
nullptr,
|
||||
0,
|
||||
rocdecode_api_ext_buffer),
|
||||
"buffer tracing service for rocdecode ext api configure");
|
||||
|
||||
ROCPROFILER_CALL(
|
||||
rocprofiler_configure_buffer_tracing_service(rocjpeg_api_buffered_ctx,
|
||||
ROCPROFILER_BUFFER_TRACING_ROCJPEG_API,
|
||||
@@ -1847,6 +1876,7 @@ tool_fini(void* tool_data)
|
||||
<< ", counter_collection_value_records=" << counter_collection_bf_records.size()
|
||||
<< ", rocdecode_api_callback_records=" << rocdecode_api_cb_records.size()
|
||||
<< ", rocdecode_api_bf_records=" << rocdecode_api_bf_records.size()
|
||||
<< ", rocdecode_api_ext_bf_records=" << rocdecode_api_ext_bf_records.size()
|
||||
<< ", rocjpeg_api_callback_records=" << rocjpeg_api_cb_records.size()
|
||||
<< ", rocjpeg_api_bf_records=" << rocjpeg_api_bf_records.size() << "...\n"
|
||||
<< std::flush;
|
||||
@@ -1973,6 +2003,7 @@ write_json(call_stack_t* _call_stack)
|
||||
json_ar(cereal::make_nvp("retired_correlation_ids", corr_id_retire_records));
|
||||
json_ar(cereal::make_nvp("counter_collection", counter_collection_bf_records));
|
||||
json_ar(cereal::make_nvp("rocdecode_api_traces", rocdecode_api_bf_records));
|
||||
json_ar(cereal::make_nvp("rocdecode_api_ext_traces", rocdecode_api_ext_bf_records));
|
||||
json_ar(cereal::make_nvp("rocjpeg_api_traces", rocjpeg_api_bf_records));
|
||||
} catch(std::exception& e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user