diff options
-rw-r--r-- | src/gallium/drivers/iris/iris_monitor.c | 112 | ||||
-rw-r--r-- | src/gallium/drivers/iris/iris_monitor.h | 13 | ||||
-rw-r--r-- | src/gallium/drivers/iris/iris_screen.h | 3 | ||||
-rw-r--r-- | src/intel/perf/gen_perf.c | 2 | ||||
-rw-r--r-- | src/intel/perf/gen_perf.h | 9 |
5 files changed, 31 insertions, 108 deletions
diff --git a/src/gallium/drivers/iris/iris_monitor.c b/src/gallium/drivers/iris/iris_monitor.c index a8409607c7a..80bddcc3b31 100644 --- a/src/gallium/drivers/iris/iris_monitor.c +++ b/src/gallium/drivers/iris/iris_monitor.c @@ -43,24 +43,19 @@ iris_get_monitor_info(struct pipe_screen *pscreen, unsigned index, struct pipe_driver_query_info *info) { const struct iris_screen *screen = (struct iris_screen *)pscreen; - assert(screen->monitor_cfg); - if (!screen->monitor_cfg) + const struct gen_perf_config *perf_cfg = screen->perf_cfg; + assert(perf_cfg); + if (!perf_cfg) return 0; - const struct iris_monitor_config *monitor_cfg = screen->monitor_cfg; - if (!info) { /* return the number of metrics */ - return monitor_cfg->num_counters; + return perf_cfg->n_counters; } - const struct gen_perf_config *perf_cfg = monitor_cfg->perf_cfg; - const int group = monitor_cfg->counters[index].group; - const int counter_index = monitor_cfg->counters[index].counter; - struct gen_perf_query_counter *counter = - &perf_cfg->queries[group].counters[counter_index]; + struct gen_perf_query_counter *counter = perf_cfg->counters[index]; - info->group_id = group; + info->group_id = counter->location.group_idx; info->name = counter->name; info->query_type = PIPE_QUERY_DRIVER_SPECIFIC + index; @@ -97,84 +92,18 @@ iris_get_monitor_info(struct pipe_screen *pscreen, unsigned index, static bool iris_monitor_init_metrics(struct iris_screen *screen) { - struct iris_monitor_config *monitor_cfg = - rzalloc(screen, struct iris_monitor_config); - struct gen_perf_config *perf_cfg = NULL; - if (unlikely(!monitor_cfg)) - goto allocation_error; - perf_cfg = gen_perf_new(monitor_cfg); + struct gen_perf_config *perf_cfg = gen_perf_new(screen); if (unlikely(!perf_cfg)) - goto allocation_error; + return false; - monitor_cfg->perf_cfg = perf_cfg; + screen->perf_cfg = perf_cfg; iris_perf_init_vtbl(perf_cfg); gen_perf_init_metrics(perf_cfg, &screen->devinfo, screen->fd, true /* pipeline stats*/); - screen->monitor_cfg = monitor_cfg; - - /* a gallium "group" is equivalent to a gen "query" - * a gallium "query" is equivalent to a gen "query_counter" - * - * Each gen_query supports a specific number of query_counters. To - * allocate the array of iris_monitor_counter, we need an upper bound - * (ignoring duplicate query_counters). - */ - int gen_query_counters_count = 0; - for (int gen_query_id = 0; - gen_query_id < perf_cfg->n_queries; - ++gen_query_id) { - gen_query_counters_count += perf_cfg->queries[gen_query_id].n_counters; - } - monitor_cfg->counters = rzalloc_size(monitor_cfg, - sizeof(struct iris_monitor_counter) * - gen_query_counters_count); - if (unlikely(!monitor_cfg->counters)) - goto allocation_error; - - int iris_monitor_id = 0; - for (int group = 0; group < perf_cfg->n_queries; ++group) { - for (int counter = 0; - counter < perf_cfg->queries[group].n_counters; - ++counter) { - /* Check previously identified metrics to filter out duplicates. The - * user is not helped by having the same metric available in several - * groups. (n^2 algorithm). - */ - bool duplicate = false; - for (int existing_group = 0; - existing_group < group && !duplicate; - ++existing_group) { - for (int existing_counter = 0; - existing_counter < perf_cfg->queries[existing_group].n_counters && !duplicate; - ++existing_counter) { - const char *current_name = - perf_cfg->queries[group].counters[counter].name; - const char *existing_name = - perf_cfg->queries[existing_group].counters[existing_counter].name; - if (strcmp(current_name, existing_name) == 0) { - duplicate = true; - } - } - } - if (duplicate) - continue; - monitor_cfg->counters[iris_monitor_id].group = group; - monitor_cfg->counters[iris_monitor_id].counter = counter; - ++iris_monitor_id; - } - } - monitor_cfg->num_counters = iris_monitor_id; - return monitor_cfg->num_counters; - -allocation_error: - if (monitor_cfg) - free(monitor_cfg->counters); - free(perf_cfg); - free(monitor_cfg); - return false; + return perf_cfg->n_counters > 0; } int @@ -183,13 +112,12 @@ iris_get_monitor_group_info(struct pipe_screen *pscreen, struct pipe_driver_query_group_info *info) { struct iris_screen *screen = (struct iris_screen *)pscreen; - if (!screen->monitor_cfg) { + if (!screen->perf_cfg) { if (!iris_monitor_init_metrics(screen)) return 0; } - const struct iris_monitor_config *monitor_cfg = screen->monitor_cfg; - const struct gen_perf_config *perf_cfg = monitor_cfg->perf_cfg; + const struct gen_perf_config *perf_cfg = screen->perf_cfg; if (!info) { /* return the count that can be queried */ @@ -214,14 +142,13 @@ static void iris_init_monitor_ctx(struct iris_context *ice) { struct iris_screen *screen = (struct iris_screen *) ice->ctx.screen; - struct iris_monitor_config *monitor_cfg = screen->monitor_cfg; ice->perf_ctx = gen_perf_new_context(ice); if (unlikely(!ice->perf_ctx)) return; struct gen_perf_context *perf_ctx = ice->perf_ctx; - struct gen_perf_config *perf_cfg = monitor_cfg->perf_cfg; + struct gen_perf_config *perf_cfg = screen->perf_cfg; gen_perf_init_context(perf_ctx, perf_cfg, ice, @@ -238,8 +165,7 @@ iris_create_monitor_object(struct iris_context *ice, unsigned *query_types) { struct iris_screen *screen = (struct iris_screen *) ice->ctx.screen; - struct iris_monitor_config *monitor_cfg = screen->monitor_cfg; - struct gen_perf_config *perf_cfg = monitor_cfg->perf_cfg; + struct gen_perf_config *perf_cfg = screen->perf_cfg; struct gen_perf_query_object *query_obj = NULL; /* initialize perf context if this has not already been done. This @@ -252,8 +178,8 @@ iris_create_monitor_object(struct iris_context *ice, assert(num_queries > 0); int query_index = query_types[0] - PIPE_QUERY_DRIVER_SPECIFIC; - assert(query_index <= monitor_cfg->num_counters); - const int group = monitor_cfg->counters[query_index].group; + assert(query_index <= perf_cfg->n_counters); + const int group = perf_cfg->counters[query_index]->location.group_idx; struct iris_monitor_object *monitor = calloc(1, sizeof(struct iris_monitor_object)); @@ -270,10 +196,10 @@ iris_create_monitor_object(struct iris_context *ice, unsigned current_query_index = current_query - PIPE_QUERY_DRIVER_SPECIFIC; /* all queries must be in the same group */ - assert(current_query_index <= monitor_cfg->num_counters); - assert(monitor_cfg->counters[current_query_index].group == group); + assert(current_query_index <= perf_cfg->n_counters); + assert(perf_cfg->counters[current_query_index]->location.group_idx == group); monitor->active_counters[i] = - monitor_cfg->counters[current_query_index].counter; + perf_cfg->counters[current_query_index]->location.counter_idx; } /* create the gen_perf_query */ diff --git a/src/gallium/drivers/iris/iris_monitor.h b/src/gallium/drivers/iris/iris_monitor.h index cb9dbd6e992..3c4ca1604a5 100644 --- a/src/gallium/drivers/iris/iris_monitor.h +++ b/src/gallium/drivers/iris/iris_monitor.h @@ -25,19 +25,6 @@ #include "pipe/p_screen.h" -struct iris_monitor_counter { - int group; - int counter; -}; - -struct iris_monitor_config { - struct gen_perf_config *perf_cfg; - - /* gallium requires an index for each counter */ - int num_counters; - struct iris_monitor_counter *counters; -}; - int iris_get_monitor_info(struct pipe_screen *pscreen, unsigned index, struct pipe_driver_query_info *info); int iris_get_monitor_group_info(struct pipe_screen *pscreen, diff --git a/src/gallium/drivers/iris/iris_screen.h b/src/gallium/drivers/iris/iris_screen.h index 836954fc1d6..1a03a3f46df 100644 --- a/src/gallium/drivers/iris/iris_screen.h +++ b/src/gallium/drivers/iris/iris_screen.h @@ -36,7 +36,6 @@ struct gen_l3_config; struct brw_vue_map; -struct iris_monitor_config; struct iris_vs_prog_key; struct iris_tcs_prog_key; struct iris_tes_prog_key; @@ -201,7 +200,7 @@ struct iris_screen { struct isl_device isl_dev; struct iris_bufmgr *bufmgr; struct brw_compiler *compiler; - struct iris_monitor_config *monitor_cfg; + struct gen_perf_config *perf_cfg; const struct gen_l3_config *l3_config_3d; const struct gen_l3_config *l3_config_cs; diff --git a/src/intel/perf/gen_perf.c b/src/intel/perf/gen_perf.c index 24fee821474..4de459dfb93 100644 --- a/src/intel/perf/gen_perf.c +++ b/src/intel/perf/gen_perf.c @@ -626,6 +626,8 @@ build_unique_counter_list(struct gen_perf_config *perf) unique_counter = counter; unique_counter->query_mask = BITFIELD64_BIT(q); + unique_counter->location.group_idx = q; + unique_counter->location.counter_idx = c; _mesa_hash_table_insert(counters_table, unique_counter->symbol_name, unique_counter); } } diff --git a/src/intel/perf/gen_perf.h b/src/intel/perf/gen_perf.h index c9c8a3042a8..ca4a66a2e9d 100644 --- a/src/intel/perf/gen_perf.h +++ b/src/intel/perf/gen_perf.h @@ -173,6 +173,15 @@ struct gen_perf_query_counter { size_t offset; uint64_t query_mask; + /** + * Each counter can be a part of many groups, each time at different index. + * This struct stores one of those locations. + */ + struct { + int group_idx; /* query/group number */ + int counter_idx; /* index inside of query/group */ + } location; + union { uint64_t (*oa_counter_read_uint64)(struct gen_perf_config *perf, const struct gen_perf_query_info *query, |