[Beignet] [PATCH] Refine custom unrolling policy.

Zhigang Gong zhigang.gong at linux.intel.com
Fri Mar 4 06:53:05 UTC 2016


We should use the production of current trip count and parent trip
count to determine whether we should unroll the parent loop.

Signed-off-by: Zhigang Gong <zhigang.gong at linux.intel.com>
---
 backend/src/llvm/llvm_unroll.cpp | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/backend/src/llvm/llvm_unroll.cpp b/backend/src/llvm/llvm_unroll.cpp
index 0f62bdc..a289c11 100644
--- a/backend/src/llvm/llvm_unroll.cpp
+++ b/backend/src/llvm/llvm_unroll.cpp
@@ -176,6 +176,12 @@ namespace gbe {
         if (ExitBlock)
           currTripCount = SE->getSmallConstantTripCount(L, ExitBlock);
 
+        if (currTripCount > 32) {
+          shouldUnroll = false;
+          setUnrollID(currL, false);
+          return shouldUnroll;
+        }
+
         while(currL) {
           Loop *parentL = currL->getParentLoop();
           unsigned parentTripCount = 0;
@@ -187,20 +193,17 @@ namespace gbe {
             if (parentExitBlock)
               parentTripCount = SE->getSmallConstantTripCount(parentL, parentExitBlock);
           }
-          if ((parentTripCount != 0 && currTripCount / parentTripCount > 16) ||
-              (currTripCount > 32)) {
-            if (currL == L)
-              shouldUnroll = false;
-            setUnrollID(currL, false);
-            if (currL != L)
+          if (parentTripCount != 0 && currTripCount * parentTripCount > 32) {
+            setUnrollID(parentL, false);
 #if LLVM_VERSION_MAJOR == 3 &&  LLVM_VERSION_MINOR >= 8
-              loopInfo.markAsRemoved(currL);
+            loopInfo.markAsRemoved(parentL);
 #else
-              LPM.deleteLoopFromQueue(currL);
+            LPM.deleteLoopFromQueue(parentL);
 #endif
+            return shouldUnroll;
           }
           currL = parentL;
-          currTripCount = parentTripCount;
+          currTripCount = parentTripCount * currTripCount;
         }
         return shouldUnroll;
       }
-- 
2.1.4



More information about the Beignet mailing list