Commit ae5868a9 authored by Lionel Landwerlin's avatar Lionel Landwerlin
Browse files

intel/perf: add helper to compute metrics from counters



The produces array tells use what metric to enable for a given pass.
Signed-off-by: Lionel Landwerlin's avatarLionel Landwerlin <lionel.g.landwerlin@intel.com>
parent 421cbe3b
......@@ -544,6 +544,30 @@ gen_perf_get_n_passes(struct gen_perf *perf,
return __builtin_popcount(queries_mask);
}
void
gen_perf_get_counters_passes(struct gen_perf *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,
......
......@@ -231,6 +231,12 @@ struct gen_perf {
int (*ioctl)(int, unsigned long, void *);
};
struct gen_perf_counter_pass {
struct gen_perf_query_info *query;
struct gen_perf_query_counter *counter;
uint32_t pass;
};
static inline size_t
gen_perf_query_counter_get_size(const struct gen_perf_query_counter *counter)
{
......@@ -320,6 +326,10 @@ uint32_t gen_perf_get_n_passes(struct gen_perf *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 *perf,
const uint32_t *counter_indices,
uint32_t counter_indices_count,
struct gen_perf_counter_pass *counter_pass);
void gen_perf_query_result_read_frequencies(struct gen_perf_query_result *result,
const struct gen_device_info *devinfo,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment