Module: Mesa
Branch: master
Commit: 5f0f9e1333385bd59a92b3a4dc72c4f9593eca68
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5f0f9e1333385bd59a92b3a4dc72c4f9593eca68

Author: Alyssa Rosenzweig <alyssa.rosenzw...@collabora.com>
Date:   Wed Aug 14 09:11:55 2019 -0700

pan/midgard: Implement blobber-db

We wire through some shader-db-style stats on the current shader in the
disassemble so we can get a quick estimate of shader complexity from a
trace.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzw...@collabora.com>
Suggested-by: Rob Clark <robdcl...@chromium.org>

---

 src/panfrost/midgard/disassemble.c     | 40 ++++++++++++++++++++++++++++++++--
 src/panfrost/midgard/disassemble.h     |  2 +-
 src/panfrost/midgard/midgard_compile.c |  2 +-
 src/panfrost/pandecode/decode.c        | 11 ++++++----
 4 files changed, 47 insertions(+), 8 deletions(-)

diff --git a/src/panfrost/midgard/disassemble.c 
b/src/panfrost/midgard/disassemble.c
index 8f2020c4c4c..382b4af7cbf 100644
--- a/src/panfrost/midgard/disassemble.c
+++ b/src/panfrost/midgard/disassemble.c
@@ -42,6 +42,10 @@
 
 static bool is_instruction_int = false;
 
+/* Stats */
+
+static unsigned nr_ins = 0;
+
 /* Prints a short form of the tag for branching, the minimum needed to be
  * legible and unambiguous */
 
@@ -541,6 +545,7 @@ print_vector_field(const char *name, uint16_t *words, 
uint16_t reg_word,
                                  reg_info->src2_reg, override, is_int);
         }
 
+        nr_ins++;
         printf("\n");
 }
 
@@ -621,6 +626,7 @@ print_scalar_field(const char *name, uint16_t *words, 
uint16_t reg_word,
         } else
                 print_scalar_src(alu_field->src2, reg_info->src2_reg);
 
+        nr_ins++;
         printf("\n");
 }
 
@@ -728,6 +734,8 @@ print_compact_branch_writeout_field(uint16_t word)
                 break;
         }
         }
+
+        nr_ins++;
 }
 
 static void
@@ -764,6 +772,8 @@ print_extended_branch_writeout_field(uint8_t *words)
         printf("%d -> ", br.offset);
         print_tag_short(br.dest_tag);
         printf("\n");
+
+        nr_ins++;
 }
 
 static unsigned
@@ -1034,6 +1044,8 @@ print_load_store_instr(uint64_t data,
         printf(", ");
         print_load_store_arg(word->arg_2, 1);
         printf(" /* %X */\n", word->varying_parameters);
+
+        nr_ins++;
 }
 
 static void
@@ -1291,10 +1303,12 @@ print_texture_word(uint32_t *word, unsigned tabs)
                 printf("// unknownA = 0x%x\n", texture->unknownA);
                 printf("// unknown8 = 0x%x\n", texture->unknown8);
         }
+
+        nr_ins++;
 }
 
 void
-disassemble_midgard(uint8_t *code, size_t size)
+disassemble_midgard(uint8_t *code, size_t size, bool stats, unsigned 
nr_registers)
 {
         uint32_t *words = (uint32_t *) code;
         unsigned num_words = size / 4;
@@ -1306,6 +1320,11 @@ disassemble_midgard(uint8_t *code, size_t size)
 
         unsigned i = 0;
 
+        /* Stats for shader-db */
+        unsigned nr_bundles = 0;
+        unsigned nr_quadwords = 0;
+        nr_ins = 0;
+
         while (i < num_words) {
                 unsigned tag = words[i] & 0xF;
                 unsigned next_tag = (words[i] >> 4) & 0xF;
@@ -1361,6 +1380,10 @@ disassemble_midgard(uint8_t *code, size_t size)
 
                 i += 4 * num_quad_words;
 
+                /* We are parsing per bundle anyway */
+                nr_bundles++;
+                nr_quadwords += num_quad_words;
+
                 /* Break based on instruction prefetch flag */
 
                 if (i < num_words && next == 1) {
@@ -1371,5 +1394,18 @@ disassemble_midgard(uint8_t *code, size_t size)
                 }
         }
 
-        return;
+        if (stats) {
+                unsigned nr_threads =
+                        (nr_registers <= 4) ? 4 :
+                        (nr_registers <= 8) ? 2 :
+                        1;
+
+                printf("%s shader: "
+                        "%u inst, %u bundles, %u quadwords, "
+                        "%u registers, %u threads, 0 loops\n",
+                        "FRAGMENT", /* TODO */
+                        nr_ins, nr_bundles, nr_quadwords,
+                        nr_registers, nr_threads);
+
+        }
 }
diff --git a/src/panfrost/midgard/disassemble.h 
b/src/panfrost/midgard/disassemble.h
index ab1837c201e..7ccee2649c6 100644
--- a/src/panfrost/midgard/disassemble.h
+++ b/src/panfrost/midgard/disassemble.h
@@ -1,2 +1,2 @@
 #include <stddef.h>
-void disassemble_midgard(uint8_t *code, size_t size);
+void disassemble_midgard(uint8_t *code, size_t size, bool stats, unsigned 
regs);
diff --git a/src/panfrost/midgard/midgard_compile.c 
b/src/panfrost/midgard/midgard_compile.c
index 460847e8266..e348ac05234 100644
--- a/src/panfrost/midgard/midgard_compile.c
+++ b/src/panfrost/midgard/midgard_compile.c
@@ -2741,7 +2741,7 @@ midgard_compile_shader_nir(struct midgard_screen *screen, 
nir_shader *nir, midga
         program->tls_size = ctx->tls_size;
 
         if (midgard_debug & MIDGARD_DBG_SHADERS)
-                disassemble_midgard(program->compiled.data, 
program->compiled.size);
+                disassemble_midgard(program->compiled.data, 
program->compiled.size, false, 0);
 
         if (midgard_debug & MIDGARD_DBG_SHADERDB) {
                 unsigned nr_bundles = 0, nr_ins = 0, nr_quadwords = 0;
diff --git a/src/panfrost/pandecode/decode.c b/src/panfrost/pandecode/decode.c
index 5bbff08f728..b49044cec2b 100644
--- a/src/panfrost/pandecode/decode.c
+++ b/src/panfrost/pandecode/decode.c
@@ -1430,7 +1430,7 @@ pandecode_scratchpad(uintptr_t pscratchpad, int job_no, 
char *suffix)
 
 static void
 pandecode_shader_disassemble(mali_ptr shader_ptr, int shader_no, int type,
-                             bool is_bifrost)
+                             bool is_bifrost, unsigned nr_regs)
 {
         struct pandecode_mapped_memory *mem = 
pandecode_find_mapped_gpu_mem_containing(shader_ptr);
         uint8_t *PANDECODE_PTR_VAR(code, mem, shader_ptr);
@@ -1446,7 +1446,7 @@ pandecode_shader_disassemble(mali_ptr shader_ptr, int 
shader_no, int type,
         if (is_bifrost) {
                 disassemble_bifrost(code, sz, false);
         } else {
-                disassemble_midgard(code, sz);
+                disassemble_midgard(code, sz, true, nr_regs);
         }
 
         printf("\n\n");
@@ -1507,6 +1507,8 @@ pandecode_vertex_tiler_postfix_pre(const struct 
mali_vertex_tiler_postfix *p,
                 pandecode_prop("attribute_count = %" PRId16, 
s->attribute_count);
                 pandecode_prop("varying_count = %" PRId16, s->varying_count);
 
+                unsigned nr_registers = 0;
+
                 if (is_bifrost) {
                         pandecode_log(".bifrost1 = {\n");
                         pandecode_indent++;
@@ -1523,6 +1525,7 @@ pandecode_vertex_tiler_postfix_pre(const struct 
mali_vertex_tiler_postfix *p,
                         pandecode_prop("uniform_count = %" PRId16, 
s->midgard1.uniform_count);
                         pandecode_prop("uniform_buffer_count = %" PRId16, 
s->midgard1.uniform_buffer_count);
                         pandecode_prop("work_count = %" PRId16, 
s->midgard1.work_count);
+                        nr_registers = s->midgard1.work_count;
 
                         pandecode_log(".flags = ");
                         pandecode_log_decoded_flags(shader_midgard1_flag_info, 
s->midgard1.flags);
@@ -1627,12 +1630,12 @@ pandecode_vertex_tiler_postfix_pre(const struct 
mali_vertex_tiler_postfix *p,
                                         shader = 
pandecode_midgard_blend_mrt(blend_base, job_no, i);
 
                                 if (shader & ~0xF)
-                                        pandecode_shader_disassemble(shader, 
job_no, job_type, false);
+                                        pandecode_shader_disassemble(shader, 
job_no, job_type, false, 0);
                         }
                 }
 
                 if (shader_ptr & ~0xF)
-                   pandecode_shader_disassemble(shader_ptr, job_no, job_type, 
is_bifrost);
+                   pandecode_shader_disassemble(shader_ptr, job_no, job_type, 
is_bifrost, nr_registers);
         } else
                 pandecode_msg("<no shader>\n");
 

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to