- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi -
Is it possible to throttle the maximum number of threads used by the task scheduler or for a parallel launch? I searched the forums for this, but couldn't find anything. Probably just the wrong key words.
Thanks.
Is it possible to throttle the maximum number of threads used by the task scheduler or for a parallel launch? I searched the forums for this, but couldn't find anything. Probably just the wrong key words.
Thanks.
Link Copied
8 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Provide a non-default argument to task_scheduler_init.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Raf Schietekat
Provide a non-default argument to task_scheduler_init.
Thanks
-T
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - turks
Raf, could you explain further ? What would be a "non default argument" ?
Thanks
-T
Thanks
-T
From the docs : http://www.threadingbuildingblocks.org/files/documentation/a00114.html
task_scheduler_init (int number_of_threads=automatic, stack_size_type thread_stack_size=0)
Shorthand for default constructor followed by call to intialize(number_of_threads).
-
task_scheduler_init tinit(4); // restrict tbb worker threads to 4, even if you have more or less hardware threads available
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - turks
Raf, could you explain further ? What would be a "non default argument" ?
Thanks
-T
Thanks
-T
task_scheduler_init( int number_of_threads=automatic, stack_size_type thread_stack_size=0);
So, you can ask directly for p threads by doing this:
task_scheduler_init init(p);
Cheers,
Terry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Vivek Rajagopalan
From the docs : http://www.threadingbuildingblocks.org/files/documentation/a00114.html
task_scheduler_init (int number_of_threads=automatic, stack_size_type thread_stack_size=0)
Shorthand for default constructor followed by call to intialize(number_of_threads).
-
task_scheduler_init tinit(4); // restrict tbb worker threads to 4, even if you have more or less hardware threads available
not 8 ? If I throttle back the worker threads at init time to 2 it uses as much CPU as when I init with 8.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - turks
Is there any way to know that if you ask for only 2 worker threads on an 8 core machine that you actually got 2 and
not 8 ? If I throttle back the worker threads at init time to 2 it uses as much CPU as when I init with 8.
not 8 ? If I throttle back the worker threads at init time to 2 it uses as much CPU as when I init with 8.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Raf Schietekat
The first task_scheduler_init instance sets the number of worker threads; any additional instances have no say in the matter. If you did provide the number to the first instance, what are the symptoms?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"Symptoms of initing to 1 or 2 threads is that my pipeline is using a lot of CPU."
That's not very specific.
"I assume the default (if no argument is given) is 8 on a machine with 2 quad-core chips ?"
Yes, unless you also have hyperthreading.
That's not very specific.
"I assume the default (if no argument is given) is 8 on a machine with 2 quad-core chips ?"
Yes, unless you also have hyperthreading.
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