Limiting number of threads with task_scheduler_init doesn't work

Limiting number of threads with task_scheduler_init doesn't work

david-m@orbotech.com的头像

Hi,

I'm creating

task_scheduler_init init(9);

and then

task_group group;

It always creates exactly 16 threads, regardless of the number I use in the init.  Do task groups not use task_scheduler_init?

Thanks,

David

6 帖子 / 0 new
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项
Anton Malakhov (Intel)的头像

What do you mean by "creates 16 threads"? 1) Do you see they simultaneously participating in the work? 2) Or do you see that 16 threads can join the work during the whole processing?
If (1) is true, please check whether another instance of task_scheduler_init already set the limit for this master thread (only the first specification matters)
(2) is expected behavior in case if you have 16 HW threads on your machine.

david-m@orbotech.com的头像

1) It both creates the pool and actually uses them during execution. I also thought perhaps the pool was 16 but not all were used.
I don't create another task_scheduler_init instance.

Raf Schietekat的头像

Also consider that any TBB scheduler-related call before an explicit task_scheduler_init is put on the application thread's stack will imply the default number of worker threads in that arena, as if there were an implicit task_scheduler_init that the explicit one could not override anymore. Could that be the case?

david-m@orbotech.com的头像

I was instantiating a thread observer before, but I put it after and I'm still getting 16 threads created and used.

Raf Schietekat的头像

To be absolutely sure, try putting the task_scheduler_init instance right in main(), so that it is created before anything else and destroyed after anything else. If that works (most likely), try getting gradually back to where you were, to isolate and hopefully remedy the problem. If it doesn't (rather less likely), please provide more information about release version and whatnot, perhaps with a minimal reproducer.

登陆并发表评论。