diff options
author | Lionel Landwerlin <[email protected]> | 2018-10-05 17:31:11 +0100 |
---|---|---|
committer | Lionel Landwerlin <[email protected]> | 2020-05-20 14:02:27 +0300 |
commit | c36933e0818ade16cb9d29b91c7d4f0068f7af39 (patch) | |
tree | 0514100c9d6a8ba18afbc0b183e92d88c0090e11 /src/intel/perf | |
parent | a7890f559b34e5a97689f16f0f1cdb1651fc4de7 (diff) |
intel/perf: add helper to compute metrics from counters
The produced array tells use what metric to enable for a given pass.
Signed-off-by: Lionel Landwerlin <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2775>
Diffstat (limited to 'src/intel/perf')
-rw-r--r-- | src/intel/perf/gen_perf.c | 24 | ||||
-rw-r--r-- | src/intel/perf/gen_perf.h | 10 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/intel/perf/gen_perf.c b/src/intel/perf/gen_perf.c index 30b87a02647..8c24344ed04 100644 --- a/src/intel/perf/gen_perf.c +++ b/src/intel/perf/gen_perf.c @@ -821,6 +821,30 @@ gen_perf_get_n_passes(struct gen_perf_config *perf, return __builtin_popcount(queries_mask); } +void +gen_perf_get_counters_passes(struct gen_perf_config *perf, + const uint32_t *counter_indices, + uint32_t counter_indices_count, + struct gen_perf_counter_pass *counter_pass) +{ + uint64_t queries_mask = get_passes_mask(perf, counter_indices, counter_indices_count); + uint32_t n_passes = __builtin_popcount(queries_mask); + + for (uint32_t i = 0; i < counter_indices_count; i++) { + assert(counter_indices[i] < perf->n_counters); + + uint32_t idx = counter_indices[i]; + counter_pass[i].counter = perf->counters[idx]; + + uint32_t query_idx = ffsll(perf->counters[idx]->query_mask & queries_mask) - 1; + counter_pass[i].query = &perf->queries[query_idx]; + + uint32_t clear_bits = 63 - query_idx; + counter_pass[i].pass = __builtin_popcount((queries_mask << clear_bits) >> clear_bits) - 1; + assert(counter_pass[i].pass < n_passes); + } +} + /* Accumulate 32bits OA counters */ static inline void accumulate_uint32(const uint32_t *report0, diff --git a/src/intel/perf/gen_perf.h b/src/intel/perf/gen_perf.h index 70525d06441..6e02702ea00 100644 --- a/src/intel/perf/gen_perf.h +++ b/src/intel/perf/gen_perf.h @@ -289,6 +289,12 @@ struct gen_perf_config { } vtbl; }; +struct gen_perf_counter_pass { + struct gen_perf_query_info *query; + struct gen_perf_query_counter *counter; + uint32_t pass; +}; + void gen_perf_init_metrics(struct gen_perf_config *perf_cfg, const struct gen_device_info *devinfo, int drm_fd, @@ -359,5 +365,9 @@ uint32_t gen_perf_get_n_passes(struct gen_perf_config *perf, const uint32_t *counter_indices, uint32_t counter_indices_count, struct gen_perf_query_info **pass_queries); +void gen_perf_get_counters_passes(struct gen_perf_config *perf, + const uint32_t *counter_indices, + uint32_t counter_indices_count, + struct gen_perf_counter_pass *counter_pass); #endif /* GEN_PERF_H */ |