[polly] r211795 - Use wrapped reduction dependences

Johannes Doerfert jdoerfert at codeaurora.org
Thu Jun 26 11:44:14 PDT 2014


Author: jdoerfert
Date: Thu Jun 26 13:44:14 2014
New Revision: 211795

URL: http://llvm.org/viewvc/llvm-project?rev=211795&view=rev
Log:
Use wrapped reduction dependences

  This change will ease the transision to multiple reductions per statement as
  we can now distinguish the effects of multiple reductions in the same
  statement.

  + Wrapped reduction dependences are used to compute privatization dependences
  + Modified test cases to account for the change


Modified:
    polly/trunk/lib/Analysis/Dependences.cpp
    polly/trunk/test/Dependences/reduction_multiple_reductions.ll
    polly/trunk/test/Dependences/reduction_privatization_deps.ll
    polly/trunk/test/Dependences/reduction_simple_iv_debug_wrapped_dependences.ll

Modified: polly/trunk/lib/Analysis/Dependences.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/Dependences.cpp?rev=211795&r1=211794&r2=211795&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/Dependences.cpp (original)
+++ polly/trunk/lib/Analysis/Dependences.cpp Thu Jun 26 13:44:14 2014
@@ -284,22 +284,6 @@ void Dependences::calculateDependences(S
                                             isl_union_map_domain(StmtSchedule));
   DEBUG(dbgs() << "Wrapped Dependences:\n"; printScop(dbgs()); dbgs() << "\n");
 
-  RAW = isl_union_map_zip(RAW);
-  WAW = isl_union_map_zip(WAW);
-  WAR = isl_union_map_zip(WAR);
-
-  DEBUG(dbgs() << "Zipped Dependences:\n"; printScop(dbgs()); dbgs() << "\n");
-
-  RAW = isl_union_map_union(isl_union_set_unwrap(isl_union_map_domain(RAW)),
-                            STMT_RAW);
-  WAW = isl_union_map_union(isl_union_set_unwrap(isl_union_map_domain(WAW)),
-                            STMT_WAW);
-  WAR = isl_union_map_union(isl_union_set_unwrap(isl_union_map_domain(WAR)),
-                            STMT_WAR);
-
-  DEBUG(dbgs() << "Unwrapped Dependences:\n"; printScop(dbgs());
-        dbgs() << "\n");
-
   // To handle reduction dependences we proceed as follows:
   // 1) Aggregate all possible reduction dependences, namely all self
   //    dependences on reduction like statements.
@@ -320,9 +304,9 @@ void Dependences::calculateDependences(S
     for (MemoryAccess *MA : *Stmt) {
       if (!MA->isReductionLike())
         continue;
-      isl_set *AccDom = isl_map_domain(MA->getAccessRelation());
+      isl_set *AccDomW = isl_map_wrap(MA->getAccessRelation());
       isl_map *Identity =
-          isl_map_from_domain_and_range(isl_set_copy(AccDom), AccDom);
+          isl_map_from_domain_and_range(isl_set_copy(AccDomW), AccDomW);
       RED = isl_union_map_add_map(RED, Identity);
       break;
     }
@@ -342,6 +326,28 @@ void Dependences::calculateDependences(S
     addPrivatizationDependences();
   }
 
+  DEBUG(dbgs() << "Final Wrapped Dependences:\n"; printScop(dbgs());
+        dbgs() << "\n");
+
+  RAW = isl_union_map_zip(RAW);
+  WAW = isl_union_map_zip(WAW);
+  WAR = isl_union_map_zip(WAR);
+  RED = isl_union_map_zip(RED);
+
+  DEBUG(dbgs() << "Zipped Dependences:\n"; printScop(dbgs()); dbgs() << "\n");
+
+  RAW = isl_union_set_unwrap(isl_union_map_domain(RAW));
+  WAW = isl_union_set_unwrap(isl_union_map_domain(WAW));
+  WAR = isl_union_set_unwrap(isl_union_map_domain(WAR));
+  RED = isl_union_set_unwrap(isl_union_map_domain(RED));
+
+  DEBUG(dbgs() << "Unwrapped Dependences:\n"; printScop(dbgs());
+        dbgs() << "\n");
+
+  RAW = isl_union_map_union(RAW, STMT_RAW);
+  WAW = isl_union_map_union(WAW, STMT_WAW);
+  WAR = isl_union_map_union(WAR, STMT_WAR);
+
   RAW = isl_union_map_coalesce(RAW);
   WAW = isl_union_map_coalesce(WAW);
   WAR = isl_union_map_coalesce(WAR);

Modified: polly/trunk/test/Dependences/reduction_multiple_reductions.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Dependences/reduction_multiple_reductions.ll?rev=211795&r1=211794&r2=211795&view=diff
==============================================================================
--- polly/trunk/test/Dependences/reduction_multiple_reductions.ll (original)
+++ polly/trunk/test/Dependences/reduction_multiple_reductions.ll Thu Jun 26 13:44:14 2014
@@ -9,7 +9,8 @@
 ; CHECK: WAW dependences:
 ; CHECK:   {  }
 ; CHECK: Reduction dependences:
-; CHECK:   { Stmt_if_then[i0] -> Stmt_if_then[1 + i0] : i0 <= 510 and i0 >= 0; Stmt_if_else[i0] -> Stmt_if_else[1 + i0] : i0 <= 1022 and i0 >= 512 }
+; CHECK-DAG: Stmt_if_then[i0] -> Stmt_if_then[1 + i0] : i0 <= 510 and i0 >= 0
+; CHECK-DAG: Stmt_if_else[i0] -> Stmt_if_else[1 + i0] : i0 <= 1022 and i0 >= 512
 ;
 ; void f(int *restrict sum, int *restrict prod) {
 ;   for (int i = 0; i < 1024; i++)

Modified: polly/trunk/test/Dependences/reduction_privatization_deps.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Dependences/reduction_privatization_deps.ll?rev=211795&r1=211794&r2=211795&view=diff
==============================================================================
--- polly/trunk/test/Dependences/reduction_privatization_deps.ll (original)
+++ polly/trunk/test/Dependences/reduction_privatization_deps.ll Thu Jun 26 13:44:14 2014
@@ -24,7 +24,6 @@
 ;      for (int i = 0; i < 1024; i++)
 ; S2:    sum[i] = sum[i + 1] * 3;
 ;    }
-;
 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S64"
 
 define void @f(i32* %sum)  {

Modified: polly/trunk/test/Dependences/reduction_simple_iv_debug_wrapped_dependences.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Dependences/reduction_simple_iv_debug_wrapped_dependences.ll?rev=211795&r1=211794&r2=211795&view=diff
==============================================================================
--- polly/trunk/test/Dependences/reduction_simple_iv_debug_wrapped_dependences.ll (original)
+++ polly/trunk/test/Dependences/reduction_simple_iv_debug_wrapped_dependences.ll Thu Jun 26 13:44:14 2014
@@ -6,32 +6,49 @@
 ; CHECK: Write: { [Stmt_for_cond[i0] -> MemRef_sum[0]] -> MemRef_sum[0] : i0 >= 0 and i0 <= 100 }
 ; CHECK: Schedule: { Stmt_for_cond[i0] -> scattering[0, i0, 0]; [Stmt_for_cond[i0] -> MemRef_sum[0]] -> scattering[0, i0, 0] : i0 <= 100 and i0 >= 0 }
 ; CHECK: Wrapped Dependences:
-; CHECK:         RAW dependences:
-; CHECK:                 { [Stmt_for_cond[i0] -> MemRef_sum[0]] -> [Stmt_for_cond[1 + i0] -> MemRef_sum[0]] : i0 >= 0 and i0 <= 99 }
-; CHECK:         WAR dependences:
-; CHECK:                 {  }
-; CHECK:         WAW dependences:
-; CHECK:                 { [Stmt_for_cond[i0] -> MemRef_sum[0]] -> [Stmt_for_cond[1 + i0] -> MemRef_sum[0]] : i0 >= 0 and i0 <= 99 }
-; CHECK:         Reduction dependences:
-; CHECK:                 n/a
+; CHECK: RAW dependences:
+; CHECK:   { [Stmt_for_cond[i0] -> MemRef_sum[0]] -> [Stmt_for_cond[1 + i0] -> MemRef_sum[0]] : i0 >= 0 and i0 <= 99 }
+; CHECK: WAR dependences:
+; CHECK:   {  }
+; CHECK: WAW dependences:
+; CHECK:   { [Stmt_for_cond[i0] -> MemRef_sum[0]] -> [Stmt_for_cond[1 + i0] -> MemRef_sum[0]] : i0 >= 0 and i0 <= 99 }
+; CHECK: Reduction dependences:
+; CHECK:   n/a
+; CHECK: Final Wrapped Dependences:
+; CHECK: RAW dependences:
+; CHECK:   {  }
+; CHECK: WAR dependences:
+; CHECK:   {  }
+; CHECK: WAW dependences:
+; CHECK:   {  }
+; CHECK: Reduction dependences:
+; CHECK:   { [Stmt_for_cond[i0] -> MemRef_sum[0]] -> [Stmt_for_cond[1 + i0] -> MemRef_sum[0]] : i0 <= 99 and i0 >= 0 }
 ; CHECK: Zipped Dependences:
-; CHECK:         RAW dependences:
-; CHECK:                 { [Stmt_for_cond[i0] -> Stmt_for_cond[1 + i0]] -> [MemRef_sum[0] -> MemRef_sum[0]] : i0 >= 0 and i0 <= 99 }
-; CHECK:         WAR dependences:
-; CHECK:                 {  }
-; CHECK:         WAW dependences:
-; CHECK:                 { [Stmt_for_cond[i0] -> Stmt_for_cond[1 + i0]] -> [MemRef_sum[0] -> MemRef_sum[0]] : i0 >= 0 and i0 <= 99 }
-; CHECK:         Reduction dependences:
-; CHECK:                 n/a
+; CHECK: RAW dependences:
+; CHECK:   {  }
+; CHECK: WAR dependences:
+; CHECK:   {  }
+; CHECK: WAW dependences:
+; CHECK:   {  }
+; CHECK: Reduction dependences:
+; CHECK:   { [Stmt_for_cond[i0] -> Stmt_for_cond[1 + i0]] -> [MemRef_sum[0] -> MemRef_sum[0]] : i0 <= 99 and i0 >= 0 }
 ; CHECK: Unwrapped Dependences:
-; CHECK:         RAW dependences:
-; CHECK:                 { Stmt_for_cond[i0] -> Stmt_for_cond[1 + i0] : i0 >= 0 and i0 <= 99 }
-; CHECK:         WAR dependences:
-; CHECK:                 {  }
-; CHECK:         WAW dependences:
-; CHECK:                 { Stmt_for_cond[i0] -> Stmt_for_cond[1 + i0] : i0 >= 0 and i0 <= 99 }
-; CHECK:         Reduction dependences:
-; CHECK:                 n/a
+; CHECK: RAW dependences:
+; CHECK:   {  }
+; CHECK: WAR dependences:
+; CHECK:   {  }
+; CHECK: WAW dependences:
+; CHECK:   {  }
+; CHECK: Reduction dependences:
+; CHECK:   { Stmt_for_cond[i0] -> Stmt_for_cond[1 + i0] : i0 <= 99 and i0 >= 0 }
+; CHECK: RAW dependences:
+; CHECK:   {  }
+; CHECK: WAR dependences:
+; CHECK:   {  }
+; CHECK: WAW dependences:
+; CHECK:   {  }
+; CHECK: Reduction dependences:
+; CHECK:   { Stmt_for_cond[i0] -> Stmt_for_cond[1 + i0] : i0 <= 99 and i0 >= 0 }
 ;
 ; void f(int* sum) {
 ;   for (int i = 0; i <= 100; i++)





More information about the llvm-commits mailing list