-
Notifications
You must be signed in to change notification settings - Fork 978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Facing Deadlock issue with nested TBB #1316
Comments
Hi @goplanid, This is how I understood what you wanted to implement:
In oneTBB we doesn't guarantee parallelism for parallel region so this example might hang on: int num_threads_available = std::thread::hardware_concurrency();
tbb::task_arena arena(/* concurrency = */ num_threads_available);
arena.execute([&] {
tbb::parallel_for(tbb::blocked_range<int>(0, numjobs), [&] (tbb::blocked_range<int> r) {
wait_threads();
},
/* Will divide work statically on num_threads_available */ tbb::static_partitioner);
}); It will work fine in most of the cases but might hang if for example you have several loops that have wait inside and each wait expects Should the (1) (2) |
Hi @pavelkumbrasev, Thank you for providing your inputs. Your understanding is right. Let me give more details with the below example: I am dividing my dataset into multiple blocks/chunks where each block is parallely computed(using TBB). Each block is calling a third party library function that needs numjob threads to do its work. The library function has several loops that wait inside and each wait expects hardware_concurrency threads. Here are my further experiments:
There are issues with this path:
Your guidance will be highly appreciated. Thanks. |
Hi @goplanid, |
Hi @goplanid, To guarantee parallelism in the inner loop, you could try launching You can prevent oversubscription by throttling down the oneTBB concurrency (e.g., to |
Hi @dnmokhov
Hi @pavelkumbrasev @dnmokhov 2.a How can i get more detailed logs with oneTBB. Like how many threads are actually being used in each innerLoopTask. I am suspecting no of threads could be an issue. |
Hi @goplanid,
OneTBB parallel algorithms (e.g.,
You can call
As mentioned above, there is no specific parallelism guarantee. The executed tasks are distributed among the available threads. When a thread completes a task, it will run the next available task, so some of the tasks can end up being run serially.
By default, |
Hi @dnmokhov, Thank you for your inputs. Sorry for the late reply, I was on leave.
outer loop: inner loop:
TBB Warning: The number of workers is currently limited to 31. The request for 32 workers is ignored. Further requests for more workers will be silently ignored until the limit changes. Kindly correct if i am wrong anywhere and advise. You inputs are really appreciated. |
Hi @goplanid, The executed tasks are distributed among the available threads, so each of your 2 inner loops will be called using anywhere from 1 to 32 threads.
To not bog down the system with oversubscription, perhaps the best performance can be achieved by a serial outer loop and nested |
Hi,
I have below case of nested parallelism,
Level 1 or outer loop: tbb::parallel_for(tbb::blocked_range(0, 2),
outerLoopTask(A,B,C));
Level 2 or inner loop: tbb::parallel_for(tbb::blocked_range(0, numjobs), innerLoopTask);
What I want to do: I want to run the above code with best possible nested solution provided by TBB. In the above code Level 1 runs for 2 iterations and each iteration of Level 1 runs numjobs no of iterations(as it is an inner loop). I have a dependency in my code such that innerLoopTask can only operate when exact no of numjobs threads are used.
Steps tried:
To solve this problem I looked into work isolation page of documentation https://oneapi-src.github.io/oneTBB/main/tbb_userguide/work_isolation.html
I tried to create seperate task arena for each inner loop or level2 using the below code but it didn't help as I continue to see deadlock issue:
oneapi::tbb::task_arena nested;
nested.execute( [innerLoopTask,numjobs]{
tbb::parallel_for(tbb::blocked_range(0, numjobs), innerLoopTask);
I also tried the isolate function using the below code but still see the same issue:
oneapi::tbb::this_task_arena::isolate([numjobs, innerLoopTask]{
tbb::parallel_for(tbb::blocked_range(0, numjobs), innerLoopTask);
});
Help needed:
Any pointers will be of great help.
The text was updated successfully, but these errors were encountered: