-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
Description
Summary
Follow up for #1822
According to oneTBB specification, threads suspended by tbb::task::suspend are participating in other TBB work. But in fact the suspended thread is bound to the arena where it was suspended.
Consider the following test:
std::size_t concurrency = std::thread::hardware_concurrency();
tbb::task_arena arena_bg(tbb::task_arena::automatic);
tbb::task_arena arena_fg(tbb::task_arena::automatic);
spin_barrier barrier(concurrency);
auto job = [&] {
arena_fg.execute([&] {
barrier.wait();
tbb::task_arena::suspend([&](tbb::suspend_point sp) {
arena_bg.enqueue([&] {
tbb::task::resume(sp);
});
});
});
};
tbb::task_group tg;
for (std::size_t i = 0; i < concurrency; ++i) {
tg.run(job);
}
tg.wait();
Because of the barrier, all available worker threads will join he arena_fg and all of them will be suspended in arena_fg and no workers will come to arena_bg to execute the "resuming" tasks that were enqueued from the suspend functor.
Version
oneTBB 2022.3.0
Observed Behavior
The test case above hangs.
Expected Behavior
The test case above should exit successfully. To achieve this, the suspended threads should be allowed to execute tasks from other arenas.