Unify the optimizer selection.
authorTobias Grosser <grosser@fim.uni-passau.de>
Tue, 24 Apr 2012 16:12:30 +0000 (16:12 +0000)
committerTobias Grosser <grosser@fim.uni-passau.de>
Tue, 24 Apr 2012 16:12:30 +0000 (16:12 +0000)
We now support -polly-optimizer=isl, -polly-optimizer=pocc and
-polly-optimizer=none. The option -polly-no-optimizer is gone.

llvm-svn: 155445

polly/include/polly/RegisterPasses.h
polly/lib/RegisterPasses.cpp
polly/www/example_load_Polly_into_clang.html

index a0ce12bb72f3fec53af677e4766f2b36c1b5ddeb..8f76242ab6bd907c6455ae0fb19897e5efec754a 100644 (file)
@@ -23,5 +23,4 @@ void registerPollyPreoptPasses(llvm::PassManagerBase &PM);
 
 // Register the Polly optimizer (including its preoptimizations).
 void registerPollyPasses(llvm::PassManagerBase &PM,
-                         bool DisableScheduler = false,
                          bool DisableCodegen = false);
index eb27138ec6941c95e5d9fc329bdebea48e61f265..6161768be39b55693af4896653a12cafd743ad84 100644 (file)
@@ -37,18 +37,30 @@ PollyEnabled("polly", cl::desc("Enable the default passes of Polly in -O3"),
              cl::init(false), cl::ZeroOrMore);
 
 static cl::opt<bool>
-DisableScheduler("polly-no-optimizer",
-                 cl::desc("Disable Polly Scheduling Optimizer"), cl::Hidden,
-                 cl::init(false), cl::ZeroOrMore);
-static cl::opt<bool>
 DisableCodegen("polly-no-codegen",
        cl::desc("Disable Polly Code Generation"), cl::Hidden,
        cl::init(false), cl::ZeroOrMore);
-static cl::opt<std::string>
+
+enum OptimizerChoice {
+  OPTIMIZER_NONE,
+#ifdef SCOPLIB_FOUND
+  OPTIMIZER_POCC,
+#endif
+  OPTIMIZER_ISL
+};
+
+static cl::opt<OptimizerChoice>
 Optimizer("polly-optimizer",
-          cl::desc("Select the scheduling optimizer. "
-                   "Either isl (default) or pocc."),
-          cl::Hidden, cl::init("isl"));
+          cl::desc("Select the scheduling optimizer"),
+          cl::values(
+            clEnumValN(OPTIMIZER_NONE, "none", "No optimizer"),
+#ifdef SCOPLIB_FOUND
+            clEnumValN(OPTIMIZER_POCC, "pocc", "The PoCC scheduling optimizer"),
+#endif
+            clEnumValN(OPTIMIZER_ISL, "isl", "The isl scheduling optimizer"),
+            clEnumValEnd),
+          cl::Hidden, cl::init(OPTIMIZER_ISL), cl::ZeroOrMore);
+
 static cl::opt<bool>
 ImportJScop("polly-run-import-jscop",
             cl::desc("Export the JScop description of the detected Scops"),
@@ -161,9 +173,7 @@ void registerPollyPreoptPasses(llvm::PassManagerBase &PM) {
   PM.add(polly::createRegionSimplifyPass());
 }
 
-void registerPollyPasses(llvm::PassManagerBase &PM, bool DisableScheduler,
-                         bool DisableCodegen) {
-  bool RunScheduler = !DisableScheduler;
+void registerPollyPasses(llvm::PassManagerBase &PM, bool DisableCodegen) {
   bool RunCodegen = !DisableCodegen;
 
   registerPollyPreoptPasses(PM);
@@ -185,23 +195,19 @@ void registerPollyPasses(llvm::PassManagerBase &PM, bool DisableScheduler,
   if (DeadCodeElim)
     PM.add(polly::createDeadCodeElimPass());
 
-  if (RunScheduler) {
-    if (Optimizer == "pocc") {
+  switch (Optimizer) {
+  case OPTIMIZER_NONE:
+    break; /* Do nothing */
+
 #ifdef SCOPLIB_FOUND
-      PM.add(polly::createPoccPass());
-#else
-      errs() << "Polly is compiled without scoplib support. As scoplib is "
-                "required to run PoCC, PoCC is also not available. Falling "
-                "back to the isl optimizer.\n";
-      PM.add(polly::createIslScheduleOptimizerPass());
+  case OPTIMIZER_POCC
+    PM.add(polly::createPoccPass());
+    break;
 #endif
-    } else if (Optimizer == "isl") {
-      PM.add(polly::createIslScheduleOptimizerPass());
-    } else {
-      errs() << "Invalid optimizer. Only 'isl' and 'pocc' allowed. "
-                "Falling back to 'isl'.\n";
-      PM.add(polly::createIslScheduleOptimizerPass());
-    }
+
+  case OPTIMIZER_ISL:
+    PM.add(polly::createIslScheduleOptimizerPass());
+    break;
   }
 
   if (ExportJScop)
@@ -219,7 +225,7 @@ void registerPollyPasses(llvm::PassManagerBase &PM, bool DisableScheduler,
 
 static
 void registerPollyEarlyAsPossiblePasses(const llvm::PassManagerBuilder &Builder,
-                                               llvm::PassManagerBase &PM) {
+                                        llvm::PassManagerBase &PM) {
 
   if (Builder.OptLevel == 0)
     return;
@@ -233,10 +239,6 @@ void registerPollyEarlyAsPossiblePasses(const llvm::PassManagerBuilder &Builder,
       errs() << "The option -polly-no-codegen has no effect. "
                 "Polly was not enabled\n";
 
-    if (DisableScheduler)
-      errs() << "The option -polly-no-optimizer has no effect. "
-                "Polly was not enabled\n";
-
     return;
   }
 
@@ -246,7 +248,7 @@ void registerPollyEarlyAsPossiblePasses(const llvm::PassManagerBuilder &Builder,
     return;
   }
 
-  registerPollyPasses(PM, DisableScheduler, DisableCodegen);
+  registerPollyPasses(PM, DisableCodegen);
 }
 
 static void registerPollyOptLevel0Passes(const llvm::PassManagerBuilder &,
index a148fafcbedb5d64cb7a90cdb3d4f335b9decf11..6e9bc50f502eb77f45a79f3fbe60e84a9875e371 100644 (file)
@@ -96,18 +96,16 @@ function a dot file that highlights the detected SCoPs. If 'only' is appended at
 the end of the option, the basic blocks are shown without the statements the
 contain.
 
-<h3>Disable the polyhedral optimizer</h3>
-
-Polly automatically runs by default a polyhedral optimizer to optimize the
-schedules. <b>-polly-no-optimizer</b> disables this optimizer.
-
-<h3>Change the Polly optimizer</h3>
-Polly uses by default the isl scheduling optimizer, a new implementation of the
-well known Pluto algorithm. The main reason for the isl scheduler being the
-default is that it does not require any additional libraries or tools to be
-installed. As the new scheduler may still have some bugs and because being
-able to compare is good in general, it is possible to switch the used optimizer
-back to PoCC. For this add the option <b>-polly-optimizer=pocc</b>.
+<h3>Change/Disable the Optimizer</h3>
+Polly uses by default the isl scheduling optimizer. The isl optimizer optimizes
+for data-locality and parallelism using the <a
+href=http://pluto-compiler.sf.net">Pluto</a> algorithm. For research it is also
+possible to run <a
+href="http://www-rocq.inria.fr/~pouchet/software/pocc/">PoCC</a> as external
+optimizer. PoCC provides access to the original Pluto implementation. To use
+PoCC add <b>-polly-optimizer=pocc</b> to the command line (only available if
+Polly was compiled with scoplib support). To disable the
+optimizer entirely use the option <b>-polly-optimizer=none</b>.
 
 <h3>Disable tiling in the optimizer</h3>
 By default both optimizers perform tiling, if possible. In case this is not