- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I would liked to limit TBB workers in my app to 4. This means that all "parallel_for" constructs will use exactly 4 workers.
I have few questions:
1.
should the "max_allowed_parallelism" parameter of global_control be specified to 4 or 5 (I got confused since the documentation in https://spec.oneapi.io/versions/1.1-rev-1/elements/oneTBB/source/task_scheduler/scheduling_controls/global_control_cls.html says that the actual value of this parameter is actually "parameter-value - 1")
2.
Are there other ways to limit the number for TBB workers in a specific app?
3.
can I assume that by default the main thread of the app is always blocked until "parallel_for" is completed and it does NOT become one the the workers during "parallel_for" ?
Thanks, Yariv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @yaridor,
The main thread does participate in the work during a parallel_for call, effectively acting as one of the worker threads. So, if you want to limit the total number of threads (including the main thread) to 4, you should set max_allowed_parallelism to 4. This way, you’ll have 3 worker threads plus the main thread, totaling 4 threads executing the parallel_for tasks.
I'm not sure I understand your question 2. The global_control allows you to control the number of threads (see above, the first paragraph). You could also create task arenas and limit the number of workers for each arena.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @yaridor,
The main thread does participate in the work during a parallel_for call, effectively acting as one of the worker threads. So, if you want to limit the total number of threads (including the main thread) to 4, you should set max_allowed_parallelism to 4. This way, you’ll have 3 worker threads plus the main thread, totaling 4 threads executing the parallel_for tasks.
I'm not sure I understand your question 2. The global_control allows you to control the number of threads (see above, the first paragraph). You could also create task arenas and limit the number of workers for each arena.
![](/skins/images/8B5EA638CA3587CA763EE9EF53643DD4/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page