radeonsi: add a HUD query for getting an average GFX BO list size
authorMarek Olšák <marek.olsak@amd.com>
Thu, 29 Jun 2017 17:20:06 +0000 (19:20 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 4 Jul 2017 13:40:37 +0000 (15:40 +0200)
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeon/r600_query.c
src/gallium/drivers/radeon/r600_query.h
src/gallium/drivers/radeon/radeon_winsys.h
src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h
src/gallium/winsys/radeon/drm/radeon_drm_winsys.c

index 3308ad8..db70878 100644 (file)
@@ -71,6 +71,7 @@ static enum radeon_value_id winsys_id_from_type(unsigned type)
        case R600_QUERY_NUM_MAPPED_BUFFERS: return RADEON_NUM_MAPPED_BUFFERS;
        case R600_QUERY_NUM_GFX_IBS: return RADEON_NUM_GFX_IBS;
        case R600_QUERY_NUM_SDMA_IBS: return RADEON_NUM_SDMA_IBS;
+       case R600_QUERY_GFX_BO_LIST_SIZE: return RADEON_GFX_BO_LIST_COUNTER;
        case R600_QUERY_NUM_BYTES_MOVED: return RADEON_NUM_BYTES_MOVED;
        case R600_QUERY_NUM_EVICTIONS: return RADEON_NUM_EVICTIONS;
        case R600_QUERY_NUM_VRAM_CPU_PAGE_FAULTS: return RADEON_NUM_VRAM_CPU_PAGE_FAULTS;
@@ -173,6 +174,12 @@ static bool r600_query_sw_begin(struct r600_common_context *rctx,
                query->begin_result = rctx->ws->query_value(rctx->ws, ws_id);
                break;
        }
+       case R600_QUERY_GFX_BO_LIST_SIZE:
+               ws_id = winsys_id_from_type(query->b.type);
+               query->begin_result = rctx->ws->query_value(rctx->ws, ws_id);
+               query->begin_time = rctx->ws->query_value(rctx->ws,
+                                                         RADEON_NUM_GFX_IBS);
+               break;
        case R600_QUERY_CS_THREAD_BUSY:
                ws_id = winsys_id_from_type(query->b.type);
                query->begin_result = rctx->ws->query_value(rctx->ws, ws_id);
@@ -318,6 +325,12 @@ static bool r600_query_sw_end(struct r600_common_context *rctx,
                query->end_result = rctx->ws->query_value(rctx->ws, ws_id);
                break;
        }
+       case R600_QUERY_GFX_BO_LIST_SIZE:
+               ws_id = winsys_id_from_type(query->b.type);
+               query->end_result = rctx->ws->query_value(rctx->ws, ws_id);
+               query->end_time = rctx->ws->query_value(rctx->ws,
+                                                       RADEON_NUM_GFX_IBS);
+               break;
        case R600_QUERY_CS_THREAD_BUSY:
                ws_id = winsys_id_from_type(query->b.type);
                query->end_result = rctx->ws->query_value(rctx->ws, ws_id);
@@ -404,6 +417,10 @@ static bool r600_query_sw_get_result(struct r600_common_context *rctx,
                return result->b;
        }
 
+       case R600_QUERY_GFX_BO_LIST_SIZE:
+               result->u64 = (query->end_result - query->begin_result) /
+                             (query->end_time - query->begin_time);
+               return true;
        case R600_QUERY_CS_THREAD_BUSY:
        case R600_QUERY_GALLIUM_THREAD_BUSY:
                result->u64 = (query->end_result - query->begin_result) * 100 /
@@ -1861,6 +1878,7 @@ static struct pipe_driver_query_info r600_driver_query_list[] = {
        X("num-mapped-buffers",         NUM_MAPPED_BUFFERS,     UINT64, AVERAGE),
        X("num-GFX-IBs",                NUM_GFX_IBS,            UINT64, AVERAGE),
        X("num-SDMA-IBs",               NUM_SDMA_IBS,           UINT64, AVERAGE),
+       X("GFX-BO-list-size",           GFX_BO_LIST_SIZE,       UINT64, AVERAGE),
        X("num-bytes-moved",            NUM_BYTES_MOVED,        BYTES, CUMULATIVE),
        X("num-evictions",              NUM_EVICTIONS,          UINT64, CUMULATIVE),
        X("VRAM-CPU-page-faults",       NUM_VRAM_CPU_PAGE_FAULTS, UINT64, CUMULATIVE),
index 1f97e11..1bbaa76 100644 (file)
@@ -69,6 +69,7 @@ enum {
        R600_QUERY_NUM_MAPPED_BUFFERS,
        R600_QUERY_NUM_GFX_IBS,
        R600_QUERY_NUM_SDMA_IBS,
+       R600_QUERY_GFX_BO_LIST_SIZE,
        R600_QUERY_NUM_BYTES_MOVED,
        R600_QUERY_NUM_EVICTIONS,
        R600_QUERY_NUM_VRAM_CPU_PAGE_FAULTS,
index e19fde6..247fff0 100644 (file)
@@ -91,6 +91,7 @@ enum radeon_value_id {
     RADEON_TIMESTAMP,
     RADEON_NUM_GFX_IBS,
     RADEON_NUM_SDMA_IBS,
+    RADEON_GFX_BO_LIST_COUNTER, /* number of BOs submitted in gfx IBs */
     RADEON_NUM_BYTES_MOVED,
     RADEON_NUM_EVICTIONS,
     RADEON_NUM_VRAM_CPU_PAGE_FAULTS,
index c88be06..1b3ca65 100644 (file)
@@ -1225,6 +1225,9 @@ void amdgpu_cs_submit_ib(void *job, int thread_index)
          cs->flags[i] = (util_last_bit64(buffer->u.real.priority_usage) - 1) / 4;
       }
 
+      if (acs->ring_type == RING_GFX)
+         ws->gfx_bo_list_counter += cs->num_real_buffers;
+
       r = amdgpu_bo_list_create(ws->dev, cs->num_real_buffers,
                                 cs->handles, cs->flags,
                                 &cs->request.resources);
index c4d5216..2148c49 100644 (file)
@@ -140,6 +140,8 @@ static uint64_t amdgpu_query_value(struct radeon_winsys *rws,
       return ws->num_gfx_IBs;
    case RADEON_NUM_SDMA_IBS:
       return ws->num_sdma_IBs;
+   case RADEON_GFX_BO_LIST_COUNTER:
+      return ws->gfx_bo_list_counter;
    case RADEON_NUM_BYTES_MOVED:
       amdgpu_query_info(ws->dev, AMDGPU_INFO_NUM_BYTES_MOVED, 8, &retval);
       return retval;
index 896a463..f011b8e 100644 (file)
@@ -65,6 +65,7 @@ struct amdgpu_winsys {
    uint64_t num_gfx_IBs;
    uint64_t num_sdma_IBs;
    uint64_t num_mapped_buffers;
+   uint64_t gfx_bo_list_counter;
 
    struct radeon_info info;
 
index 2a6ce2c..8e43b68 100644 (file)
@@ -631,6 +631,7 @@ static uint64_t radeon_query_value(struct radeon_winsys *rws,
     case RADEON_NUM_EVICTIONS:
     case RADEON_NUM_VRAM_CPU_PAGE_FAULTS:
     case RADEON_VRAM_VIS_USAGE:
+    case RADEON_GFX_BO_LIST_COUNTER:
         return 0; /* unimplemented */
     case RADEON_VRAM_USAGE:
         radeon_get_drm_value(ws->fd, RADEON_INFO_VRAM_USAGE,