We can deduct the size from another field, let's just save some space.
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Mark Janes <mark.a.janes@intel.com>
enum gen_perf_counter_data_type data_type;
uint64_t raw_max;
size_t offset;
- size_t size;
union {
uint64_t (*oa_counter_read_uint64)(struct gen_perf *perf,
int (*ioctl)(int, unsigned long, void *);
};
+static inline size_t
+gen_perf_query_counter_get_size(const struct gen_perf_query_counter *counter)
+{
+ switch (counter->data_type) {
+ case GEN_PERF_COUNTER_DATA_TYPE_BOOL32:
+ return sizeof(uint32_t);
+ case GEN_PERF_COUNTER_DATA_TYPE_UINT32:
+ return sizeof(uint32_t);
+ case GEN_PERF_COUNTER_DATA_TYPE_UINT64:
+ return sizeof(uint64_t);
+ case GEN_PERF_COUNTER_DATA_TYPE_FLOAT:
+ return sizeof(float);
+ case GEN_PERF_COUNTER_DATA_TYPE_DOUBLE:
+ return sizeof(double);
+ default:
+ unreachable("invalid counter data type");
+ }
+}
+
static inline struct gen_perf_query_info *
gen_perf_query_append_query_info(struct gen_perf *perf, int max_counters)
{
counter->desc = description;
counter->type = GEN_PERF_COUNTER_TYPE_RAW;
counter->data_type = GEN_PERF_COUNTER_DATA_TYPE_UINT64;
- counter->size = sizeof(uint64_t);
counter->offset = sizeof(uint64_t) * query->n_counters;
counter->pipeline_stat.reg = reg;
counter->pipeline_stat.numerator = numerator;
current_offset = pot_align(current_offset, sizeof(c_type))
c("counter->offset = " + str(current_offset) + ";\n")
- c("counter->size = sizeof(" + c_type + ");\n")
if availability:
c_outdent(3);
offset = output_counter_report(set, counter, offset)
- c("\nquery->data_size = counter->offset + counter->size;\n")
+ c("\nquery->data_size = counter->offset + gen_perf_query_counter_get_size(counter);\n")
c_outdent(3)
c("}");
*name = counter->name;
*desc = counter->desc;
*offset = counter->offset;
- *data_size = counter->size;
+ *data_size = gen_perf_query_counter_get_size(counter);
*type_enum = gen_counter_type_enum_to_gl_type(counter->type);
*data_type_enum = gen_counter_data_type_to_gl_type(counter->data_type);
*raw_max = counter->raw_max;
const struct gen_perf_query_counter *counter = &query->counters[i];
uint64_t *out_uint64;
float *out_float;
+ size_t counter_size = gen_perf_query_counter_get_size(counter);
- if (counter->size) {
+ if (counter_size) {
switch (counter->data_type) {
case GEN_PERF_COUNTER_DATA_TYPE_UINT64:
out_uint64 = (uint64_t *)(data + counter->offset);
/* So far we aren't using uint32, double or bool32... */
unreachable("unexpected counter data type");
}
- written = counter->offset + counter->size;
+ written = counter->offset + counter_size;
}
}
counter->type = GEN_PERF_COUNTER_TYPE_RAW;
counter->data_type = data_type;
counter->offset = data_offset;
- counter->size = data_size;
- assert(counter->offset + counter->size <= query->data_size);
query->n_counters++;
+
+ assert(counter->offset + gen_perf_query_counter_get_size(counter) <= query->data_size);
}
#define MDAPI_QUERY_ADD_COUNTER(query, struct_name, field_name, type_name) \