- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page