Mesa (main): pan/bi: Account for message preloading in shaderdb

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Feb 24 20:12:34 UTC 2022


Module: Mesa
Branch: main
Commit: c8437cd415c79ad597b44c9d3c24540c772c5a59
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c8437cd415c79ad597b44c9d3c24540c772c5a59

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Wed Feb 23 13:49:54 2022 -0500

pan/bi: Account for message preloading in shaderdb

If a message-passing instruction like LD_VAR is preloaded, it will no longer be
counted in the shader cycle counts. Add a special message preload counter that
approximates the cost of preloading, so this information doesn't get a lost.

Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9438>

---

 src/panfrost/bifrost/bifrost_compile.c | 48 +++++++++++++++++++++++++++++-----
 1 file changed, 41 insertions(+), 7 deletions(-)

diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c
index 64f2e3fe4d3..ce51a5a40c6 100644
--- a/src/panfrost/bifrost/bifrost_compile.c
+++ b/src/panfrost/bifrost/bifrost_compile.c
@@ -3260,6 +3260,34 @@ bi_count_tuple_stats(bi_clause *clause, bi_tuple *tuple, struct bi_stats *stats)
 
 }
 
+/*
+ * v7 allows preloading LD_VAR or VAR_TEX messages that must complete before the
+ * shader completes. These costs are not accounted for in the general cycle
+ * counts, so this function calculates the effective cost of these messages, as
+ * if they were executed by shader code.
+ */
+static unsigned
+bi_count_preload_cost(bi_context *ctx)
+{
+        /* Units: 1/16 of a normalized cycle, assuming that we may interpolate
+         * 16 fp16 varying components per cycle or fetch two texels per cycle.
+         */
+        unsigned cost = 0;
+
+        for (unsigned i = 0; i < ARRAY_SIZE(ctx->info.bifrost->messages); ++i) {
+                struct bifrost_message_preload msg = ctx->info.bifrost->messages[i];
+
+                if (msg.enabled && msg.texture) {
+                        /* 2 coordinate, 2 half-words each, plus texture */
+                        cost += 12;
+                } else if (msg.enabled) {
+                        cost += (msg.num_components * (msg.fp16 ? 1 : 2));
+                }
+        }
+
+        return cost;
+}
+
 static const char *
 bi_shader_stage_name(bi_context *ctx)
 {
@@ -3313,20 +3341,26 @@ bi_print_stats(bi_context *ctx, unsigned size, FILE *fp)
         unsigned nr_threads = full_threads ? 2 : 1;
 
         /* Dump stats */
-
-        fprintf(stderr, "%s - %s shader: "
+        char *str = ralloc_asprintf(NULL, "%s - %s shader: "
                         "%u inst, %u tuples, %u clauses, "
                         "%f cycles, %f arith, %f texture, %f vary, %f ldst, "
-                        "%u quadwords, %u threads, %u loops, "
-                        "%u:%u spills:fills\n",
+                        "%u quadwords, %u threads",
                         ctx->nir->info.label ?: "",
                         bi_shader_stage_name(ctx),
                         stats.nr_ins, stats.nr_tuples, stats.nr_clauses,
                         cycles_bound, cycles_arith, cycles_texture,
                         cycles_varying, cycles_ldst,
-                        size / 16, nr_threads,
-                        ctx->loop_count,
-                        ctx->spills, ctx->fills);
+                        size / 16, nr_threads);
+
+        if (ctx->arch == 7) {
+                ralloc_asprintf_append(&str, ", %u preloads", bi_count_preload_cost(ctx));
+        }
+
+        ralloc_asprintf_append(&str, ", %u loops, %u:%u spills:fills\n",
+                        ctx->loop_count, ctx->spills, ctx->fills);
+
+        fputs(str, stderr);
+        ralloc_free(str);
 }
 
 static int



More information about the mesa-commit mailing list