[Mesa-dev] [PATCH 22/23] i965: Emit compaction stats without walking the assembly.

Matt Turner mattst88 at gmail.com
Mon May 19 11:55:48 PDT 2014


The instruction count does not include padding NOPs, but the compaction
stats do.
---
 src/mesa/drivers/dri/i965/brw_eu_compact.c       | 19 -------------------
 src/mesa/drivers/dri/i965/brw_fs_generator.cpp   |  8 ++++++++
 src/mesa/drivers/dri/i965/brw_vec4_generator.cpp |  7 +++++++
 3 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_eu_compact.c b/src/mesa/drivers/dri/i965/brw_eu_compact.c
index f40ba04..0560367 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_compact.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_compact.c
@@ -841,23 +841,4 @@ brw_compact_instructions(struct brw_compile *p, int start_offset,
 
       annotation[num_annotations].offset = p->next_insn_offset;
    }
-
-   if (0) {
-      fprintf(stderr, "dumping compacted program\n");
-      brw_disassemble(brw, store, 0, p->next_insn_offset - start_offset, stderr);
-
-      int cmp = 0;
-      for (offset = 0; offset < p->next_insn_offset - start_offset;) {
-         struct brw_instruction *insn = store + offset;
-
-         if (insn->header.cmpt_control) {
-            offset += 8;
-            cmp++;
-         } else {
-            offset += 16;
-         }
-      }
-      fprintf(stderr, "%db/%db saved (%d%%)\n", cmp * 8, offset + cmp * 8,
-              cmp * 8 * 100 / (offset + cmp * 8));
-   }
 }
diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
index f70e7b2..4b2245b 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
@@ -1827,11 +1827,15 @@ fs_generator::generate_assembly(exec_list *simd8_instructions,
 
          struct annotation *annotation;
          int num_annotations;
+         int start_offset = p->next_insn_offset;
 
          dispatch_width = (i + 1) * 8;
          generate_code(instructions[i], &num_annotations, &annotation);
+
+         int before_size = p->next_insn_offset - start_offset;
          brw_compact_instructions(p, prog_data->prog_offset_16,
                                   num_annotations, annotation);
+         int after_size = p->next_insn_offset - start_offset;
 
          if (unlikely(debug_flag)) {
             if (this->prog) {
@@ -1847,6 +1851,10 @@ fs_generator::generate_assembly(exec_list *simd8_instructions,
                fprintf(stderr, "Native code for blorp program (SIMD%d dispatch):\n",
                        dispatch_width);
             }
+            fprintf(stderr, "SIMD%d shader: %d instructions. Compacted %d to %d"
+                            " bytes (%.0f%%)\n",
+                    dispatch_width, before_size / 16, before_size, after_size,
+                    100.0f * (before_size - after_size) / before_size);
             dump_assembly(p->store, num_annotations, annotation, brw, prog,
                           brw_disassemble);
             ralloc_free(annotation);
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
index 819ed10..affcc90 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
@@ -1365,7 +1365,10 @@ vec4_generator::generate_assembly(exec_list *instructions,
 
    brw_set_access_mode(p, BRW_ALIGN_16);
    generate_code(instructions, &num_annotations, &annotation);
+
+   int before_size = p->next_insn_offset;
    brw_compact_instructions(p, 0, num_annotations, annotation);
+   int after_size = p->next_insn_offset;
 
    if (unlikely(debug_flag)) {
       if (shader_prog) {
@@ -1375,6 +1378,10 @@ vec4_generator::generate_assembly(exec_list *instructions,
       } else {
          fprintf(stderr, "Native code for vertex program %d:\n", prog->Id);
       }
+      fprintf(stderr, "vec4 shader: %d instructions. Compacted %d to %d"
+                      " bytes (%.0f%%)\n",
+              before_size / 16, before_size, after_size,
+              100.0f * (before_size - after_size) / before_size);
       dump_assembly(p->store, num_annotations, annotation, brw, prog,
                     brw_disassemble);
       ralloc_free(annotation);
-- 
1.8.3.2



More information about the mesa-dev mailing list