[PATCH] D115019: ThreadPool: grow the pool only as needed
Benoit Jacob via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 2 19:11:24 PST 2021
Benoit added inline comments.
================
Comment at: llvm/include/llvm/Support/ThreadPool.h:68-70
+ // Returns the overall number of threads, which is 1 (main thread) plus the
+ // number of worker Threads.
+ unsigned getThreadCount() const { return Threads.size() + 1; }
----------------
Please decide what we want here? The immediate problem that led me to add +1 here was that when Threads was empty, I was now returning 0, and the caller was clearly expecting at least 1:
At mlir/include/mlir/IR/Threading.h:75
```
size_t numActions = std::min(numElements, threadPool.getThreadCount());
SmallVector<std::shared_future<void>> threadFutures;
threadFutures.reserve(numActions - 1);
for (unsigned i = 1; i < numActions; ++i)
threadFutures.emplace_back(threadPool.async(processFn));
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D115019/new/
https://reviews.llvm.org/D115019
More information about the llvm-commits
mailing list