[PATCH] D61115: Parallel: only allow the first TaskGroup to run tasks parallelly
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 24 23:26:33 PDT 2019
MaskRay added a comment.
A triply nested loop can easily reproduce the dead lock:
#include <llvm/Support/Parallel.h>
#include <unistd.h>
int main() {
int a[99] = {};
llvm::parallel::for_each(llvm::parallel::par, a, a+99, [&](int x) {
usleep(1000);
llvm::parallel::for_each(llvm::parallel::par, a, a+99, [&](int x) {
usleep(1000);
llvm::parallel::for_each(llvm::parallel::par, a, a+99, [&](int x) {
usleep(1000);
});
});
});
}
`strace -f ./a` => You soon see no `nanosleep` syscalls are made as all threads get stuck in `futex()`. This patch fixes that.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D61115/new/
https://reviews.llvm.org/D61115
More information about the llvm-commits
mailing list