- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would like to ask for some help understanding the role that some components play in the scheduler. I'm looking to understand the big picture of how these pieces fit. What is an Arena? Task proxy? Mailbox? Thanks.
I'll take a stab at getting this dialog started. In TBB TheArena is the data structure that keeps track of tasks and threads. It's created the first time task_scheduler_init::initialize is called with a non-deferred number of threads, when that function calls Arena::allocate_arena() and comprises three sections. The middle section is called the ArenaPrefix and contains a collection of miscellaneous data used for managing scheduling such as worker_list, the collection of worker threads attached to this arena.
After the prefix is an array of slots which is where the scheduled TBB tasks are hung. Arena allocation creates twice as many slots as available threads. Each slotmaintains a TaskPool which is a possiblearray of tasks with a couple extra fields to track status. allocate_area() reserves a slot for each worker thread and marks the rest as unused.
On the other side of the ArenaPrefix is an array of mailboxes that are indexed in the opposite direction from the slots and are used for passing tasks between threads to sort out affinities, which is where task proxies come into play.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Right. When a task is spawned, in case it has a non-zero affinity_id, it is also put into the mailbox corresponding to that id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As I recently wrote in another forum thread, task affinity mechanism in TBB does not guarantee that the affinitized task will be executed on the thread it was mailed to. In other words, affinity_id is a hint, not an order. And the note_affinity() callback is there to help you noticing when the hint was not followed, and make adjustments if necessary.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would like to ask for some help understanding the role that some components play in the scheduler. I'm looking to understand the big picture of how these pieces fit. What is an Arena? Task proxy? Mailbox? Thanks.
I'll take a stab at getting this dialog started. In TBB TheArena is the data structure that keeps track of tasks and threads. It's created the first time task_scheduler_init::initialize is called with a non-deferred number of threads, when that function calls Arena::allocate_arena() and comprises three sections. The middle section is called the ArenaPrefix and contains a collection of miscellaneous data used for managing scheduling such as worker_list, the collection of worker threads attached to this arena.
After the prefix is an array of slots which is where the scheduled TBB tasks are hung. Arena allocation creates twice as many slots as available threads. Each slotmaintains a TaskPool which is a possiblearray of tasks with a couple extra fields to track status. allocate_area() reserves a slot for each worker thread and marks the rest as unused.
On the other side of the ArenaPrefix is an array of mailboxes that are indexed in the opposite direction from the slots and are used for passing tasks between threads to sort out affinities, which is where task proxies come into play.
Hello, I am new to TBB
I am confused that why do we have 2*num_threads slots? Why dont we have slots=num_threads?
osman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am confused that why do we have 2*num_threads slots? Why dont we have slots=num_threads?
osman
There are more arena slots than HW threads in order to allow multiple masters (i.e. threads not created by TBB itself) to share their work. I.e. if an application already have a couple of threads to perform different functions, and both of those can benefit from data driven parallelism, both could use TBB algorithms, at the same or at different times.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Since master threads are external to TBB, reserving space for more than 1 master does not cause oversubscription by itself.
If more masters want to join arena simultaneously than there are slots for them, those who are late will not join, and so their tasks won't get stolen. They might join the arena later however if some slots got freed; if I am not mistaken each task spawn checks for a slot in the arena, if not yet there.

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