[llvm-commits] [polly] r146033 - in /polly/trunk: lib/Cloog.cpp test/CMakeLists.txt test/Cloog/ test/Cloog/ambigous_schedule.ll test/Cloog/ambigous_schedule___%for.cond---%for.end30.jscop

Tobias Grosser grosser at fim.uni-passau.de
Wed Dec 7 03:03:49 PST 2011


Author: grosser
Date: Wed Dec  7 05:03:48 2011
New Revision: 146033

URL: http://llvm.org/viewvc/llvm-project?rev=146033&view=rev
Log:
ClooG: Make sure ambigous schedules do not introduce complicated code

Cloog continued to split the domains even after the scattering. This lead to
complicated code.

Added:
    polly/trunk/test/Cloog/
    polly/trunk/test/Cloog/ambigous_schedule.ll
    polly/trunk/test/Cloog/ambigous_schedule___%for.cond---%for.end30.jscop
Modified:
    polly/trunk/lib/Cloog.cpp
    polly/trunk/test/CMakeLists.txt

Modified: polly/trunk/lib/Cloog.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Cloog.cpp?rev=146033&r1=146032&r2=146033&view=diff
==============================================================================
--- polly/trunk/lib/Cloog.cpp (original)
+++ polly/trunk/lib/Cloog.cpp Wed Dec  7 05:03:48 2011
@@ -152,6 +152,15 @@
   Options->strides = 1;
   Options->save_domains = 1;
   Options->noscalars = 1;
+
+  // The last loop depth to optimize should be the last scattering dimension.
+  // CLooG by default will continue to split the loops even after the last
+  // scattering dimension. This splitting is problematic for the schedules
+  // calculated by the PoCC/isl/Pluto optimizer. Such schedules contain may
+  // not be fully defined, but statements without dependences may be mapped
+  // to the same exeuction time. For such schedules, continuing to split
+  // may lead to a larger set of if-conditions in the innermost loop.
+  Options->l = 0;
 }
 
 CloogUnionDomain *Cloog::buildCloogUnionDomain() {

Modified: polly/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/CMakeLists.txt?rev=146033&r1=146032&r2=146033&view=diff
==============================================================================
--- polly/trunk/test/CMakeLists.txt (original)
+++ polly/trunk/test/CMakeLists.txt Wed Dec  7 05:03:48 2011
@@ -3,6 +3,7 @@
   "ScopInfo"
   "ScheduleOptimizer"
   "CodeGen"
+  "Cloog"
   "OpenMP"
   "polybench"
   "vect")

Added: polly/trunk/test/Cloog/ambigous_schedule.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Cloog/ambigous_schedule.ll?rev=146033&view=auto
==============================================================================
--- polly/trunk/test/Cloog/ambigous_schedule.ll (added)
+++ polly/trunk/test/Cloog/ambigous_schedule.ll Wed Dec  7 05:03:48 2011
@@ -0,0 +1,118 @@
+; RUN: opt %loadPolly %defaultOpts -polly-import-jscop-dir=`dirname %s` -polly-import-jscop -polly-cloog -analyze %s | FileCheck %s
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+ at A = common global [100 x [100 x double]] zeroinitializer, align 16
+ at B = common global [100 x [100 x double]] zeroinitializer, align 16
+
+define void @ambigous_schedule() nounwind uwtable {
+entry:
+  br label %for.cond
+
+for.cond:                                         ; preds = %for.inc6, %entry
+  %i.0 = phi i32 [ 0, %entry ], [ %inc7, %for.inc6 ]
+  %cmp = icmp slt i32 %i.0, 100
+  br i1 %cmp, label %for.body, label %for.end8
+
+for.body:                                         ; preds = %for.cond
+  br label %for.cond1
+
+for.cond1:                                        ; preds = %for.inc, %for.body
+  %j.0 = phi i32 [ 0, %for.body ], [ %inc, %for.inc ]
+  %cmp2 = icmp slt i32 %j.0, 100
+  br i1 %cmp2, label %for.body3, label %for.end
+
+for.body3:                                        ; preds = %for.cond1
+  %add = add nsw i32 %i.0, %j.0
+  %conv = sitofp i32 %add to double
+  %idxprom = sext i32 %j.0 to i64
+  %idxprom4 = sext i32 %i.0 to i64
+  %arrayidx = getelementptr inbounds [100 x [100 x double]]* @A, i32 0, i64 %idxprom4
+  %arrayidx5 = getelementptr inbounds [100 x double]* %arrayidx, i32 0, i64 %idxprom
+  store double %conv, double* %arrayidx5, align 8
+  br label %for.inc
+
+for.inc:                                          ; preds = %for.body3
+  %inc = add nsw i32 %j.0, 1
+  br label %for.cond1
+
+for.end:                                          ; preds = %for.cond1
+  br label %for.inc6
+
+for.inc6:                                         ; preds = %for.end
+  %inc7 = add nsw i32 %i.0, 1
+  br label %for.cond
+
+for.end8:                                         ; preds = %for.cond
+  br label %for.cond10
+
+for.cond10:                                       ; preds = %for.inc28, %for.end8
+  %i9.0 = phi i32 [ 0, %for.end8 ], [ %inc29, %for.inc28 ]
+  %cmp11 = icmp slt i32 %i9.0, 100
+  br i1 %cmp11, label %for.body13, label %for.end30
+
+for.body13:                                       ; preds = %for.cond10
+  br label %for.cond15
+
+for.cond15:                                       ; preds = %for.inc25, %for.body13
+  %j14.0 = phi i32 [ 0, %for.body13 ], [ %inc26, %for.inc25 ]
+  %cmp16 = icmp slt i32 %j14.0, 100
+  br i1 %cmp16, label %for.body18, label %for.end27
+
+for.body18:                                       ; preds = %for.cond15
+  %add19 = add nsw i32 %i9.0, %j14.0
+  %conv20 = sitofp i32 %add19 to double
+  %idxprom21 = sext i32 %j14.0 to i64
+  %idxprom22 = sext i32 %i9.0 to i64
+  %arrayidx23 = getelementptr inbounds [100 x [100 x double]]* @B, i32 0, i64 %idxprom22
+  %arrayidx24 = getelementptr inbounds [100 x double]* %arrayidx23, i32 0, i64 %idxprom21
+  store double %conv20, double* %arrayidx24, align 8
+  br label %for.inc25
+
+for.inc25:                                        ; preds = %for.body18
+  %inc26 = add nsw i32 %j14.0, 1
+  br label %for.cond15
+
+for.end27:                                        ; preds = %for.cond15
+  br label %for.inc28
+
+for.inc28:                                        ; preds = %for.end27
+  %inc29 = add nsw i32 %i9.0, 1
+  br label %for.cond10
+
+for.end30:                                        ; preds = %for.cond10
+  ret void
+}
+
+; CHECK: for (c2=0;c2<=99;c2++) {
+; CHECK:   for (c3=0;c3<=99;c3++) {
+; CHECK:     Stmt_for_body3(c2,c3);
+; CHECK:     Stmt_for_body18(c3,c2);
+; CHECK:   }
+; CHECK: }
+
+; This check makes sure CLooG stops splitting for ambigious schedules as
+; they may be generated by the isl/PoCC/Pluto schedule optimizers.
+;
+; Previously we created such code:
+;
+; for (c2=0;c2<=99;c2++) {
+;   for (c3=0;c3<=99;c3++) {
+;     if (c2 == c3) {
+;       Stmt_for_body3(c2,c2);
+;       Stmt_for_body18(c2,c2);
+;     }
+;     if (c2 <= c3-1) {
+;       Stmt_for_body3(c2,c3);
+;     }
+;     if (c2 <= c3-1) {
+;       Stmt_for_body18(c3,c2);
+;     }
+;     if (c2 >= c3+1) {
+;       Stmt_for_body18(c3,c2);
+;     }
+;     if (c2 >= c3+1) {
+;       Stmt_for_body3(c2,c3);
+;     }
+;   }
+; }

Added: polly/trunk/test/Cloog/ambigous_schedule___%for.cond---%for.end30.jscop
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Cloog/ambigous_schedule___%25for.cond---%25for.end30.jscop?rev=146033&view=auto
==============================================================================
--- polly/trunk/test/Cloog/ambigous_schedule___%for.cond---%for.end30.jscop (added)
+++ polly/trunk/test/Cloog/ambigous_schedule___%for.cond---%for.end30.jscop Wed Dec  7 05:03:48 2011
@@ -0,0 +1,28 @@
+{
+   "context" : "{  :  }",
+   "name" : "for.cond => for.end30",
+   "statements" : [
+      {
+         "accesses" : [
+            {
+               "kind" : "write",
+               "relation" : "{ Stmt_for_body3[i0, i1] -> MemRef_A[100i0 + i1] }"
+            }
+         ],
+         "domain" : "{ Stmt_for_body3[i0, i1] : i0 >= 0 and i0 <= 99 and i1 >= 0 and i1 <= 99 }",
+         "name" : "Stmt_for_body3",
+         "schedule" : "{ Stmt_for_body3[i0, i1] -> scattering[0, i0, i1, 0] }"
+      },
+      {
+         "accesses" : [
+            {
+               "kind" : "write",
+               "relation" : "{ Stmt_for_body18[i0, i1] -> MemRef_B[100i0 + i1] }"
+            }
+         ],
+         "domain" : "{ Stmt_for_body18[i0, i1] : i0 >= 0 and i0 <= 99 and i1 >= 0 and i1 <= 99 }",
+         "name" : "Stmt_for_body18",
+         "schedule" : "{ Stmt_for_body18[i0, i1] -> scattering[0, i1, i0, 0] }"
+      }
+   ]
+}





More information about the llvm-commits mailing list