[llvm-commits] [polly] r130752 - in /polly/trunk: include/polly/Dependences.h lib/Analysis/Dependences.cpp lib/CodeGeneration.cpp

Hongbin Zheng etherzhhb at gmail.com
Tue May 3 06:46:59 PDT 2011


Author: ether
Date: Tue May  3 08:46:58 2011
New Revision: 130752

URL: http://llvm.org/viewvc/llvm-project?rev=130752&view=rev
Log:
Refactor: Move 'isParallelFor' from codegen backend to Dependences analysis, so other passes can also use it.

Modified:
    polly/trunk/include/polly/Dependences.h
    polly/trunk/lib/Analysis/Dependences.cpp
    polly/trunk/lib/CodeGeneration.cpp

Modified: polly/trunk/include/polly/Dependences.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/Dependences.h?rev=130752&r1=130751&r2=130752&view=diff
==============================================================================
--- polly/trunk/include/polly/Dependences.h (original)
+++ polly/trunk/include/polly/Dependences.h Tue May  3 08:46:58 2011
@@ -31,6 +31,7 @@
 struct isl_union_set;
 struct isl_map;
 struct isl_set;
+struct clast_for;
 
 using namespace llvm;
 
@@ -69,6 +70,16 @@
     ///              valid for the scattering domain subset given.
     bool isParallelDimension(isl_set *loopDomain, unsigned parallelDimension);
 
+    /// @brief Check if a loop is parallel
+    ///
+    /// Detect if a clast_for loop can be executed in parallel.
+    ///
+    /// @param f The clast for loop to check.
+    ///
+    /// @return bool Returns true if the incoming clast_for statement can
+    ///              execute in parallel.
+    bool isParallelFor(const clast_for *f);
+
     bool runOnScop(Scop &S);
     void printScop(raw_ostream &OS) const;
     virtual void releaseMemory();

Modified: polly/trunk/lib/Analysis/Dependences.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/Dependences.cpp?rev=130752&r1=130751&r2=130752&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/Dependences.cpp (original)
+++ polly/trunk/lib/Analysis/Dependences.cpp Tue May  3 08:46:58 2011
@@ -31,8 +31,9 @@
 #include "llvm/Support/CommandLine.h"
 
 #include <isl/flow.h>
-#include <isl/map.h>
-#include <isl/constraint.h>
+#define CLOOG_INT_GMP 1
+#include <cloog/cloog.h>
+#include <cloog/isl/cloog.h>
 
 using namespace polly;
 using namespace llvm;
@@ -351,6 +352,13 @@
     && isl_union_set_is_empty(nonValid_waw);
 }
 
+bool Dependences::isParallelFor(const clast_for *f) {
+  isl_set *loopDomain = isl_set_from_cloog_domain(f->domain);
+  assert(loopDomain && "Cannot access domain of loop");
+
+  return isParallelDimension(loopDomain, isl_set_n_dim(loopDomain));
+}
+
 void Dependences::printScop(raw_ostream &OS) const {
   OS.indent(4) << "Must dependences:\n";
   OS.indent(8) << stringFromIslObj(must_dep) << "\n";

Modified: polly/trunk/lib/CodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGeneration.cpp?rev=130752&r1=130751&r2=130752&view=diff
==============================================================================
--- polly/trunk/lib/CodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGeneration.cpp Tue May  3 08:46:58 2011
@@ -826,25 +826,6 @@
     Builder.SetInsertPoint(AfterBB);
   }
 
-  /// @brief Check if a loop is parallel
-  ///
-  /// Detect if a clast_for loop can be executed in parallel.
-  ///
-  /// @param f The clast for loop to check.
-  bool isParallelFor(const clast_for *f) {
-    isl_set *loopDomain = isl_set_from_cloog_domain(f->domain);
-    assert(loopDomain && "Cannot access domain of loop");
-
-    bool isParallel = DP->isParallelDimension(loopDomain,
-                                              isl_set_n_dim(loopDomain));
-
-    if (isParallel)
-      DEBUG(dbgs() << "Parallel loop with induction variable '" << f->iterator
-            << "' found\n";);
-
-    return isParallel;
-  }
-
   /// @brief Add a new definition of an openmp subfunction.
   Function* addOpenMPSubfunction(Module *M) {
     Function *F = Builder.GetInsertBlock()->getParent();
@@ -1157,11 +1138,11 @@
   }
 
   void codegen(const clast_for *f) {
-    if (Vector && isInnermostLoop(f) && isParallelFor(f)
+    if (Vector && isInnermostLoop(f) && DP->isParallelFor(f)
         && (-1 != getNumberOfIterations(f))
         && (getNumberOfIterations(f) <= 16)) {
       codegenForVector(f);
-    } else if (OpenMP && !parallelCodeGeneration && isParallelFor(f)) {
+    } else if (OpenMP && !parallelCodeGeneration && DP->isParallelFor(f)) {
       parallelCodeGeneration = true;
       parallelLoops.push_back(f->iterator);
       codegenForOpenMP(f);





More information about the llvm-commits mailing list