intel/perf: move query_mask and location out of gen_perf_query_counter
Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Mark Janes <mark.a.janes@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5399>
This commit is contained in:

committed by
Marge Bot

parent
9f19662550
commit
3144bc1d33
@@ -594,8 +594,8 @@ i915_get_sseu(int drm_fd, struct drm_i915_gem_context_param_sseu *sseu)
|
||||
static int
|
||||
compare_counters(const void *_c1, const void *_c2)
|
||||
{
|
||||
const struct gen_perf_query_counter * const *c1 = _c1, * const *c2 = _c2;
|
||||
return strcmp((*c1)->symbol_name, (*c2)->symbol_name);
|
||||
const struct gen_perf_query_counter_info *c1 = _c1, *c2 = _c2;
|
||||
return strcmp(c1->counter->symbol_name, c2->counter->symbol_name);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -603,6 +603,21 @@ build_unique_counter_list(struct gen_perf_config *perf)
|
||||
{
|
||||
assert(perf->n_queries < 64);
|
||||
|
||||
size_t max_counters = 0;
|
||||
|
||||
for (int q = 0; q < perf->n_queries; q++)
|
||||
max_counters += perf->queries[q].n_counters;
|
||||
|
||||
/*
|
||||
* Allocate big enough array to hold maximum possible number of counters.
|
||||
* We can't alloc it small and realloc when needed because the hash table
|
||||
* below contains pointers to this array.
|
||||
*/
|
||||
struct gen_perf_query_counter_info *counter_infos =
|
||||
ralloc_array_size(perf, sizeof(counter_infos[0]), max_counters);
|
||||
|
||||
perf->n_counters = 0;
|
||||
|
||||
struct hash_table *counters_table =
|
||||
_mesa_hash_table_create(perf,
|
||||
_mesa_hash_string,
|
||||
@@ -612,39 +627,37 @@ build_unique_counter_list(struct gen_perf_config *perf)
|
||||
struct gen_perf_query_info *query = &perf->queries[q];
|
||||
|
||||
for (int c = 0; c < query->n_counters; c++) {
|
||||
struct gen_perf_query_counter *counter, *unique_counter;
|
||||
struct gen_perf_query_counter *counter;
|
||||
struct gen_perf_query_counter_info *counter_info;
|
||||
|
||||
counter = &query->counters[c];
|
||||
entry = _mesa_hash_table_search(counters_table, counter->symbol_name);
|
||||
|
||||
if (entry) {
|
||||
unique_counter = entry->data;
|
||||
unique_counter->query_mask |= BITFIELD64_BIT(q);
|
||||
counter_info = entry->data;
|
||||
counter_info->query_mask |= BITFIELD64_BIT(q);
|
||||
continue;
|
||||
}
|
||||
assert(perf->n_counters < max_counters);
|
||||
|
||||
unique_counter = counter;
|
||||
unique_counter->query_mask = BITFIELD64_BIT(q);
|
||||
counter_info = &counter_infos[perf->n_counters++];
|
||||
counter_info->counter = counter;
|
||||
counter_info->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);
|
||||
counter_info->location.group_idx = q;
|
||||
counter_info->location.counter_idx = c;
|
||||
|
||||
_mesa_hash_table_insert(counters_table, counter->symbol_name, counter_info);
|
||||
}
|
||||
}
|
||||
|
||||
perf->n_counters = _mesa_hash_table_num_entries(counters_table);
|
||||
perf->counters = ralloc_array(perf, struct gen_perf_query_counter *,
|
||||
perf->n_counters);
|
||||
|
||||
int c = 0;
|
||||
hash_table_foreach(counters_table, entry) {
|
||||
struct gen_perf_query_counter *counter = entry->data;
|
||||
perf->counters[c++] = counter;
|
||||
}
|
||||
|
||||
_mesa_hash_table_destroy(counters_table, NULL);
|
||||
|
||||
qsort(perf->counters, perf->n_counters, sizeof(perf->counters[0]),
|
||||
/* Now we can realloc counter_infos array because hash table doesn't exist. */
|
||||
perf->counter_infos = reralloc_array_size(perf, counter_infos,
|
||||
sizeof(counter_infos[0]), perf->n_counters);
|
||||
|
||||
qsort(perf->counter_infos, perf->n_counters, sizeof(perf->counter_infos[0]),
|
||||
compare_counters);
|
||||
}
|
||||
|
||||
@@ -814,13 +827,13 @@ get_passes_mask(struct gen_perf_config *perf,
|
||||
assert(counter_indices[i] < perf->n_counters);
|
||||
|
||||
uint32_t idx = counter_indices[i];
|
||||
if (__builtin_popcount(perf->counters[idx]->query_mask) != (q + 1))
|
||||
if (__builtin_popcount(perf->counter_infos[idx].query_mask) != (q + 1))
|
||||
continue;
|
||||
|
||||
if (queries_mask & perf->counters[idx]->query_mask)
|
||||
if (queries_mask & perf->counter_infos[idx].query_mask)
|
||||
continue;
|
||||
|
||||
queries_mask |= BITFIELD64_BIT(ffsll(perf->counters[idx]->query_mask) - 1);
|
||||
queries_mask |= BITFIELD64_BIT(ffsll(perf->counter_infos[idx].query_mask) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -859,9 +872,9 @@ gen_perf_get_counters_passes(struct gen_perf_config *perf,
|
||||
assert(counter_indices[i] < perf->n_counters);
|
||||
|
||||
uint32_t idx = counter_indices[i];
|
||||
counter_pass[i].counter = perf->counters[idx];
|
||||
counter_pass[i].counter = perf->counter_infos[idx].counter;
|
||||
|
||||
uint32_t query_idx = ffsll(perf->counters[idx]->query_mask & queries_mask) - 1;
|
||||
uint32_t query_idx = ffsll(perf->counter_infos[idx].query_mask & queries_mask) - 1;
|
||||
counter_pass[i].query = &perf->queries[query_idx];
|
||||
|
||||
uint32_t clear_bits = 63 - query_idx;
|
||||
|
Reference in New Issue
Block a user