英特尔TBB使用的线程数 [英] Number of threads used by Intel TBB

查看:622
本文介绍了英特尔TBB使用的线程数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Intel TBB如何选择用于并行段的线程数?

How does Intel TBB choose the number of threads to used for a parallel section?

有某种规格可用吗?

推荐答案

从TBB 2.2版开始,任务调度程序将自动初始化,并且在运行时照顾要使用的线程数(如果您要手动更改该数量) ,您可以使用以下方法之一:

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

tbb::task_scheduler_init init(nthread);

否则您可以使用

tbb::task_scheduler_init init(tbb::task_scheduler_init::automatic);

在这种情况下,tbb调度程序创建的线程数与CPU内核数一样

In this case, tbb scheduler creates as many threads as your CPU cores

这篇关于英特尔TBB使用的线程数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆