PC Sampling - blit kernels handling (#878)

* correlation id 0 for blit kernels' samples

* rocprofiler_pc_sampling_snapshot_v1_t docs update (for future use)

* ROCPROFILER_CORRELATION_ID_VALUE_NONE introduced

* Simplifying ROCPROFILER_CORRELATION_ID_VALUE_NONE

* Apply suggestions from code review

Co-authored-by: Vladimir Indic <139573562+vlaindic@users.noreply.github.com>

---------

Co-authored-by: Jonathan R. Madsen <jrmadsen@users.noreply.github.com>
This commit is contained in:
Vladimir Indic
2024-05-29 12:55:47 +02:00
کامیت شده توسط GitHub
والد dc054eea76
کامیت c45bf712d1
4فایلهای تغییر یافته به همراه19 افزوده شده و 9 حذف شده
@@ -519,6 +519,11 @@ typedef struct
rocprofiler_user_data_t external;
} rocprofiler_correlation_id_t;
/**
* @brief The NULL correlation ID value.
*/
#define ROCPROFILER_CORRELATION_ID_VALUE_NONE 0ULL
/**
* @struct rocprofiler_buffer_id_t
* @brief Buffer ID.
@@ -197,7 +197,7 @@ rocprofiler_query_pc_sampling_agent_configurations(
*/
typedef struct
{
uint8_t valid : 1; /// sample is valid
uint8_t valid : 1; /// ::rocprofiler_pc_sampling_snapshot_v1_t field is valid
uint8_t type : 4;
uint8_t has_stall_reason : 1;
uint8_t has_wave_cnt : 1;
@@ -219,7 +219,12 @@ typedef struct
} rocprofiler_pc_sampling_header_v1_t;
/**
* @brief TODO: provide the description
* @brief For future use.
*
* @todo: Provide the description
* @todo: Should we use bitfields because of C ABI portability?
* @todo: Should we abstract this to be architecture agnostic?
* @todo: Consider having a query to determine organization of this information.
*/
typedef struct
{
@@ -176,8 +176,7 @@ data_ready_callback(void* client_callback_data,
if(pcs_parser_status != PCSAMPLE_STATUS_SUCCESS)
{
// TODO: should we end program here or somehow report an error to the user and continue?
throw std::runtime_error("Error while parsing PC samples");
ROCP_INFO << "PCS Parser encountered samples from a blit kernel.\n";
}
});
}
@@ -140,9 +140,9 @@ public:
if(dev.handle == cache_dev_id && correlation_in == cache_correlation_id_in)
return cache_correlation_id_out;
#endif
cache_correlation_id_out = dispatch_to_correlation.at({correlation_in, dev});
cache_dev_id = dev.handle;
cache_correlation_id_in = correlation_in;
cache_correlation_id_out = dispatch_to_correlation.at({correlation_in, dev});
return cache_correlation_id_out;
}
@@ -191,16 +191,17 @@ add_upcoming_samples(const device_handle device,
{
const auto* snap = reinterpret_cast<const perf_sample_snapshot_v1*>(buffer + p);
samples[p] = copySample<bHostTrap, GFXIP>((const void*) (buffer + p));
samples[p].size = 0; // pc sampling record with size 0 will indicate invalid sample
samples[p].size = sizeof(rocprofiler_pc_sampling_record_t);
try
{
Parser::trap_correlation_id_t trap{.raw = snap->correlation_id};
samples[p].correlation_id = corr_map->get(device, trap);
samples[p].size = sizeof(rocprofiler_pc_sampling_record_t);
// set size after corr_map->get which may throw
} catch(std::exception& e)
{
status = PCSAMPLE_STATUS_PARSER_ERROR;
samples[p].correlation_id = {.internal = ROCPROFILER_CORRELATION_ID_VALUE_NONE,
.external = rocprofiler_user_data_t{
.value = ROCPROFILER_CORRELATION_ID_VALUE_NONE}};
status = PCSAMPLE_STATUS_PARSER_ERROR;
}
}
return status;