[lld] [llvm] [Support] Support nested parallel TaskGroup via work-stealing (PR #189293)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 30 20:47:44 PDT 2026
================
@@ -96,14 +96,30 @@ class ThreadPoolExecutor {
static void call(void *Ptr) { ((ThreadPoolExecutor *)Ptr)->stop(); }
};
- void add(std::function<void()> F) {
+ void add(std::function<void()> F, parallel::detail::Latch &L) {
{
std::lock_guard<std::mutex> Lock(Mutex);
- WorkStack.push_back(std::move(F));
+ WorkStack.push_back({std::move(F), std::ref(L)});
}
Cond.notify_one();
}
+ // Execute tasks from the work queue until the latch reaches zero.
+ // Used by nested TaskGroups (on worker threads) to prevent deadlock:
+ // instead of blocking in sync(), actively help drain the queue.
+ void helpSync(const parallel::detail::Latch &L) {
----------------
MaskRay wrote:
Done `Item()`
https://github.com/llvm/llvm-project/pull/189293
More information about the llvm-commits
mailing list