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 3308ad82c3d63894933995d4c231a6f0c1ac54de..db70878d1dffb7b13d1dca344995f3376f16a65d 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 1f97e115906d666a3763ae6fd608e7cecd01ab2d..1bbaa76e584ebaf41f703e4952297cf2e591dfaa 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 e19fde6e4317aedcfdf29d93fa8f4195baf5c3e0..247fff04ac58fd7be41c8a449053825093e53cb7 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 c88be069d06566c57257e8cc7bc2a233485f1d75..1b3ca6546b838b1eb17a5e2570f7c9cf880e3bfb 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 c4d52166fb7a9933c6637e37f96008b0d65699ce..2148c496d7dbc9325b28f03c295ed0334434b73b 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 896a463ee6fae3bee52179cd6c965e28e99e41d2..f011b8eeedfe9a3d65494f2648b8555ed3ecf927 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 2a6ce2ca216e2c0e0656b6b35400c0a20e7263ff..8e43b68b22986dc020b28e804b6c787c0eafaca6 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,