Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

Task seemingly dropped

pedro_p_3
Beginner
143 Views

Hi there,

I am using TBB 4.1 in production and I have recently came across a problem that *seems* to indicate that on occasion tasks can be dropped without every being executed. I am using the following call to spawn a task:

      auto &task = *new(tbb::task::allocate_root()) DrainMailbox(*me, this);
      LOG << "Spawning " << &task;
      tbb::task::spawn(task);

And inside the task I log as follows:

struct TBBMailbox::DrainMailbox : public tbb::task 
{   
   DrainMailbox (TBBMailbox::PImpl &me, TBBMailbox const *ptr)
      : me (me), mbox_ptr (ptr)
   {}
   
   tbb::task* execute () 
   {
      LOG  << " task: " << this << " executing";
      

...

On occasion I see the "spawn" log entry but not the corresponding "executing" log entry (other tasks are still being spawned and executed - so I know TBB has enough non blocked threads to work with). 

Any ideas on what could be going wrong? This is in on Linux x64, 3.13. 

Thanks in advance

 

 

 

0 Kudos
1 Reply
RafSchietekat
Black Belt
143 Views

If you want to "fire and forget" a task, use enqueue() rather than spawn(). Otherwise you could explicitly spawn_root_and_wait().

Reply