Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
93 Views

From Cilk to Intel TBB

Jump to solution

Hi

 

I am big fan of Cilk but it is dead. So now I want to use TBB instead. (So I am new to TBB)

I rely on the function

 

__cilkrts_get_worker_number()

 

Therefore, I created a global arena  as follows

 

tbb::task_arena *global_arena=NULL;

int tbb_setnumworkers(integer32 numworkers)
{
  int  ok=1;

  if ( global_arena==NULL )
    global_arena = new tbb::task_arena (numworkers);
}

and then my parallel fors looks like

(*global_arena).execute([=](){ tbb::parallel_for(ufirst,ulast,ustep,[=](uinteger32 i){(*f)(i,arg);}); });

Now I need a thread id I do

 

integer32 tbb_workerid(void)
{
  if ( global_arena==NULL )
    return ( 0 );
  else
    return ( tbb::this_task_arena::current_thread_index() );
} /* tbb_workerid */

It works mostly. However, it seems when tbb_workerid is not called from the thread that created the global_arena then the thread is -1. Well, at least I get -1 in some cases.

Any suggestion for fixing this issue with thread id being -1 in some cases? Or is it impossible?

 

Thanks.

 

Erling

 

0 Kudos

Accepted Solutions
Highlighted
56 Views

Re: From Cilk to Intel TBB

Jump to solution

Sorry, my first attempt to answer this was wrong.  I don't think TBB has a way to detect the underlying thread id, by design (https://software.intel.com/en-us/comment/1585082#).

What are you going that requires the thread id?

http://jeffhammond.github.io/

View solution in original post

0 Kudos
2 Replies
Highlighted
57 Views

Re: From Cilk to Intel TBB

Jump to solution

Sorry, my first attempt to answer this was wrong.  I don't think TBB has a way to detect the underlying thread id, by design (https://software.intel.com/en-us/comment/1585082#).

What are you going that requires the thread id?

http://jeffhammond.github.io/

View solution in original post

0 Kudos
Highlighted
Moderator
26 Views

Re:From Cilk to Intel TBB

Jump to solution

The current_thread_index function you are using is the best available for getting a thread ID, but as Jeff pointed out thread ID is mostly hidden by design. Please read the discussion he posted regarding it.


I am closing support on this thread. Any further discussion will be considered community only, and Intel support will not be officially handling this thread going forward. If you need Intel support, please post a new thread.


0 Kudos