Intel TBB使用的线程数
英特尔 TBB 如何选择用于并行部分的线程数?
有某种规格可用吗?
How does Intel TBB choose the number of threads to used for a parallel section?
Is there some kind of specification available?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从 TBB 版本 2.2 开始,任务调度程序将自动初始化,并在运行时处理要使用的线程数,如果您想要手动更改该数量,可以使用以下方法之一:
创建调度程序时,您 的线程数
可以指定您可以使用
在这种情况下,tbb 调度程序创建与您的 CPU 核心一样多的线程
As of TBB Version 2.2 the task scheduler will be automatically initialized and on runtime take care of the numbers of threads to use, if you manually want to change that number, you can use one of the following methods:
When you create the scheduler, you can specify the number of threads as
else you can use
In this case, tbb scheduler creates as many threads as your CPU cores
推荐的选项是让 TBB 决定池中的线程数量 - 它通常会创建与机器上逻辑 CPU 数量一样多的工作线程 - 请参阅 tbb::task_scheduler_init 的类参考。
在任何给定时间找出有多少工作线程存在或正在执行任务并不容易 - 这是一个经过深思熟虑的设计选择。来自英特尔 TBB 并行编程课程:
Letting TBB decide the number of threads in the pool is the recommended option - it will usually create as many worker threads as there are logical CPUs on the machine - see Class reference for tbb::task_scheduler_init.
It's not easy to find out how many worker threads exist or are executing tasks at any given time - this is a deliberate design choice. From Intel's TBB Parallel Programming Course:
文档说只是“取决于硬件配置”。可能只是可用的 CPU 核心数量。
Documetation says just "dependent on hardware configuration". Possibly it just number of CPU cores available.