nvc0: move SW/HW queries info to their respective files
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 13 Oct 2015 20:16:23 +0000 (22:16 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 16 Oct 2015 19:57:44 +0000 (21:57 +0200)
This will help for handling HW SM queries variants on Fermi.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/gallium/drivers/nouveau/nvc0/nvc0_query.c
src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c
src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.h
src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_sm.c
src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_sm.h
src/gallium/drivers/nouveau/nvc0/nvc0_query_sw.c
src/gallium/drivers/nouveau/nvc0/nvc0_query_sw.h

index 80f311be2e84e206a0db67aec5d6b366477290d8..e4752e2dbc594c959f34327478d701f338ffdb29 100644 (file)
@@ -141,163 +141,19 @@ nvc0_render_condition(struct pipe_context *pipe,
    PUSH_DATA (push, hq->bo->offset + hq->offset);
 }
 
-/* === DRIVER STATISTICS === */
-
-#ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS
-
-static const char *nvc0_sw_query_drv_stat_names[] =
-{
-   "drv-tex_obj_current_count",
-   "drv-tex_obj_current_bytes",
-   "drv-buf_obj_current_count",
-   "drv-buf_obj_current_bytes_vid",
-   "drv-buf_obj_current_bytes_sys",
-   "drv-tex_transfers_rd",
-   "drv-tex_transfers_wr",
-   "drv-tex_copy_count",
-   "drv-tex_blit_count",
-   "drv-tex_cache_flush_count",
-   "drv-buf_transfers_rd",
-   "drv-buf_transfers_wr",
-   "drv-buf_read_bytes_staging_vid",
-   "drv-buf_write_bytes_direct",
-   "drv-buf_write_bytes_staging_vid",
-   "drv-buf_write_bytes_staging_sys",
-   "drv-buf_copy_bytes",
-   "drv-buf_non_kernel_fence_sync_count",
-   "drv-any_non_kernel_fence_sync_count",
-   "drv-query_sync_count",
-   "drv-gpu_serialize_count",
-   "drv-draw_calls_array",
-   "drv-draw_calls_indexed",
-   "drv-draw_calls_fallback_count",
-   "drv-user_buffer_upload_bytes",
-   "drv-constbuf_upload_count",
-   "drv-constbuf_upload_bytes",
-   "drv-pushbuf_count",
-   "drv-resource_validate_count"
-};
-
-#endif /* NOUVEAU_ENABLE_DRIVER_STATISTICS */
-
-/* === PERFORMANCE MONITORING COUNTERS for NVE4+ === */
-
-/* NOTE: intentionally using the same names as NV */
-static const char *nve4_hw_sm_query_names[] =
-{
-   /* MP counters */
-   "active_cycles",
-   "active_warps",
-   "atom_count",
-   "branch",
-   "divergent_branch",
-   "gld_request",
-   "global_ld_mem_divergence_replays",
-   "global_store_transaction",
-   "global_st_mem_divergence_replays",
-   "gred_count",
-   "gst_request",
-   "inst_executed",
-   "inst_issued",
-   "inst_issued1",
-   "inst_issued2",
-   "l1_global_load_hit",
-   "l1_global_load_miss",
-   "l1_local_load_hit",
-   "l1_local_load_miss",
-   "l1_local_store_hit",
-   "l1_local_store_miss",
-   "l1_shared_load_transactions",
-   "l1_shared_store_transactions",
-   "local_load",
-   "local_load_transactions",
-   "local_store",
-   "local_store_transactions",
-   "prof_trigger_00",
-   "prof_trigger_01",
-   "prof_trigger_02",
-   "prof_trigger_03",
-   "prof_trigger_04",
-   "prof_trigger_05",
-   "prof_trigger_06",
-   "prof_trigger_07",
-   "shared_load",
-   "shared_load_replay",
-   "shared_store",
-   "shared_store_replay",
-   "sm_cta_launched",
-   "threads_launched",
-   "uncached_global_load_transaction",
-   "warps_launched",
-   /* metrics, i.e. functions of the MP counters */
-   "metric-ipc",                   /* inst_executed, clock */
-   "metric-ipac",                  /* inst_executed, active_cycles */
-   "metric-ipec",                  /* inst_executed, (bool)inst_executed */
-   "metric-achieved_occupancy",    /* active_warps, active_cycles */
-   "metric-sm_efficiency",         /* active_cycles, clock */
-   "metric-inst_replay_overhead"   /* inst_issued, inst_executed */
-};
-
-/* === PERFORMANCE MONITORING COUNTERS for NVC0:NVE4 === */
-static const char *nvc0_hw_sm_query_names[] =
-{
-   /* MP counters */
-   "active_cycles",
-   "active_warps",
-   "atom_count",
-   "branch",
-   "divergent_branch",
-   "gld_request",
-   "gred_count",
-   "gst_request",
-   "inst_executed",
-   "inst_issued1_0",
-   "inst_issued1_1",
-   "inst_issued2_0",
-   "inst_issued2_1",
-   "local_load",
-   "local_store",
-   "prof_trigger_00",
-   "prof_trigger_01",
-   "prof_trigger_02",
-   "prof_trigger_03",
-   "prof_trigger_04",
-   "prof_trigger_05",
-   "prof_trigger_06",
-   "prof_trigger_07",
-   "shared_load",
-   "shared_store",
-   "threads_launched",
-   "thread_inst_executed_0",
-   "thread_inst_executed_1",
-   "thread_inst_executed_2",
-   "thread_inst_executed_3",
-   "warps_launched",
-};
-
 int
 nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen,
                                   unsigned id,
                                   struct pipe_driver_query_info *info)
 {
    struct nvc0_screen *screen = nvc0_screen(pscreen);
-   int count = 0;
-
-   count += NVC0_SW_QUERY_DRV_STAT_COUNT;
+   int num_sw_queries = 0, num_hw_queries = 0;
 
-   if (screen->base.device->drm_version >= 0x01000101) {
-      if (screen->compute) {
-         if (screen->base.class_3d == NVE4_3D_CLASS) {
-            count += NVE4_HW_SM_QUERY_COUNT;
-         } else
-         if (screen->base.class_3d < NVE4_3D_CLASS) {
-            count += NVC0_HW_SM_QUERY_COUNT;
-         }
-      }
-   }
+   num_sw_queries = nvc0_sw_get_driver_query_info(screen, 0, NULL);
+   num_hw_queries = nvc0_hw_get_driver_query_info(screen, 0, NULL);
 
    if (!info)
-      return count;
+      return num_sw_queries + num_hw_queries;
 
    /* Init default values. */
    info->name = "this_is_not_the_query_you_are_looking_for";
@@ -307,36 +163,11 @@ nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen,
    info->group_id = -1;
 
 #ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS
-   if (id < NVC0_SW_QUERY_DRV_STAT_COUNT) {
-      info->name = nvc0_sw_query_drv_stat_names[id];
-      info->query_type = NVC0_SW_QUERY_DRV_STAT(id);
-      info->max_value.u64 = 0;
-      if (strstr(info->name, "bytes"))
-         info->type = PIPE_DRIVER_QUERY_TYPE_BYTES;
-      info->group_id = NVC0_SW_QUERY_DRV_STAT_GROUP;
-      return 1;
-   } else
+   if (id < num_sw_queries)
+      return nvc0_sw_get_driver_query_info(screen, id, info);
 #endif
-   if (id < count) {
-      if (screen->compute) {
-         if (screen->base.class_3d == NVE4_3D_CLASS) {
-            info->name = nve4_hw_sm_query_names[id - NVC0_SW_QUERY_DRV_STAT_COUNT];
-            info->query_type = NVE4_HW_SM_QUERY(id - NVC0_SW_QUERY_DRV_STAT_COUNT);
-            info->max_value.u64 =
-               (id < NVE4_HW_SM_QUERY_METRIC_MP_OCCUPANCY) ? 0 : 100;
-            info->group_id = NVC0_HW_SM_QUERY_GROUP;
-            return 1;
-         } else
-         if (screen->base.class_3d < NVE4_3D_CLASS) {
-            info->name = nvc0_hw_sm_query_names[id - NVC0_SW_QUERY_DRV_STAT_COUNT];
-            info->query_type = NVC0_HW_SM_QUERY(id - NVC0_SW_QUERY_DRV_STAT_COUNT);
-            info->group_id = NVC0_HW_SM_QUERY_GROUP;
-            return 1;
-         }
-      }
-   }
-   /* user asked for info about non-existing query */
-   return 0;
+
+   return nvc0_hw_get_driver_query_info(screen, id - num_sw_queries, info);
 }
 
 int
index 16a639e3c48f7921de233426ead4fac31fa5b165..91254bedf1e19eb53a6113e1edc7e8c96145af02 100644 (file)
@@ -431,6 +431,20 @@ nvc0_hw_create_query(struct nvc0_context *nvc0, unsigned type, unsigned index)
    return q;
 }
 
+int
+nvc0_hw_get_driver_query_info(struct nvc0_screen *screen, unsigned id,
+                              struct pipe_driver_query_info *info)
+{
+   int num_hw_sm_queries = 0;
+
+   num_hw_sm_queries = nvc0_hw_sm_get_driver_query_info(screen, 0, NULL);
+
+   if (!info)
+      return num_hw_sm_queries;
+
+   return nvc0_hw_sm_get_driver_query_info(screen, id, info);
+}
+
 void
 nvc0_hw_query_pushbuf_submit(struct nouveau_pushbuf *push,
                              struct nvc0_query *q, unsigned result_offset)
index d72d894cc5a1ff3e0ce05b0955b5ad5a5a65477b..3701eb7100f0bb8e43abddd577823b1dd011f74c 100644 (file)
@@ -42,6 +42,9 @@ nvc0_hw_query(struct nvc0_query *q)
 
 struct nvc0_query *
 nvc0_hw_create_query(struct nvc0_context *, unsigned, unsigned);
+int
+nvc0_hw_get_driver_query_info(struct nvc0_screen *, unsigned,
+                              struct pipe_driver_query_info *);
 bool
 nvc0_hw_query_allocate(struct nvc0_context *, struct nvc0_query *, int);
 void
index 0b4a36f57dd3d9249af4e439369da897c65a333c..f4c1e52be38cc7294672c977eeb85469befa0538 100644 (file)
 
 /* === PERFORMANCE MONITORING COUNTERS for NVE4+ === */
 
+/* NOTE: intentionally using the same names as NV */
+static const char *nve4_hw_sm_query_names[] =
+{
+   /* MP counters */
+   "active_cycles",
+   "active_warps",
+   "atom_count",
+   "branch",
+   "divergent_branch",
+   "gld_request",
+   "global_ld_mem_divergence_replays",
+   "global_store_transaction",
+   "global_st_mem_divergence_replays",
+   "gred_count",
+   "gst_request",
+   "inst_executed",
+   "inst_issued",
+   "inst_issued1",
+   "inst_issued2",
+   "l1_global_load_hit",
+   "l1_global_load_miss",
+   "l1_local_load_hit",
+   "l1_local_load_miss",
+   "l1_local_store_hit",
+   "l1_local_store_miss",
+   "l1_shared_load_transactions",
+   "l1_shared_store_transactions",
+   "local_load",
+   "local_load_transactions",
+   "local_store",
+   "local_store_transactions",
+   "prof_trigger_00",
+   "prof_trigger_01",
+   "prof_trigger_02",
+   "prof_trigger_03",
+   "prof_trigger_04",
+   "prof_trigger_05",
+   "prof_trigger_06",
+   "prof_trigger_07",
+   "shared_load",
+   "shared_load_replay",
+   "shared_store",
+   "shared_store_replay",
+   "sm_cta_launched",
+   "threads_launched",
+   "uncached_global_load_transaction",
+   "warps_launched",
+   /* metrics, i.e. functions of the MP counters */
+   "metric-ipc",                   /* inst_executed, clock */
+   "metric-ipac",                  /* inst_executed, active_cycles */
+   "metric-ipec",                  /* inst_executed, (bool)inst_executed */
+   "metric-achieved_occupancy",    /* active_warps, active_cycles */
+   "metric-sm_efficiency",         /* active_cycles, clock */
+   "metric-inst_replay_overhead"   /* inst_issued, inst_executed */
+};
+
 /* Code to read out MP counters: They are accessible via mmio, too, but let's
  * just avoid mapping registers in userspace. We'd have to know which MPs are
  * enabled/present, too, and that information is not presently exposed.
@@ -230,6 +286,42 @@ static const struct nvc0_hw_sm_query_cfg nve4_hw_sm_queries[] =
 #undef _M2B
 
 /* === PERFORMANCE MONITORING COUNTERS for NVC0:NVE4 === */
+static const char *nvc0_hw_sm_query_names[] =
+{
+   /* MP counters */
+   "active_cycles",
+   "active_warps",
+   "atom_count",
+   "branch",
+   "divergent_branch",
+   "gld_request",
+   "gred_count",
+   "gst_request",
+   "inst_executed",
+   "inst_issued1_0",
+   "inst_issued1_1",
+   "inst_issued2_0",
+   "inst_issued2_1",
+   "local_load",
+   "local_store",
+   "prof_trigger_00",
+   "prof_trigger_01",
+   "prof_trigger_02",
+   "prof_trigger_03",
+   "prof_trigger_04",
+   "prof_trigger_05",
+   "prof_trigger_06",
+   "prof_trigger_07",
+   "shared_load",
+   "shared_store",
+   "threads_launched",
+   "thread_inst_executed_0",
+   "thread_inst_executed_1",
+   "thread_inst_executed_2",
+   "thread_inst_executed_3",
+   "warps_launched",
+};
+
 static const uint64_t nvc0_read_hw_sm_counters_code[] =
 {
    /* mov b32 $r8 $tidx
@@ -842,3 +934,44 @@ nvc0_hw_sm_create_query(struct nvc0_context *nvc0, unsigned type)
 
    return hq;
 }
+
+int
+nvc0_hw_sm_get_driver_query_info(struct nvc0_screen *screen, unsigned id,
+                                 struct pipe_driver_query_info *info)
+{
+   int count = 0;
+
+   if (screen->base.device->drm_version >= 0x01000101) {
+      if (screen->compute) {
+         if (screen->base.class_3d == NVE4_3D_CLASS) {
+            count += NVE4_HW_SM_QUERY_COUNT;
+         } else
+         if (screen->base.class_3d < NVE4_3D_CLASS) {
+            count += NVC0_HW_SM_QUERY_COUNT;
+         }
+      }
+   }
+
+   if (!info)
+      return count;
+
+   if (id < count) {
+      if (screen->compute) {
+         if (screen->base.class_3d == NVE4_3D_CLASS) {
+            info->name = nve4_hw_sm_query_names[id];
+            info->query_type = NVE4_HW_SM_QUERY(id);
+            info->max_value.u64 =
+               (id < NVE4_HW_SM_QUERY_METRIC_MP_OCCUPANCY) ? 0 : 100;
+            info->group_id = NVC0_HW_SM_QUERY_GROUP;
+            return 1;
+         } else
+         if (screen->base.class_3d < NVE4_3D_CLASS) {
+            info->name = nvc0_hw_sm_query_names[id];
+            info->query_type = NVC0_HW_SM_QUERY(id);
+            info->group_id = NVC0_HW_SM_QUERY_GROUP;
+            return 1;
+         }
+      }
+   }
+   return 0;
+}
index 0ad8a91ee6d168730b6f48fee56caff1d7ef0980..bb1166d1a8547d86f4e8a93c85f89008285574fc 100644 (file)
@@ -113,5 +113,7 @@ enum nvc0_hw_sm_queries
 
 struct nvc0_hw_query *
 nvc0_hw_sm_create_query(struct nvc0_context *, unsigned);
-
+int
+nvc0_hw_sm_get_driver_query_info(struct nvc0_screen *, unsigned,
+                                 struct pipe_driver_query_info *);
 #endif
index 5f33b1e019a4005291002a88143d06575c87117d..cd24618d564da4fbc0dd728bb37934eb0146029f 100644 (file)
 
 #include "nvc0_query_sw.h"
 
+/* === DRIVER STATISTICS === */
+
+#ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS
+
+static const char *nvc0_sw_query_drv_stat_names[] =
+{
+   "drv-tex_obj_current_count",
+   "drv-tex_obj_current_bytes",
+   "drv-buf_obj_current_count",
+   "drv-buf_obj_current_bytes_vid",
+   "drv-buf_obj_current_bytes_sys",
+   "drv-tex_transfers_rd",
+   "drv-tex_transfers_wr",
+   "drv-tex_copy_count",
+   "drv-tex_blit_count",
+   "drv-tex_cache_flush_count",
+   "drv-buf_transfers_rd",
+   "drv-buf_transfers_wr",
+   "drv-buf_read_bytes_staging_vid",
+   "drv-buf_write_bytes_direct",
+   "drv-buf_write_bytes_staging_vid",
+   "drv-buf_write_bytes_staging_sys",
+   "drv-buf_copy_bytes",
+   "drv-buf_non_kernel_fence_sync_count",
+   "drv-any_non_kernel_fence_sync_count",
+   "drv-query_sync_count",
+   "drv-gpu_serialize_count",
+   "drv-draw_calls_array",
+   "drv-draw_calls_indexed",
+   "drv-draw_calls_fallback_count",
+   "drv-user_buffer_upload_bytes",
+   "drv-constbuf_upload_count",
+   "drv-constbuf_upload_bytes",
+   "drv-pushbuf_count",
+   "drv-resource_validate_count"
+};
+
+#endif /* NOUVEAU_ENABLE_DRIVER_STATISTICS */
+
 static void
 nvc0_sw_destroy_query(struct nvc0_context *nvc0, struct nvc0_query *q)
 {
@@ -96,3 +135,28 @@ nvc0_sw_create_query(struct nvc0_context *nvcO, unsigned type, unsigned index)
 
    return q;
 }
+
+int
+nvc0_sw_get_driver_query_info(struct nvc0_screen *screen, unsigned id,
+                              struct pipe_driver_query_info *info)
+{
+   int count = 0;
+
+   count += NVC0_SW_QUERY_DRV_STAT_COUNT;
+   if (!info)
+      return count;
+
+#ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS
+   if (id < count) {
+      info->name = nvc0_sw_query_drv_stat_names[id];
+      info->query_type = NVC0_SW_QUERY_DRV_STAT(id);
+      info->type = PIPE_DRIVER_QUERY_TYPE_UINT64;
+      info->max_value.u64 = 0;
+      if (strstr(info->name, "bytes"))
+         info->type = PIPE_DRIVER_QUERY_TYPE_BYTES;
+      info->group_id = NVC0_SW_QUERY_DRV_STAT_GROUP;
+      return 1;
+   }
+#endif
+   return 0;
+}
index 71d23d9b41ea0ff863d88dd8ea04fbfe68c4d24d..eaa890e4fc0b64d0320df0f78298f93aed640d27 100644 (file)
@@ -57,5 +57,8 @@ enum nvc0_sw_query_drv_stat
 
 struct nvc0_query *
 nvc0_sw_create_query(struct nvc0_context *, unsigned, unsigned);
+int
+nvc0_sw_get_driver_query_info(struct nvc0_screen *, unsigned,
+                              struct pipe_driver_query_info *);
 
 #endif