Disable MLIR multithreading while parsing input, this speeds up the

parser (which doesn't a lot of IR generation) by about 18%!
This commit is contained in:
Chris Lattner 2020-05-02 17:13:55 -07:00
parent 90daf8bbcf
commit 7a80afaad6
3 changed files with 11 additions and 1 deletions

View File

@ -7,10 +7,10 @@
#include "cirt/FIRParser.h"
#include "FIRLexer.h"
#include "cirt/Dialect/FIRRTL/Ops.h"
#include "mlir/IR/Verifier.h"
#include "mlir/IR/Diagnostics.h"
#include "mlir/IR/Module.h"
#include "mlir/IR/StandardTypes.h"
#include "mlir/IR/Verifier.h"
#include "mlir/Translation.h"
#include "llvm/ADT/ScopedHashTable.h"
#include "llvm/Support/SourceMgr.h"

View File

@ -79,6 +79,10 @@ int main(int argc, char **argv) {
auto processBuffer = [&](std::unique_ptr<llvm::MemoryBuffer> ownedBuffer,
raw_ostream &os) {
MLIRContext context;
// Nothing here is threaded. Disable synchronization overhead.
context.disableMultithreading();
llvm::SourceMgr sourceMgr;
sourceMgr.AddNewSourceBuffer(std::move(ownedBuffer), llvm::SMLoc());

View File

@ -70,6 +70,9 @@ processBuffer(std::unique_ptr<llvm::MemoryBuffer> ownedBuffer,
sourceMgr.AddNewSourceBuffer(std::move(ownedBuffer), llvm::SMLoc());
SourceMgrDiagnosticHandler sourceMgrHandler(sourceMgr, &context);
// Nothing in the parser is threaded. Disable synchronization overhead.
context.disableMultithreading();
OwningModuleRef module;
if (inputFormat == InputFIRFile) {
FIRParserOptions options;
@ -82,6 +85,9 @@ processBuffer(std::unique_ptr<llvm::MemoryBuffer> ownedBuffer,
if (!module)
return failure();
// Allow optimizations to run multithreaded.
context.disableMultithreading(false);
// If enabled, run the optimizer.
if (!disableOptimization) {
// Apply any pass manager command line options.