Skip to content

Commit

Permalink
Update the way to create pool.
Browse files Browse the repository at this point in the history
Signed-off-by: Haruki Imai <[email protected]>
  • Loading branch information
imaihal committed Jan 23, 2025
1 parent da52a06 commit 2414108
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/onnx-mlir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ int main(int argc, char *argv[]) {

// Create context after MLIRContextCLOptions are registered and parsed.
mlir::MLIRContext context(mlir::MLIRContext::Threading::DISABLED);
llvm::DefaultThreadPool pool(
llvm::hardware_concurrency(compilationNumThreads));
if (compilationNumThreads > 1)
context.setThreadPool(pool);
std::unique_ptr<llvm::ThreadPoolInterface> threadPoolPtr;
if (compilationNumThreads > 1) {
threadPoolPtr = std::make_unique<llvm::DefaultThreadPool>(
llvm::hardware_concurrency(compilationNumThreads));
context.setThreadPool(*threadPoolPtr);
}

if (!context.isMultithreadingEnabled()) {
assert(context.getNumThreads() == 1 && "1 thread if no multithreading");
Expand Down

0 comments on commit 2414108

Please sign in to comment.