- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have the following pattern
parallel_for (blocked_range(0 , max), [ ] (r) {
for (size_t i = r.begin(); i != r.end(); ++i) {
ctx = make_unique<tbb::task_group_context>();
waitTask = (new (tbb::task::allocate_root(*ctx))
tbb::empty_task);
waitTask->set_ref_count(2);
auto& workerTask = *new (waitTask->allocate_child()) WorkerTask(name);
tbb::task::enqueue(workerTask);
waitTask->wait_for_all(); // wait for children to complete.
}
}
I get a hang with all threads in receive_or_steal_task, but the "execute" of WorkerTask never being called.
Things work fine if I wait on all waitTasks outside of the parallel_for in a different parallel_for.
OR
A sequential for loop in place of parallel_for in the above example also works fine .
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
tbb::task::spawn () instead of tbb::task::enqueue() also works well. But we need enqueue as we don't want to force require a wait() to guarantee the execution of the workerTask.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear @sanjivkumargupta,
Apologies for a lack of response. Please let us know if the question is still actual or not.
Thanks, Mariya
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page