- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am new to tbb and am trying to understand the workings of tbb scheduler. I am still not convinced that I correctly understand the purpose of task reference count.
I understand the following points
- I need to set it before spawning any child tasks.
- I need to set it to (number of child +1) if I need the parent to block i.e. for wait_for_all to work.
- If i am using continuation , I have to set ref count for the continuing task.
However I still don't understand, why was this exposed to the user? In other words I can not think of a situation where I would want to set it to any number other than
(number of child) or (number of child +1) or ( just increment count by 1)
Why can't this automatically be done, assuming we have a construct that enables us to specify our intent to wait for children before launching them.
I see that this is done in the allocate_additional _child_of method.
Thanks!
Regards,
Manisha
I am new to tbb and am trying to understand the workings of tbb scheduler. I am still not convinced that I correctly understand the purpose of task reference count.
I understand the following points
- I need to set it before spawning any child tasks.
- I need to set it to (number of child +1) if I need the parent to block i.e. for wait_for_all to work.
- If i am using continuation , I have to set ref count for the continuing task.
However I still don't understand, why was this exposed to the user? In other words I can not think of a situation where I would want to set it to any number other than
(number of child) or (number of child +1) or ( just increment count by 1)
Why can't this automatically be done, assuming we have a construct that enables us to specify our intent to wait for children before launching them.
I see that this is done in the allocate_additional _child_of method.
Thanks!
Regards,
Manisha
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
> Why can't this automatically be done
Short answer: for efficiency reasons.
The task interface was never considered a primary user API in TBB; it evolved as the underlying mechanism to implement parallel algorithms. So it favors efficiency over simplicity. A separate method to set the reference counter, plus certain discipline to calculate and set it appropriately before spawning any childtask, allows to use one plain store instead of several atomic adds. It is still important for performance, and was even more important 6 years ago when TBB started.
If you need a convenient mechanism to work with individual tasks, look at the task_group class.
Short answer: for efficiency reasons.
The task interface was never considered a primary user API in TBB; it evolved as the underlying mechanism to implement parallel algorithms. So it favors efficiency over simplicity. A separate method to set the reference counter, plus certain discipline to calculate and set it appropriately before spawning any childtask, allows to use one plain store instead of several atomic adds. It is still important for performance, and was even more important 6 years ago when TBB started.
If you need a convenient mechanism to work with individual tasks, look at the task_group class.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
> Why can't this automatically be done
Short answer: for efficiency reasons.
The task interface was never considered a primary user API in TBB; it evolved as the underlying mechanism to implement parallel algorithms. So it favors efficiency over simplicity. A separate method to set the reference counter, plus certain discipline to calculate and set it appropriately before spawning any childtask, allows to use one plain store instead of several atomic adds. It is still important for performance, and was even more important 6 years ago when TBB started.
If you need a convenient mechanism to work with individual tasks, look at the task_group class.
Short answer: for efficiency reasons.
The task interface was never considered a primary user API in TBB; it evolved as the underlying mechanism to implement parallel algorithms. So it favors efficiency over simplicity. A separate method to set the reference counter, plus certain discipline to calculate and set it appropriately before spawning any childtask, allows to use one plain store instead of several atomic adds. It is still important for performance, and was even more important 6 years ago when TBB started.
If you need a convenient mechanism to work with individual tasks, look at the task_group class.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot for your reply.
Regards,
Manisha
Regards,
Manisha
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page