-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
Description
Hi,
I have encountered a problem with version 2022.2.0 (and older) when using resumable tasks that task arenas were not getting any worker threads.
I have boiled it down to the following reproducer:
#include <oneapi/tbb.h>
#include <iostream>
int main(){
using namespace oneapi;
auto concurrency = std::thread::hardware_concurrency();
auto arena_bg = tbb::task_arena(tbb::task_arena::automatic);
auto arena_fg = tbb::task_arena(tbb::task_arena::automatic);
auto job = [&]() {
arena_fg.execute([&]() {
tbb::task::suspend([&](tbb::task::suspend_point suspend_point) {
arena_bg.enqueue([&, suspend_point]() {
std::cout << "If you can read this, all is fine\n";
tbb::task::resume(suspend_point);
});
});
});
};
tbb::task_group jobs;
for (unsigned i = 0; i < concurrency; i++)
jobs.run(job);
jobs.wait();
return 0;
};
The reproducer is not reliable. Sometimes it terminates fine, sometimes it deadlocks as tasks enqueued in bg_arena are never executed.
So I am unsure what is expected behavior should be: Are the worker threads resulting from suspended tasks still bound to the original arena or should they seek work in any arena?