ac/spm: introduce ac_spm_trace and ac_spm_get_trace()
For more code isolation. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22707>
This commit is contained in:
committed by
Marge Bot
parent
44a2e5ba38
commit
0d4fa8e5c6
@@ -892,7 +892,7 @@ struct sqtt_file_chunk_spm_db {
|
||||
static_assert(sizeof(struct sqtt_file_chunk_spm_db) == 32,
|
||||
"sqtt_file_chunk_spm_db doesn't match RGP spec");
|
||||
|
||||
static void ac_sqtt_fill_spm_db(const struct ac_spm_trace_data *spm_trace,
|
||||
static void ac_sqtt_fill_spm_db(const struct ac_spm_trace *spm_trace,
|
||||
struct sqtt_file_chunk_spm_db *chunk,
|
||||
uint32_t num_samples,
|
||||
uint32_t chunk_size)
|
||||
@@ -909,12 +909,12 @@ static void ac_sqtt_fill_spm_db(const struct ac_spm_trace_data *spm_trace,
|
||||
chunk->sample_interval = spm_trace->sample_interval;
|
||||
}
|
||||
|
||||
static void ac_sqtt_dump_spm(const struct ac_spm_trace_data *spm_trace,
|
||||
static void ac_sqtt_dump_spm(const struct ac_spm_trace *spm_trace,
|
||||
size_t file_offset,
|
||||
FILE *output)
|
||||
{
|
||||
uint32_t sample_size_in_bytes = ac_spm_get_sample_size(spm_trace);
|
||||
uint32_t num_samples = ac_spm_get_num_samples(spm_trace);
|
||||
uint32_t sample_size_in_bytes = spm_trace->sample_size_in_bytes;
|
||||
uint32_t num_samples = spm_trace->num_samples;
|
||||
uint8_t *spm_data_ptr = (uint8_t *)spm_trace->ptr;
|
||||
struct sqtt_file_chunk_spm_db spm_db;
|
||||
size_t file_spm_db_offset = file_offset;
|
||||
@@ -983,7 +983,7 @@ static void ac_sqtt_dump_spm(const struct ac_spm_trace_data *spm_trace,
|
||||
#if defined(USE_LIBELF)
|
||||
static void ac_sqtt_dump_data(struct radeon_info *rad_info,
|
||||
struct ac_thread_trace *thread_trace,
|
||||
const struct ac_spm_trace_data *spm_trace,
|
||||
const struct ac_spm_trace *spm_trace,
|
||||
FILE *output)
|
||||
{
|
||||
struct ac_thread_trace_data *thread_trace_data = thread_trace->data;
|
||||
@@ -1171,7 +1171,7 @@ static void ac_sqtt_dump_data(struct radeon_info *rad_info,
|
||||
|
||||
int ac_dump_rgp_capture(struct radeon_info *info,
|
||||
struct ac_thread_trace *thread_trace,
|
||||
const struct ac_spm_trace_data *spm_trace)
|
||||
const struct ac_spm_trace *spm_trace)
|
||||
{
|
||||
#if !defined(USE_LIBELF)
|
||||
return -1;
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
struct radeon_info;
|
||||
struct ac_thread_trace;
|
||||
struct ac_thread_trace_data;
|
||||
struct ac_spm_trace_data;
|
||||
struct ac_spm_trace;
|
||||
|
||||
enum rgp_hardware_stages {
|
||||
RGP_HW_STAGE_VS = 0,
|
||||
@@ -191,7 +191,7 @@ struct rgp_clock_calibration {
|
||||
int
|
||||
ac_dump_rgp_capture(struct radeon_info *info,
|
||||
struct ac_thread_trace *thread_trace,
|
||||
const struct ac_spm_trace_data *spm_trace);
|
||||
const struct ac_spm_trace *spm_trace);
|
||||
|
||||
void
|
||||
ac_rgp_file_write_elf_object(FILE *output, size_t file_elf_start,
|
||||
|
||||
+15
-2
@@ -342,7 +342,7 @@ void ac_destroy_spm(struct ac_spm_trace_data *spm_trace)
|
||||
FREE(spm_trace->counters);
|
||||
}
|
||||
|
||||
uint32_t ac_spm_get_sample_size(const struct ac_spm_trace_data *spm_trace)
|
||||
static uint32_t ac_spm_get_sample_size(const struct ac_spm_trace_data *spm_trace)
|
||||
{
|
||||
uint32_t sample_size = 0; /* in bytes */
|
||||
|
||||
@@ -353,7 +353,7 @@ uint32_t ac_spm_get_sample_size(const struct ac_spm_trace_data *spm_trace)
|
||||
return sample_size;
|
||||
}
|
||||
|
||||
uint32_t ac_spm_get_num_samples(const struct ac_spm_trace_data *spm_trace)
|
||||
static uint32_t ac_spm_get_num_samples(const struct ac_spm_trace_data *spm_trace)
|
||||
{
|
||||
uint32_t sample_size = ac_spm_get_sample_size(spm_trace);
|
||||
uint32_t *ptr = (uint32_t *)spm_trace->ptr;
|
||||
@@ -375,3 +375,16 @@ uint32_t ac_spm_get_num_samples(const struct ac_spm_trace_data *spm_trace)
|
||||
|
||||
return num_samples;
|
||||
}
|
||||
|
||||
void ac_spm_get_trace(const struct ac_spm_trace_data *spm,
|
||||
struct ac_spm_trace *trace)
|
||||
{
|
||||
memset(trace, 0, sizeof(*trace));
|
||||
|
||||
trace->ptr = spm->ptr;
|
||||
trace->sample_interval = spm->sample_interval;
|
||||
trace->num_counters = spm->num_counters;
|
||||
trace->counters = spm->counters;
|
||||
trace->sample_size_in_bytes = ac_spm_get_sample_size(spm);
|
||||
trace->num_samples = ac_spm_get_num_samples(spm);
|
||||
}
|
||||
|
||||
+11
-2
@@ -112,6 +112,15 @@ struct ac_spm_trace_data {
|
||||
struct ac_spm_muxsel_line *muxsel_lines[AC_SPM_SEGMENT_TYPE_COUNT];
|
||||
};
|
||||
|
||||
struct ac_spm_trace {
|
||||
void *ptr;
|
||||
uint16_t sample_interval;
|
||||
unsigned num_counters;
|
||||
struct ac_spm_counter_info *counters;
|
||||
uint32_t sample_size_in_bytes;
|
||||
uint32_t num_samples;
|
||||
};
|
||||
|
||||
bool ac_init_spm(const struct radeon_info *info,
|
||||
const struct ac_perfcounters *pc,
|
||||
unsigned num_counters,
|
||||
@@ -119,7 +128,7 @@ bool ac_init_spm(const struct radeon_info *info,
|
||||
struct ac_spm_trace_data *spm_trace);
|
||||
void ac_destroy_spm(struct ac_spm_trace_data *spm_trace);
|
||||
|
||||
uint32_t ac_spm_get_sample_size(const struct ac_spm_trace_data *spm_trace);
|
||||
uint32_t ac_spm_get_num_samples(const struct ac_spm_trace_data *spm_trace);
|
||||
void ac_spm_get_trace(const struct ac_spm_trace_data *spm,
|
||||
struct ac_spm_trace *trace);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -541,12 +541,13 @@ radv_handle_thread_trace(VkQueue _queue)
|
||||
queue->device->vk.dispatch_table.QueueWaitIdle(_queue);
|
||||
|
||||
if (radv_get_thread_trace(queue, &thread_trace)) {
|
||||
struct ac_spm_trace_data *spm_trace = NULL;
|
||||
struct ac_spm_trace spm_trace;
|
||||
|
||||
if (queue->device->spm_trace.bo)
|
||||
spm_trace = &queue->device->spm_trace;
|
||||
ac_spm_get_trace(&queue->device->spm_trace, &spm_trace);
|
||||
|
||||
ac_dump_rgp_capture(&queue->device->physical_device->rad_info, &thread_trace, spm_trace);
|
||||
ac_dump_rgp_capture(&queue->device->physical_device->rad_info, &thread_trace,
|
||||
queue->device->spm_trace.bo ? &spm_trace : NULL);
|
||||
} else {
|
||||
/* Trigger a new capture if the driver failed to get
|
||||
* the trace because the buffer was too small.
|
||||
|
||||
@@ -849,12 +849,16 @@ si_handle_thread_trace(struct si_context *sctx, struct radeon_cmdbuf *rcs)
|
||||
/* Wait for SQTT to finish and read back the bo */
|
||||
if (sctx->ws->fence_wait(sctx->ws, sctx->last_sqtt_fence, PIPE_TIMEOUT_INFINITE) &&
|
||||
si_get_thread_trace(sctx, &thread_trace)) {
|
||||
struct ac_spm_trace spm_trace;
|
||||
|
||||
/* Map the SPM counter buffer */
|
||||
if (sctx->spm_trace.bo)
|
||||
if (sctx->spm_trace.bo) {
|
||||
sctx->spm_trace.ptr = sctx->ws->buffer_map(sctx->ws, sctx->spm_trace.bo,
|
||||
NULL, PIPE_MAP_READ | RADEON_MAP_TEMPORARY);
|
||||
ac_spm_get_trace(&sctx->spm_trace, &spm_trace);
|
||||
}
|
||||
|
||||
ac_dump_rgp_capture(&sctx->screen->info, &thread_trace, sctx->spm_trace.bo ? &sctx->spm_trace : NULL);
|
||||
ac_dump_rgp_capture(&sctx->screen->info, &thread_trace, sctx->spm_trace.bo ? &spm_trace : NULL);
|
||||
|
||||
if (sctx->spm_trace.ptr)
|
||||
sctx->ws->buffer_unmap(sctx->ws, sctx->spm_trace.bo);
|
||||
|
||||
Reference in New Issue
Block a user