Intel TBB使用的线程数

发布于 2024-09-24 10:54:19 字数 48 浏览 2 评论 0原文

英特尔 TBB 如何选择用于并行部分的线程数?

有某种规格可用吗?

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

Is there some kind of specification available?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

誰ツ都不明白 2024-10-01 10:54:19

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

创建调度程序时,您 的线程数

tbb::task_scheduler_init init(nthread);

可以指定您可以使用

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

在这种情况下,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

tbb::task_scheduler_init init(nthread);

else you can use

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

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

凡间太子 2024-10-01 10:54:19

推荐的选项是让 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:

How do I know how many threads are available?

Do not ask!

  • Not even the scheduler knows how many threads really are
    available
  • There may be other processes running on the machine
  • Routine may be nested inside other parallel routines
十雾 2024-10-01 10:54:19

文档说只是“取决于硬件配置”。可能只是可用的 CPU 核心数量。

Documetation says just "dependent on hardware configuration". Possibly it just number of CPU cores available.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文