Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.
2466 Discussions

task_scheduler_init::default_num_threads() returns 1

Wang__Shaodong
Beginner
652 Views

I'm using a Core i7-6700 CPU. Why does tbb create only one thread by default?

0 Kudos
2 Replies
Alexei_K_Intel
Employee
652 Views

I suppose it is caused by the affinity mask of the calling thread. task_scheduler_init respects the affinity mask of the calling thread and, if only one bit is set, it can return 1. Do you use other threading models inside your application? Try to call task_scheduler_init::default_num_threads in the beginning of the main function. However, the affinity mask can be set externally, e.g. with the taskset utility. What OS do you use and how the application is launched? 

0 Kudos
Wang__Shaodong
Beginner
652 Views

Alex (Intel) wrote:

I suppose it is caused by the affinity mask of the calling thread. task_scheduler_init respects the affinity mask of the calling thread and, if only one bit is set, it can return 1. Do you use other threading models inside your application? Try to call task_scheduler_init::default_num_threads in the beginning of the main function. However, the affinity mask can be set externally, e.g. with the taskset utility. What OS do you use and how the application is launched? 

Hi Alex,

This problem is indeed caused by another library I use, namely dlib.

I'm using Arch Linux so I used the package on AUR. It constraints all the threads to only one core.

However, when I compiled dlib from source, the problem disappears.

0 Kudos
Reply