Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 1/3] lib/i915/perf: Stop generating silly C code
Date: Mon,  3 Apr 2023 20:47:58 +0300	[thread overview]
Message-ID: <20230403174800.19621-2-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20230403174800.19621-1-ville.syrjala@linux.intel.com>

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Seems a bit weird to use use python to generate C code that
generates arrays of registers. Just generate those arrays
straight from python.

$ size -A meson-generated_.._i915_perf_registers_acmgt3.c
-.text                1737442      0
+.text                 257871      0
+.rodata               820776      0

$ du -h build/lib/libi915_perf.so.1.5
- 23M   build/lib/libi915_perf.so.1.5
+ 19M   build/lib/libi915_perf.so.1.5

And the change in build time:
$ touch lib/i915/perf-configs/perf-registers-codegen.py
$ time ninja -C build -j1

ADL:
- real  2m32,251s
+ real  1m8,984s

VLV:
- real	19m14.999s
+ real	8m3.277s

Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 lib/i915/perf-configs/perf-registers-codegen.py | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/lib/i915/perf-configs/perf-registers-codegen.py b/lib/i915/perf-configs/perf-registers-codegen.py
index 19f09d7a897c..bde3d14323d3 100644
--- a/lib/i915/perf-configs/perf-registers-codegen.py
+++ b/lib/i915/perf-configs/perf-registers-codegen.py
@@ -68,9 +68,19 @@ def generate_register_configs(set):
             set.gen.output_availability(set, availability, register_config.get('type') + ' register config')
             c.indent(4)
 
+        c("{")
+        c.indent(4)
+        c("static const struct intel_perf_register_prog _%s[] = {" % t)
+        c.indent(4)
         for register in register_config.findall('register'):
-            c("metric_set->%s[metric_set->n_%s++] = (struct intel_perf_register_prog) { .reg = %s, .val = %s };" %
-              (t, t, register.get('address'), register.get('value')))
+            c("{ .reg = %s, .val = %s }," %
+              (register.get('address'), register.get('value')))
+        c.outdent(4)
+        c("};")
+        c("memcpy(metric_set->%s, _%s, sizeof(_%s));" % (t, t, t))
+        c("metric_set->n_%s = sizeof(_%s) / sizeof(_%s[0]);" % (t, t, t))
+        c.outdent(4)
+        c("}")
 
         if availability:
             c.outdent(4)
@@ -146,6 +156,7 @@ def main():
     c(copyright)
     c("\n")
     c("#include <stdlib.h>")
+    c("#include <string.h>")
     c("\n")
     c("#include \"%s\"" % header_file)
     c("#include \"i915/perf.h\"")
-- 
2.39.2

  reply	other threads:[~2023-04-03 17:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-03 17:47 [igt-dev] [PATCH i-g-t 0/3] lib/i915/perf: Speed up the build Ville Syrjala
2023-04-03 17:47 ` Ville Syrjala [this message]
2023-04-03 17:47 ` [igt-dev] [PATCH i-g-t 2/3] lib/i915/perf: Stop making copies of the registers Ville Syrjala
2023-04-03 17:48 ` [igt-dev] [PATCH i-g-t 3/3] lib/i915/perf: Convert the metric counters to an array as well Ville Syrjala
2023-04-03 19:07 ` [igt-dev] ✓ Fi.CI.BAT: success for lib/i915/perf: Speed up the build Patchwork
2023-04-04  1:27 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2023-04-04  7:59 ` [igt-dev] [PATCH i-g-t 0/3] " Lionel Landwerlin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230403174800.19621-2-ville.syrjala@linux.intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox