[mlir] Async: Add numWorkerThreads argument to createAsyncParallelForPass

Add an option to pass the number of worker threads to select the number of async regions for parallel for transformation.
```
std::unique_ptr<OperationPass<FuncOp>> createAsyncParallelForPass(int numWorkerThreads);
```

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D92835
This commit is contained in:
Eugene Zhulenev 2020-12-08 04:35:27 -08:00
parent 4fede8bc8a
commit 94e645f9cc
2 changed files with 12 additions and 0 deletions

View File

@ -19,6 +19,9 @@ namespace mlir {
std::unique_ptr<OperationPass<FuncOp>> createAsyncParallelForPass();
std::unique_ptr<OperationPass<FuncOp>>
createAsyncParallelForPass(int numWorkerThreads);
std::unique_ptr<OperationPass<FuncOp>> createAsyncRefCountingPass();
std::unique_ptr<OperationPass<FuncOp>> createAsyncRefCountingOptimizationPass();

View File

@ -96,6 +96,10 @@ private:
struct AsyncParallelForPass
: public AsyncParallelForBase<AsyncParallelForPass> {
AsyncParallelForPass() = default;
AsyncParallelForPass(int numWorkerThreads) {
assert(numWorkerThreads >= 1);
numConcurrentAsyncExecute = numWorkerThreads;
}
void runOnFunction() override;
};
@ -276,3 +280,8 @@ void AsyncParallelForPass::runOnFunction() {
std::unique_ptr<OperationPass<FuncOp>> mlir::createAsyncParallelForPass() {
return std::make_unique<AsyncParallelForPass>();
}
std::unique_ptr<OperationPass<FuncOp>>
mlir::createAsyncParallelForPass(int numWorkerThreads) {
return std::make_unique<AsyncParallelForPass>(numWorkerThreads);
}