Enable multi-threading in the pass manager by default.
authorRiver Riddle <riverriddle@google.com>
Fri, 26 Apr 2019 18:38:50 +0000 (11:38 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Mon, 6 May 2019 15:17:58 +0000 (08:17 -0700)
--

PiperOrigin-RevId: 245458081

mlir/lib/Pass/Pass.cpp
mlir/test/Pass/ir-printing.mlir
mlir/test/Pass/pass-timing.mlir

index 346355b..da88130 100644 (file)
 using namespace mlir;
 using namespace mlir::detail;
 
-static llvm::cl::opt<bool> enableThreads(
-    "experimental-mt-pm",
-    llvm::cl::desc("Enable experimental multithreading in the pass manager"),
-    llvm::cl::init(false));
+static llvm::cl::opt<bool>
+    disableThreads("disable-pass-threading",
+                   llvm::cl::desc("Disable multithreading in the pass manager"),
+                   llvm::cl::init(false));
 
 //===----------------------------------------------------------------------===//
 // Pass
@@ -430,13 +430,13 @@ void PassManager::addPass(FunctionPassBase *pass) {
   detail::FunctionPassExecutor *fpe;
   if (nestedExecutorStack.empty()) {
     /// Create an executor adaptor for this pass.
-    if (enableThreads && llvm::llvm_is_multithreaded()) {
-      // If multi-threading is enabled, then create an asynchronous adaptor.
-      auto *adaptor = new ModuleToFunctionPassAdaptorParallel();
+    if (disableThreads || !llvm::llvm_is_multithreaded()) {
+      // If multi-threading is disabled, then create a synchronous adaptor.
+      auto *adaptor = new ModuleToFunctionPassAdaptor();
       addPass(adaptor);
       fpe = &adaptor->getFunctionExecutor();
     } else {
-      auto *adaptor = new ModuleToFunctionPassAdaptor();
+      auto *adaptor = new ModuleToFunctionPassAdaptorParallel();
       addPass(adaptor);
       fpe = &adaptor->getFunctionExecutor();
     }
index 12092d8..88644a6 100644 (file)
@@ -1,8 +1,8 @@
-// RUN: mlir-opt %s -cse -canonicalize -print-ir-before=cse  -o /dev/null 2>&1 | FileCheck -check-prefix=BEFORE %s
-// RUN: mlir-opt %s -cse -canonicalize -print-ir-before-all -o /dev/null 2>&1 | FileCheck -check-prefix=BEFORE_ALL %s
-// RUN: mlir-opt %s -cse -canonicalize -print-ir-after=cse -o /dev/null 2>&1 | FileCheck -check-prefix=AFTER %s
-// RUN: mlir-opt %s -cse -canonicalize -print-ir-after-all -o /dev/null 2>&1 | FileCheck -check-prefix=AFTER_ALL %s
-// RUN: mlir-opt %s -cse -canonicalize -print-ir-before=cse -print-ir-module-scope -o /dev/null 2>&1 | FileCheck -check-prefix=BEFORE_MODULE %s
+// RUN: mlir-opt %s -disable-pass-threading=true -cse -canonicalize -print-ir-before=cse  -o /dev/null 2>&1 | FileCheck -check-prefix=BEFORE %s
+// RUN: mlir-opt %s -disable-pass-threading=true -cse -canonicalize -print-ir-before-all -o /dev/null 2>&1 | FileCheck -check-prefix=BEFORE_ALL %s
+// RUN: mlir-opt %s -disable-pass-threading=true -cse -canonicalize -print-ir-after=cse -o /dev/null 2>&1 | FileCheck -check-prefix=AFTER %s
+// RUN: mlir-opt %s -disable-pass-threading=true -cse -canonicalize -print-ir-after-all -o /dev/null 2>&1 | FileCheck -check-prefix=AFTER_ALL %s
+// RUN: mlir-opt %s -disable-pass-threading=true -cse -canonicalize -print-ir-before=cse -print-ir-module-scope -o /dev/null 2>&1 | FileCheck -check-prefix=BEFORE_MODULE %s
 
 func @foo() {
   return
index 194aa68..15f6147 100644 (file)
@@ -1,7 +1,7 @@
-// RUN: mlir-opt %s -verify-each=true -cse -canonicalize -cse -pass-timing -pass-timing-display=list 2>&1 | FileCheck -check-prefix=LIST %s
-// RUN: mlir-opt %s -verify-each=true -cse -canonicalize -cse -pass-timing -pass-timing-display=pipeline 2>&1 | FileCheck -check-prefix=PIPELINE %s
-// RUN: mlir-opt %s -experimental-mt-pm=true -verify-each=true -cse -canonicalize -cse -pass-timing -pass-timing-display=list 2>&1 | FileCheck -check-prefix=MT_LIST %s
-// RUN: mlir-opt %s -experimental-mt-pm=true -verify-each=true -cse -canonicalize -cse -pass-timing -pass-timing-display=pipeline 2>&1 | FileCheck -check-prefix=MT_PIPELINE %s
+// RUN: mlir-opt %s -disable-pass-threading=true -verify-each=true -cse -canonicalize -cse -pass-timing -pass-timing-display=list 2>&1 | FileCheck -check-prefix=LIST %s
+// RUN: mlir-opt %s -disable-pass-threading=true -verify-each=true -cse -canonicalize -cse -pass-timing -pass-timing-display=pipeline 2>&1 | FileCheck -check-prefix=PIPELINE %s
+// RUN: mlir-opt %s -disable-pass-threading=false -verify-each=true -cse -canonicalize -cse -pass-timing -pass-timing-display=list 2>&1 | FileCheck -check-prefix=MT_LIST %s
+// RUN: mlir-opt %s -disable-pass-threading=false -verify-each=true -cse -canonicalize -cse -pass-timing -pass-timing-display=pipeline 2>&1 | FileCheck -check-prefix=MT_PIPELINE %s
 
 // LIST: Pass execution timing report
 // LIST: Total Execution Time: