Mesa (staging/21.3): intel/perf: Move some static blocks of C code out of the python script.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue May 10 06:58:50 UTC 2022
Module: Mesa
Branch: staging/21.3
Commit: f3500570be6ef86bcce22b1a5327c87f650d9812
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f3500570be6ef86bcce22b1a5327c87f650d9812
Author: Emma Anholt <emma at anholt.net>
Date: Mon Feb 7 11:06:18 2022 -0800
intel/perf: Move some static blocks of C code out of the python script.
Now my editor can help me format code as I type.
Reviewed-by: Matt Turner <mattst88 at gmail.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
(cherry picked from commit 12e065ddecd50885158c724a2ccfa453c445ce74)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16405>
---
src/intel/perf/gen_perf.py | 48 +------------------------
src/intel/perf/intel_perf_setup.h | 75 +++++++++++++++++++++++++++++++++++++++
2 files changed, 76 insertions(+), 47 deletions(-)
diff --git a/src/intel/perf/gen_perf.py b/src/intel/perf/gen_perf.py
index 41c4b3ca43b..be5e829b636 100644
--- a/src/intel/perf/gen_perf.py
+++ b/src/intel/perf/gen_perf.py
@@ -686,53 +686,7 @@ def main():
c(textwrap.dedent("""\
#include "perf/intel_perf.h"
-
-
- #define MIN(a, b) ((a < b) ? (a) : (b))
- #define MAX(a, b) ((a > b) ? (a) : (b))
-
- static struct intel_perf_query_info *
- intel_query_alloc(struct intel_perf_config *perf, int ncounters)
- {
- struct intel_perf_query_info *query = rzalloc(perf, struct intel_perf_query_info);
- query->perf = perf;
- query->kind = INTEL_PERF_QUERY_TYPE_OA;
- query->n_counters = 0;
- query->oa_metrics_set_id = 0; /* determined at runtime, via sysfs */
- query->counters = rzalloc_array(query, struct intel_perf_query_counter, ncounters);
- return query;
- }
-
- static struct intel_perf_query_info *
- hsw_query_alloc(struct intel_perf_config *perf, int ncounters)
- {
- struct intel_perf_query_info *query = intel_query_alloc(perf, ncounters);
- query->oa_format = I915_OA_FORMAT_A45_B8_C8;
- /* Accumulation buffer offsets... */
- query->gpu_time_offset = 0;
- query->a_offset = query->gpu_time_offset + 1;
- query->b_offset = query->a_offset + 45;
- query->c_offset = query->b_offset + 8;
- query->perfcnt_offset = query->c_offset + 8;
- query->rpstat_offset = query->perfcnt_offset + 2;
- return query;
- }
-
- static struct intel_perf_query_info *
- bdw_query_alloc(struct intel_perf_config *perf, int ncounters)
- {
- struct intel_perf_query_info *query = intel_query_alloc(perf, ncounters);
- query->oa_format = I915_OA_FORMAT_A32u40_A4u32_B8_C8;
- /* Accumulation buffer offsets... */
- query->gpu_time_offset = 0;
- query->gpu_clock_offset = query->gpu_time_offset + 1;
- query->a_offset = query->gpu_clock_offset + 1;
- query->b_offset = query->a_offset + 36;
- query->c_offset = query->b_offset + 8;
- query->perfcnt_offset = query->c_offset + 8;
- query->rpstat_offset = query->perfcnt_offset + 2;
- return query;
- }
+ #include "perf/intel_perf_setup.h"
"""))
# Print out all equation functions.
diff --git a/src/intel/perf/intel_perf_setup.h b/src/intel/perf/intel_perf_setup.h
new file mode 100644
index 00000000000..8ba0d57ed3f
--- /dev/null
+++ b/src/intel/perf/intel_perf_setup.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright © 2018 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef INTEL_PERF_SETUP_H
+#define INTEL_PERF_SETUP_H
+
+#include "perf/intel_perf.h"
+
+#define MIN(a, b) ((a < b) ? (a) : (b))
+#define MAX(a, b) ((a > b) ? (a) : (b))
+
+static struct intel_perf_query_info *
+intel_query_alloc(struct intel_perf_config *perf, int ncounters)
+{
+ struct intel_perf_query_info *query = rzalloc(perf, struct intel_perf_query_info);
+ query->perf = perf;
+ query->kind = INTEL_PERF_QUERY_TYPE_OA;
+ query->n_counters = 0;
+ query->oa_metrics_set_id = 0; /* determined at runtime, via sysfs */
+ query->counters = rzalloc_array(query, struct intel_perf_query_counter, ncounters);
+ return query;
+}
+
+static struct intel_perf_query_info *
+hsw_query_alloc(struct intel_perf_config *perf, int ncounters)
+{
+ struct intel_perf_query_info *query = intel_query_alloc(perf, ncounters);
+ query->oa_format = I915_OA_FORMAT_A45_B8_C8;
+ /* Accumulation buffer offsets... */
+ query->gpu_time_offset = 0;
+ query->a_offset = query->gpu_time_offset + 1;
+ query->b_offset = query->a_offset + 45;
+ query->c_offset = query->b_offset + 8;
+ query->perfcnt_offset = query->c_offset + 8;
+ query->rpstat_offset = query->perfcnt_offset + 2;
+ return query;
+}
+
+static struct intel_perf_query_info *
+bdw_query_alloc(struct intel_perf_config *perf, int ncounters)
+{
+ struct intel_perf_query_info *query = intel_query_alloc(perf, ncounters);
+ query->oa_format = I915_OA_FORMAT_A32u40_A4u32_B8_C8;
+ /* Accumulation buffer offsets... */
+ query->gpu_time_offset = 0;
+ query->gpu_clock_offset = query->gpu_time_offset + 1;
+ query->a_offset = query->gpu_clock_offset + 1;
+ query->b_offset = query->a_offset + 36;
+ query->c_offset = query->b_offset + 8;
+ query->perfcnt_offset = query->c_offset + 8;
+ query->rpstat_offset = query->perfcnt_offset + 2;
+ return query;
+}
+
+#endif /* INTEL_PERF_SETUP_H */
More information about the mesa-commit
mailing list