Mesa (master): panfrost/midgard: Preview for data hazards

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Mar 4 05:05:26 UTC 2019


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

Author: Alyssa Rosenzweig <alyssa at rosenzweig.io>
Date:   Wed Feb 27 05:40:55 2019 +0000

panfrost/midgard: Preview for data hazards

If a selected unit causes a data hazard, the whole block gets cut short.
So, we preview for data hazards _while_ selecting units.

Signed-off-by: Alyssa Rosenzweig <alyssa at rosenzweig.io>
Tested-by: Tomeu Vizoso <tomeu.vizoso at collabora.com

---

 .../drivers/panfrost/midgard/midgard_compile.c     | 25 ++++++++++++++--------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/panfrost/midgard/midgard_compile.c b/src/gallium/drivers/panfrost/midgard/midgard_compile.c
index e37037ac737..f9bd611f789 100644
--- a/src/gallium/drivers/panfrost/midgard/midgard_compile.c
+++ b/src/gallium/drivers/panfrost/midgard/midgard_compile.c
@@ -2060,6 +2060,20 @@ can_run_concurrent_ssa(midgard_instruction *first, midgard_instruction *second)
         return true;
 }
 
+static bool
+midgard_has_hazard(
+                midgard_instruction **segment, unsigned segment_size,
+                midgard_instruction *ains)
+{
+        for (int s = 0; s < segment_size; ++s)
+                if (!can_run_concurrent_ssa(segment[s], ains))
+                        return true;
+
+        return false;
+
+
+}
+
 /* Schedules, but does not emit, a single basic block. After scheduling, the
  * final tag and size of the block are known, which are necessary for branching
  * */
@@ -2159,7 +2173,7 @@ schedule_bundle(compiler_context *ctx, midgard_block *block, midgard_instruction
                                                 else
                                                         break;
                                         } else {
-                                                if ((units & UNIT_SADD) && !(control & UNIT_SADD))
+                                                if ((units & UNIT_SADD) && !(control & UNIT_SADD) && !midgard_has_hazard(segment, segment_size, ains))
                                                         unit = UNIT_SADD;
                                                 else if (units & UNIT_SMUL)
                                                         unit = ((units & UNIT_VMUL) && !(control & UNIT_VMUL)) ? UNIT_VMUL : UNIT_SMUL;
@@ -2180,14 +2194,7 @@ schedule_bundle(compiler_context *ctx, midgard_block *block, midgard_instruction
                         if (last_unit < UNIT_VADD && unit >= UNIT_VADD)
                                 segment_size = 0;
 
-                        /* Check for data hazards */
-                        int has_hazard = false;
-
-                        for (int s = 0; s < segment_size; ++s)
-                                if (!can_run_concurrent_ssa(segment[s], ains))
-                                        has_hazard = true;
-
-                        if (has_hazard)
+                        if (midgard_has_hazard(segment, segment_size, ains))
                                 break;
 
                         /* We're good to go -- emit the instruction */




More information about the mesa-commit mailing list