ac/rgp: move radv/sqtt functions to ac
pso_correlation and code_object_loader don't depend on drivers specific logic so move them to the shared code. Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9277>
This commit is contained in:

committed by
Marge Bot

parent
b2ef94943f
commit
7f5a8db96d
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "ac_gpu_info.h"
|
||||
#include "util/u_math.h"
|
||||
#include "util/os_time.h"
|
||||
|
||||
uint64_t
|
||||
ac_thread_trace_get_info_offset(unsigned se)
|
||||
@@ -96,3 +97,54 @@ ac_get_expected_buffer_size(struct radeon_info *rad_info,
|
||||
|
||||
return (info->gfx9_write_counter * 32) / 1024;
|
||||
}
|
||||
|
||||
bool
|
||||
ac_sqtt_add_pso_correlation(struct ac_thread_trace_data *thread_trace_data,
|
||||
uint64_t pipeline_hash)
|
||||
{
|
||||
struct rgp_pso_correlation *pso_correlation = &thread_trace_data->rgp_pso_correlation;
|
||||
struct rgp_pso_correlation_record *record;
|
||||
|
||||
record = malloc(sizeof(struct rgp_pso_correlation_record));
|
||||
if (!record)
|
||||
return false;
|
||||
|
||||
record->api_pso_hash = pipeline_hash;
|
||||
record->pipeline_hash[0] = pipeline_hash;
|
||||
record->pipeline_hash[1] = pipeline_hash;
|
||||
memset(record->api_level_obj_name, 0, sizeof(record->api_level_obj_name));
|
||||
|
||||
simple_mtx_lock(&pso_correlation->lock);
|
||||
list_addtail(&record->list, &pso_correlation->record);
|
||||
pso_correlation->record_count++;
|
||||
simple_mtx_unlock(&pso_correlation->lock);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ac_sqtt_add_code_object_loader_event(struct ac_thread_trace_data *thread_trace_data,
|
||||
uint64_t pipeline_hash,
|
||||
uint64_t base_address)
|
||||
{
|
||||
struct rgp_loader_events *loader_events = &thread_trace_data->rgp_loader_events;
|
||||
struct rgp_loader_events_record *record;
|
||||
|
||||
record = malloc(sizeof(struct rgp_loader_events_record));
|
||||
if (!record)
|
||||
return false;
|
||||
|
||||
record->loader_event_type = RGP_LOAD_TO_GPU_MEMORY;
|
||||
record->reserved = 0;
|
||||
record->base_address = base_address & 0xffffffffffff;
|
||||
record->code_object_hash[0] = pipeline_hash;
|
||||
record->code_object_hash[1] = pipeline_hash;
|
||||
record->time_stamp = os_time_get_nano();
|
||||
|
||||
simple_mtx_lock(&loader_events->lock);
|
||||
list_addtail(&record->list, &loader_events->record);
|
||||
loader_events->record_count++;
|
||||
simple_mtx_unlock(&loader_events->lock);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -489,4 +489,12 @@ struct rgp_sqtt_marker_pipeline_bind {
|
||||
static_assert(sizeof(struct rgp_sqtt_marker_pipeline_bind) == 12,
|
||||
"rgp_sqtt_marker_pipeline_bind doesn't match RGP spec");
|
||||
|
||||
|
||||
bool ac_sqtt_add_pso_correlation(struct ac_thread_trace_data *thread_trace_data,
|
||||
uint64_t pipeline_hash);
|
||||
|
||||
bool ac_sqtt_add_code_object_loader_event(struct ac_thread_trace_data *thread_trace_data,
|
||||
uint64_t pipeline_hash,
|
||||
uint64_t base_address);
|
||||
|
||||
#endif
|
||||
|
@@ -1008,71 +1008,6 @@ radv_mesa_to_rgp_shader_stage(struct radv_pipeline *pipeline,
|
||||
}
|
||||
}
|
||||
|
||||
static VkResult
|
||||
radv_add_pso_correlation(struct radv_device *device,
|
||||
struct radv_pipeline *pipeline)
|
||||
{
|
||||
struct ac_thread_trace_data *thread_trace_data = &device->thread_trace;
|
||||
struct rgp_pso_correlation *pso_correlation = &thread_trace_data->rgp_pso_correlation;
|
||||
struct rgp_pso_correlation_record *record;
|
||||
|
||||
record = malloc(sizeof(struct rgp_pso_correlation_record));
|
||||
if (!record)
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
|
||||
record->api_pso_hash = pipeline->pipeline_hash;
|
||||
record->pipeline_hash[0] = pipeline->pipeline_hash;
|
||||
record->pipeline_hash[1] = pipeline->pipeline_hash;
|
||||
memset(record->api_level_obj_name, 0, sizeof(record->api_level_obj_name));
|
||||
|
||||
simple_mtx_lock(&thread_trace_data->rgp_pso_correlation.lock);
|
||||
list_addtail(&record->list, &pso_correlation->record);
|
||||
pso_correlation->record_count++;
|
||||
simple_mtx_unlock(&thread_trace_data->rgp_pso_correlation.lock);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
static VkResult
|
||||
radv_add_code_object_loader_event(struct radv_device *device,
|
||||
struct radv_pipeline *pipeline)
|
||||
{
|
||||
struct ac_thread_trace_data *thread_trace_data = &device->thread_trace;
|
||||
struct rgp_loader_events *loader_events = &thread_trace_data->rgp_loader_events;
|
||||
struct rgp_loader_events_record *record;
|
||||
uint64_t base_va = ~0;
|
||||
|
||||
record = malloc(sizeof(struct rgp_loader_events_record));
|
||||
if (!record)
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
|
||||
/* Find the lowest shader BO VA. */
|
||||
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
|
||||
struct radv_shader_variant *shader = pipeline->shaders[i];
|
||||
uint64_t va;
|
||||
|
||||
if (!shader)
|
||||
continue;
|
||||
|
||||
va = radv_buffer_get_va(shader->bo) + shader->bo_offset;
|
||||
base_va = MIN2(base_va, va);
|
||||
}
|
||||
|
||||
record->loader_event_type = RGP_LOAD_TO_GPU_MEMORY;
|
||||
record->reserved = 0;
|
||||
record->base_address = base_va & 0xffffffffffff;
|
||||
record->code_object_hash[0] = pipeline->pipeline_hash;
|
||||
record->code_object_hash[1] = pipeline->pipeline_hash;
|
||||
record->time_stamp = os_time_get_nano();
|
||||
|
||||
simple_mtx_lock(&loader_events->lock);
|
||||
list_addtail(&record->list, &loader_events->record);
|
||||
loader_events->record_count++;
|
||||
simple_mtx_unlock(&loader_events->lock);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
static VkResult
|
||||
radv_add_code_object(struct radv_device *device,
|
||||
struct radv_pipeline *pipeline)
|
||||
@@ -1134,15 +1069,30 @@ static VkResult
|
||||
radv_register_pipeline(struct radv_device *device,
|
||||
struct radv_pipeline *pipeline)
|
||||
{
|
||||
VkResult result;
|
||||
bool result;
|
||||
uint64_t base_va = ~0;
|
||||
|
||||
result = radv_add_pso_correlation(device, pipeline);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
result = ac_sqtt_add_pso_correlation(&device->thread_trace, pipeline->pipeline_hash);
|
||||
if (!result)
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
|
||||
result = radv_add_code_object_loader_event(device, pipeline);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
/* Find the lowest shader BO VA. */
|
||||
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
|
||||
struct radv_shader_variant *shader = pipeline->shaders[i];
|
||||
uint64_t va;
|
||||
|
||||
if (!shader)
|
||||
continue;
|
||||
|
||||
va = radv_buffer_get_va(shader->bo) + shader->bo_offset;
|
||||
base_va = MIN2(base_va, va);
|
||||
}
|
||||
|
||||
result = ac_sqtt_add_code_object_loader_event(&device->thread_trace,
|
||||
pipeline->pipeline_hash,
|
||||
base_va);
|
||||
if (!result)
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
|
||||
result = radv_add_code_object(device, pipeline);
|
||||
if (result != VK_SUCCESS)
|
||||
|
Reference in New Issue
Block a user