diff options
author | Mehdi Amini <joker.eph@gmail.com> | 2024-02-19 18:07:12 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-19 18:07:12 -0800 |
commit | 744616b3aebd008a5ad0e9de9f82f5e284440ab1 (patch) | |
tree | e7712d6eac6ee52ee71745ff369c878a14dc0964 | |
parent | 71e0623110b674765fb9349f449279faa7361e3d (diff) | |
download | llvm-744616b3aebd008a5ad0e9de9f82f5e284440ab1.zip llvm-744616b3aebd008a5ad0e9de9f82f5e284440ab1.tar.gz llvm-744616b3aebd008a5ad0e9de9f82f5e284440ab1.tar.bz2 |
Rename `ThreadPool::getThreadCount()` to `getMaxConcurrency()` (NFC) (#82296)
This is addressing a long-time TODO to rename this misleading API. The
old one is preserved for now but marked deprecated.
-rw-r--r-- | bolt/tools/merge-fdata/merge-fdata.cpp | 3 | ||||
-rw-r--r-- | clang/tools/clang-scan-deps/ClangScanDeps.cpp | 6 | ||||
-rw-r--r-- | llvm/include/llvm/Support/ThreadPool.h | 5 | ||||
-rw-r--r-- | llvm/lib/Debuginfod/Debuginfod.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/LTO/LTO.cpp | 2 | ||||
-rw-r--r-- | mlir/include/mlir/IR/Threading.h | 2 | ||||
-rw-r--r-- | mlir/lib/ExecutionEngine/AsyncRuntime.cpp | 2 | ||||
-rw-r--r-- | mlir/lib/IR/MLIRContext.cpp | 2 | ||||
-rw-r--r-- | mlir/lib/Pass/Pass.cpp | 2 |
9 files changed, 15 insertions, 11 deletions
diff --git a/bolt/tools/merge-fdata/merge-fdata.cpp b/bolt/tools/merge-fdata/merge-fdata.cpp index 104991d..c6dfd3c 100644 --- a/bolt/tools/merge-fdata/merge-fdata.cpp +++ b/bolt/tools/merge-fdata/merge-fdata.cpp @@ -317,7 +317,8 @@ void mergeLegacyProfiles(const SmallVectorImpl<std::string> &Filenames) { ThreadPoolStrategy S = optimal_concurrency( std::max(Filenames.size() / 4, static_cast<size_t>(1))); ThreadPool Pool(S); - DenseMap<llvm::thread::id, ProfileTy> ParsedProfiles(Pool.getThreadCount()); + DenseMap<llvm::thread::id, ProfileTy> ParsedProfiles( + Pool.getMaxConcurrency()); for (const auto &Filename : Filenames) Pool.async(ParseProfile, std::cref(Filename), std::ref(ParsedProfiles)); Pool.wait(); diff --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp b/clang/tools/clang-scan-deps/ClangScanDeps.cpp index e45ea70..0458a4b 100644 --- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp +++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp @@ -870,7 +870,7 @@ int clang_scan_deps_main(int argc, char **argv, const llvm::ToolContext &) { EagerLoadModules); llvm::ThreadPool Pool(llvm::hardware_concurrency(NumThreads)); std::vector<std::unique_ptr<DependencyScanningTool>> WorkerTools; - for (unsigned I = 0; I < Pool.getThreadCount(); ++I) + for (unsigned I = 0; I < Pool.getMaxConcurrency(); ++I) WorkerTools.push_back(std::make_unique<DependencyScanningTool>(Service)); std::vector<tooling::CompileCommand> Inputs = @@ -894,13 +894,13 @@ int clang_scan_deps_main(int argc, char **argv, const llvm::ToolContext &) { if (Verbose) { llvm::outs() << "Running clang-scan-deps on " << Inputs.size() - << " files using " << Pool.getThreadCount() << " workers\n"; + << " files using " << Pool.getMaxConcurrency() << " workers\n"; } llvm::Timer T; T.startTimer(); - for (unsigned I = 0; I < Pool.getThreadCount(); ++I) { + for (unsigned I = 0; I < Pool.getMaxConcurrency(); ++I) { Pool.async([&, I]() { llvm::DenseSet<ModuleID> AlreadySeenModules; while (auto MaybeInputIndex = GetNextInputIndex()) { diff --git a/llvm/include/llvm/Support/ThreadPool.h b/llvm/include/llvm/Support/ThreadPool.h index 5e67a31..03ebd35 100644 --- a/llvm/include/llvm/Support/ThreadPool.h +++ b/llvm/include/llvm/Support/ThreadPool.h @@ -104,9 +104,12 @@ public: /// not to waste the thread. void wait(ThreadPoolTaskGroup &Group); - // TODO: misleading legacy name warning! // Returns the maximum number of worker threads in the pool, not the current // number of threads! + unsigned getMaxConcurrency() const { return MaxThreadCount; } + + // TODO: misleading legacy name warning! + LLVM_DEPRECATED("Use getMaxConcurrency instead", "getMaxConcurrency") unsigned getThreadCount() const { return MaxThreadCount; } /// Returns true if the current thread is a worker thread of this thread pool. diff --git a/llvm/lib/Debuginfod/Debuginfod.cpp b/llvm/lib/Debuginfod/Debuginfod.cpp index 4928fcb..1cf5507 100644 --- a/llvm/lib/Debuginfod/Debuginfod.cpp +++ b/llvm/lib/Debuginfod/Debuginfod.cpp @@ -414,7 +414,7 @@ Error DebuginfodCollection::findBinaries(StringRef Path) { sys::fs::recursive_directory_iterator I(Twine(Path), EC), E; std::mutex IteratorMutex; ThreadPoolTaskGroup IteratorGroup(Pool); - for (unsigned WorkerIndex = 0; WorkerIndex < Pool.getThreadCount(); + for (unsigned WorkerIndex = 0; WorkerIndex < Pool.getMaxConcurrency(); WorkerIndex++) { IteratorGroup.async([&, this]() -> void { std::string FilePath; diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index b38c568..b506258 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -1537,7 +1537,7 @@ public: } unsigned getThreadCount() override { - return BackendThreadPool.getThreadCount(); + return BackendThreadPool.getMaxConcurrency(); } }; } // end anonymous namespace diff --git a/mlir/include/mlir/IR/Threading.h b/mlir/include/mlir/IR/Threading.h index 4dc06766..0f71dc2 100644 --- a/mlir/include/mlir/IR/Threading.h +++ b/mlir/include/mlir/IR/Threading.h @@ -68,7 +68,7 @@ LogicalResult failableParallelForEach(MLIRContext *context, IteratorT begin, // Otherwise, process the elements in parallel. llvm::ThreadPool &threadPool = context->getThreadPool(); llvm::ThreadPoolTaskGroup tasksGroup(threadPool); - size_t numActions = std::min(numElements, threadPool.getThreadCount()); + size_t numActions = std::min(numElements, threadPool.getMaxConcurrency()); for (unsigned i = 0; i < numActions; ++i) tasksGroup.async(processFn); // If the current thread is a worker thread from the pool, then waiting for diff --git a/mlir/lib/ExecutionEngine/AsyncRuntime.cpp b/mlir/lib/ExecutionEngine/AsyncRuntime.cpp index 24835c5..1899029 100644 --- a/mlir/lib/ExecutionEngine/AsyncRuntime.cpp +++ b/mlir/lib/ExecutionEngine/AsyncRuntime.cpp @@ -437,7 +437,7 @@ extern "C" void mlirAsyncRuntimeAwaitAllInGroupAndExecute(AsyncGroup *group, } extern "C" int64_t mlirAsyncRuntimGetNumWorkerThreads() { - return getDefaultAsyncRuntime()->getThreadPool().getThreadCount(); + return getDefaultAsyncRuntime()->getThreadPool().getMaxConcurrency(); } //===----------------------------------------------------------------------===// diff --git a/mlir/lib/IR/MLIRContext.cpp b/mlir/lib/IR/MLIRContext.cpp index 2fd9cac..58ebe4f 100644 --- a/mlir/lib/IR/MLIRContext.cpp +++ b/mlir/lib/IR/MLIRContext.cpp @@ -638,7 +638,7 @@ unsigned MLIRContext::getNumThreads() { if (isMultithreadingEnabled()) { assert(impl->threadPool && "multi-threading is enabled but threadpool not set"); - return impl->threadPool->getThreadCount(); + return impl->threadPool->getMaxConcurrency(); } // No multithreading or active thread pool. Return 1 thread. return 1; diff --git a/mlir/lib/Pass/Pass.cpp b/mlir/lib/Pass/Pass.cpp index 5ee0ae6..3fb05e5 100644 --- a/mlir/lib/Pass/Pass.cpp +++ b/mlir/lib/Pass/Pass.cpp @@ -748,7 +748,7 @@ void OpToOpPassAdaptor::runOnOperationAsyncImpl(bool verifyPasses) { // Create the async executors if they haven't been created, or if the main // pipeline has changed. if (asyncExecutors.empty() || hasSizeMismatch(asyncExecutors.front(), mgrs)) - asyncExecutors.assign(context->getThreadPool().getThreadCount(), mgrs); + asyncExecutors.assign(context->getThreadPool().getMaxConcurrency(), mgrs); // This struct represents the information for a single operation to be // scheduled on a pass manager. |