- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I would like to know if it is possible to switch the task stealing off when using TBB ?
It appears to be activated by default and I need to switch it off to perform specific tests ....
I looked into the official book and found nothing related to this.
Did somebody already try something like that ?
Thanks a lot !
I would like to know if it is possible to switch the task stealing off when using TBB ?
It appears to be activated by default and I need to switch it off to perform specific tests ....
I looked into the official book and found nothing related to this.
Did somebody already try something like that ?
Thanks a lot !
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, yes, it is possible. Include task_scheduler_init.h header file and in your code before you run anything related to TBB create a task_scheduler_init object and pass 1 as an argument to the constructor (more info in reference manual).
[cpp]tbb::task_scheduler_init init(1);[/cpp]This will effectively turn off implicit TBB multi-threading for your application, only one TBB worker thread will be created, the work will be serialized, the tasks will be created in this single thread's task pool and will never be stolen, just taken out and executed. Unfortunately serialization is the only way here, because task stealing is the only mechanism in TBB to share work between threads, so having multiple threads with no stealing means having really just one thread.
Note: if you explicitly create other std::threads and run several algorithms in parallel, I think there still will be stealing between these master threads and task_scheduler_init will not help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok,
Thanks for your help,
Thanks for your help,
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