Enqueued tasks never gets picked up.

Enqueued tasks never gets picked up.


I have the following pattern

parallel_for (blocked_range(0 , max),  [ ] (r) {

for (size_t i = r.begin(); i != r.end(); ++i) {

         ctx[i]  = make_unique<tbb::task_group_context>();

         waitTask[i] = (new (tbb::task::allocate_root(*ctx))

                         tbb::empty_task); 

        waitTask[i]->set_ref_count(2);

        auto& workerTask = *new (waitTask->allocate_child()) WorkerTask(name);

        tbb::task::enqueue(workerTask);    

        waitTask[i]->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 .

 

1 post / 0 new