Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where does parallel_for workers get its tasks from? #1225

Closed
blonded04 opened this issue Oct 9, 2023 · 1 comment
Closed

Where does parallel_for workers get its tasks from? #1225

blonded04 opened this issue Oct 9, 2023 · 1 comment
Labels

Comments

@blonded04
Copy link
Contributor

Good evening! I want to microbenchmark some ideas on modifying parallel-for worker-loop, and I don't know TBB internal architecture.

Can you please answer these questions:

  • Is it true that every thread that executes task from parallel-for gets it only from task_dispatcher::receive_or_steal_task? Is it the same for task_group? If no, where do parallel-for worker-threads obtain their tasks and in which cases?
  • Is it true that the same thread that calls task_dispatcher::receive_or_steal_task will eventually run it? If no, then who else can run it?
  • Which function exactly executes tasks, that are sent to parallel-for? Is it the same for task-group?
@pavelkumbrasev
Copy link
Contributor

Hi @blonded04,
The main task dispatch algorithm is presented in local_wait_for_all. The orders of how task will be found and executed described there.
In TBB each thread that participate in work inside the internal arena has its own task queue. It's the first place where thread goes for a next task to execute (by calling slot.get_task). If thread cannot find for in local queue it will try to steal work from other threads calling receive_or_steal_task.

Both parallel_for and task_group will utilize this algorithm during their execution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants