Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Wang__Shaodong
Beginner
135 Views

task_scheduler_init::default_num_threads() returns 1

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
135 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? 

Wang__Shaodong
Beginner
135 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.

Reply