[polly] r245563 - Add support for two-level tiling

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 20 06:45:02 PDT 2015


Author: grosser
Date: Thu Aug 20 08:45:02 2015
New Revision: 245563

URL: http://llvm.org/viewvc/llvm-project?rev=245563&view=rev
Log:
Add support for two-level tiling

By default we only use one level of tiling for loops, but in general tiling
for multiple levels is trivial for us. Hence, we add a set of options that
allow people to play with a second level of tiling. If this is profitable for
some cases we can work on heuristics that allow us to identify these cases
and use two-level tiling for them.

Modified:
    polly/trunk/lib/Transform/ScheduleOptimizer.cpp
    polly/trunk/test/ScheduleOptimizer/rectangular-tiling.ll

Modified: polly/trunk/lib/Transform/ScheduleOptimizer.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Transform/ScheduleOptimizer.cpp?rev=245563&r1=245562&r2=245563&view=diff
==============================================================================
--- polly/trunk/lib/Transform/ScheduleOptimizer.cpp (original)
+++ polly/trunk/lib/Transform/ScheduleOptimizer.cpp Thu Aug 20 08:45:02 2015
@@ -71,11 +71,6 @@ using namespace polly;
 
 #define DEBUG_TYPE "polly-opt-isl"
 
-static cl::opt<bool> EnableTiling("polly-tiling",
-                                  cl::desc("Enable loop tiling"),
-                                  cl::init(true), cl::ZeroOrMore,
-                                  cl::cat(PollyCategory));
-
 static cl::opt<std::string>
     OptimizeDeps("polly-opt-optimize-only",
                  cl::desc("Only a certain kind of dependences (all/raw)"),
@@ -113,18 +108,40 @@ static cl::opt<int> PrevectorWidth(
         "The number of loop iterations to strip-mine for pre-vectorization"),
     cl::Hidden, cl::init(4), cl::ZeroOrMore, cl::cat(PollyCategory));
 
-static cl::opt<int> DefaultTileSize(
+static cl::opt<bool> FirstLevelTiling("polly-tiling",
+                                      cl::desc("Enable loop tiling"),
+                                      cl::init(true), cl::ZeroOrMore,
+                                      cl::cat(PollyCategory));
+
+static cl::opt<int> FirstLevelDefaultTileSize(
     "polly-default-tile-size",
     cl::desc("The default tile size (if not enough were provided by"
              " --polly-tile-sizes)"),
     cl::Hidden, cl::init(32), cl::ZeroOrMore, cl::cat(PollyCategory));
 
-static cl::list<int> TileSizes("polly-tile-sizes",
-                               cl::desc("A tile size"
-                                        " for each loop dimension, filled with"
-                                        " --polly-default-tile-size"),
-                               cl::Hidden, cl::ZeroOrMore, cl::CommaSeparated,
-                               cl::cat(PollyCategory));
+static cl::list<int> FirstLevelTileSizes(
+    "polly-tile-sizes", cl::desc("A tile size for each loop dimension, filled "
+                                 "with --polly-default-tile-size"),
+    cl::Hidden, cl::ZeroOrMore, cl::CommaSeparated, cl::cat(PollyCategory));
+
+static cl::opt<bool>
+    SecondLevelTiling("polly-2nd-level-tiling",
+                      cl::desc("Enable a 2nd level loop of loop tiling"),
+                      cl::init(false), cl::ZeroOrMore, cl::cat(PollyCategory));
+
+static cl::opt<int> SecondLevelDefaultTileSize(
+    "polly-2nd-level-default-tile-size",
+    cl::desc("The default 2nd-level tile size (if not enough were provided by"
+             " --polly-2nd-level-tile-sizes)"),
+    cl::Hidden, cl::init(16), cl::ZeroOrMore, cl::cat(PollyCategory));
+
+static cl::list<int>
+    SecondLevelTileSizes("polly-2nd-level-tile-sizes",
+                         cl::desc("A tile size for each loop dimension, filled "
+                                  "with --polly-default-tile-size"),
+                         cl::Hidden, cl::ZeroOrMore, cl::CommaSeparated,
+                         cl::cat(PollyCategory));
+
 namespace {
 
 class IslScheduleOptimizer : public ScopPass {
@@ -325,8 +342,11 @@ IslScheduleOptimizer::optimizeBand(__isl
   if (!isTileableBandNode(Node))
     return Node;
 
-  if (EnableTiling)
-    Node = tileNode(Node, TileSizes, DefaultTileSize);
+  if (FirstLevelTiling)
+    Node = tileNode(Node, FirstLevelTileSizes, FirstLevelDefaultTileSize);
+
+  if (SecondLevelTiling)
+    Node = tileNode(Node, SecondLevelTileSizes, SecondLevelDefaultTileSize);
 
   if (PollyVectorizerChoice == VECTORIZER_NONE)
     return Node;

Modified: polly/trunk/test/ScheduleOptimizer/rectangular-tiling.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScheduleOptimizer/rectangular-tiling.ll?rev=245563&r1=245562&r2=245563&view=diff
==============================================================================
--- polly/trunk/test/ScheduleOptimizer/rectangular-tiling.ll (original)
+++ polly/trunk/test/ScheduleOptimizer/rectangular-tiling.ll Thu Aug 20 08:45:02 2015
@@ -1,6 +1,12 @@
 ; RUN: opt %loadPolly -polly-detect-unprofitable -polly-opt-isl -analyze -polly-ast -polly-tile-sizes=256,16 < %s | FileCheck %s
 ; RUN: opt %loadPolly -polly-detect-unprofitable -polly-opt-isl -analyze -polly-tiling=false -polly-ast -polly-tile-sizes=256,16 -polly-no-early-exit < %s | FileCheck %s --check-prefix=NOTILING
 
+; RUN: opt %loadPolly -polly-detect-unprofitable -polly-opt-isl -analyze \
+; RUN:                -polly-2nd-level-tiling -polly-ast \
+; RUN:                -polly-tile-sizes=256,16 -polly-no-early-exit \
+; RUN:                -polly-2nd-level-tile-sizes=16,8 < %s | \
+; RUN: FileCheck %s --check-prefix=TWOLEVEL
+
 ; CHECK: for (int c0 = 0; c0 <= 3; c0 += 1)
 ; CHECK:   for (int c1 = 0; c1 <= 31; c1 += 1)
 ; CHECK:     for (int c2 = 0; c2 <= 255; c2 += 1)
@@ -11,6 +17,16 @@
 ; NOTILING:   for (int c1 = 0; c1 <= 511; c1 += 1)
 ; NOTILING:     Stmt_for_body3(c0, c1);
 
+
+; TWOLEVEL: for (int c0 = 0; c0 <= 3; c0 += 1)
+; TWOLEVEL:   for (int c1 = 0; c1 <= 31; c1 += 1)
+; TWOLEVEL:     for (int c2 = 0; c2 <= 15; c2 += 1)
+; TWOLEVEL:       for (int c3 = 0; c3 <= 1; c3 += 1)
+; TWOLEVEL:         for (int c4 = 0; c4 <= 15; c4 += 1)
+; TWOLEVEL:           for (int c5 = 0; c5 <= 7; c5 += 1)
+; TWOLEVEL:             Stmt_for_body3(256 * c0 + 16 * c2 + c4, 16 * c1 + 8 * c3 + c5);
+
+
 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S64"
 
 ; Function Attrs: nounwind




More information about the llvm-commits mailing list