intel/perf: drop counter size field
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Tue, 2 Oct 2018 14:41:41 +0000 (15:41 +0100)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Wed, 17 Apr 2019 13:10:42 +0000 (14:10 +0100)
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>
src/intel/perf/gen_perf.h
src/intel/perf/gen_perf.py
src/mesa/drivers/dri/i965/brw_performance_query.c
src/mesa/drivers/dri/i965/brw_performance_query_mdapi.c

index 24fbd15cac1a942edc8671d88d0f637fc96aa3e3..6e7a6d36c1570ec6a4f0e81cfeba606a33780e19 100644 (file)
@@ -106,7 +106,6 @@ struct gen_perf_query_counter {
    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,
@@ -193,6 +192,25 @@ struct gen_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)
 {
@@ -230,7 +248,6 @@ gen_perf_query_info_add_stat_reg(struct gen_perf_query_info *query,
    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;
index c41e8f3eb110a4f808d6d0f38397407382aac019..f7d0b86b2cf211767cf07e76ca73dcc91a89d186 100644 (file)
@@ -381,7 +381,6 @@ def output_counter_report(set, counter, current_offset):
 
     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);
@@ -722,7 +721,7 @@ def main():
                 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("}");
index 831ad97a6750fe99c4250f5b40498ae5a3bdd692..cd7961905bd11415430744ecfb55c1228af7eb50 100644 (file)
@@ -447,7 +447,7 @@ brw_get_perf_counter_info(struct gl_context *ctx,
    *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;
@@ -1392,8 +1392,9 @@ get_oa_counter_data(struct brw_context *brw,
       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);
@@ -1411,7 +1412,7 @@ get_oa_counter_data(struct brw_context *brw,
             /* 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;
       }
    }
 
index f77560390d735ace2138db95a37da8aad119ddba..379515d328f21e7e7f56e1d00775fe9dd77adbf0 100644 (file)
@@ -43,10 +43,10 @@ fill_mdapi_perf_query_counter(struct gen_perf_query_info *query,
    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) \