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

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

问题描述

英特尔 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天全站免登陆