pan/mdg: Fix out-of-order execution
authorAlyssa Rosenzweig <alyssa@collabora.com>
Sat, 29 Oct 2022 19:45:03 +0000 (15:45 -0400)
committerMarge Bot <emma+marge@anholt.net>
Wed, 23 Nov 2022 20:23:50 +0000 (20:23 +0000)
We can go up to 15 instructions out of order (performance fix) but we
can't go past a branch (bug fix).

Fixes: 30a393f4581 ("pan/mdg: Enable out-of-order execution after texture ops")
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19762>

src/panfrost/midgard/midgard.h
src/panfrost/midgard/midgard_emit.c

index d7715c6..2121dc4 100644 (file)
@@ -937,8 +937,8 @@ __attribute__((__packed__))
          * be any dependency (the blob appears to forbid even accessing other
          * channels of a given texture register). */
 
-        unsigned out_of_order   : 2;
-        unsigned unknown4  : 10;
+        unsigned out_of_order   : 4;
+        unsigned unknown4  : 8;
 
         /* In immediate mode, each offset field is an immediate range [0, 7].
          *
index 716e434..52dd4a8 100644 (file)
@@ -416,10 +416,11 @@ mir_pack_swizzle_tex(midgard_instruction *ins)
         /* TODO: bias component */
 }
 
-/* Up to 3 { ALU, LDST } bundles can execute in parallel with a texture op.
+/*
+ * Up to 15 { ALU, LDST } bundles can execute in parallel with a texture op.
  * Given a texture op, lookahead to see how many such bundles we can flag for
- * OoO execution */
-
+ * OoO execution
+ */
 static bool
 mir_can_run_ooo(midgard_block *block, midgard_bundle *bundle,
                 unsigned dependency)
@@ -432,11 +433,14 @@ mir_can_run_ooo(midgard_block *block, midgard_bundle *bundle,
         if (!IS_ALU(bundle->tag) && bundle->tag != TAG_LOAD_STORE_4)
                 return false;
 
-        /* Ensure there is no read-after-write dependency */
-
         for (unsigned i = 0; i < bundle->instruction_count; ++i) {
                 midgard_instruction *ins = bundle->instructions[i];
 
+                /* No branches, jumps, or discards */
+                if (ins->compact_branch)
+                        return false;
+
+                /* No read-after-write data dependencies */
                 mir_foreach_src(ins, s) {
                         if (ins->src[s] == dependency)
                                 return false;
@@ -452,7 +456,7 @@ mir_pack_tex_ooo(midgard_block *block, midgard_bundle *bundle, midgard_instructi
 {
         unsigned count = 0;
 
-        for (count = 0; count < 3; ++count) {
+        for (count = 0; count < 15; ++count) {
                 if (!mir_can_run_ooo(block, bundle + count + 1, ins->dest))
                         break;
         }