双处理器工作站上的多线程 - 如何在两个处理器上使用所有线程? [英] Multithread on dual processor workstation - How to use all threads on both processors?

查看:383
本文介绍了双处理器工作站上的多线程 - 如何在两个处理器上使用所有线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用旨在使用并行处理的软件和使用"CreateThread"的多个线程:

I am currently using software that is designed to use parallel processing and multiple threads using the "CreateThread":

m_ThreadHandle = CreateThread( 0, 0, ThreadProc, this, 0, &m_ThreadID );

在软件本身中,有一个选项可以定义允许软件使用的线程数。 

In the software itself there is an option to define how many threads the software is allowed to use. 

但是我遇到了以下情况:我有一个双xeon处理器工作站。每个Xeon有22个核心,这意味着总共44个核心,这意味着总共88个线程。当我在这个工作站上运行软件时,它只会使用最多
的44个线程,尽管我允许软件使用更多的线程。 

However I have come across the following situation: I have a dual xeon processor workstation. Each Xeon has 22 cores which means a total of 44 cores which means a total of 88 threads. When I run the software on this workstation, it will only use a maximum of 44 threads despite the fact that I have allowed in the software to use substantially more threads. 

我的印象是所有线程都会被自动使用。 

I was under the impression that all threads would be automatically used. 

需要做些什么才能允许软件同时使用两个CPU上的线程? 

What needs to be done to allow the software to use the threads on both CPUs at the same time? 

推荐答案

你有一件事没有提到的是,这个软件是由你或你所属的团队编写的。

One thing that you haven't mentioned is if this software was written by you or a team you are part of.

但无论如何,仅仅因为软件可以创建尽可能多的线程,就在那里通常是一些内置的方式来约束这个。例如,如果你告诉它创建2,000个线程,你会很高兴吗?

But anyway, just because the software could create as many threads as you tell it to, there is usually some inbuilt way to constrain this. For example, if you told it to create 2,000 threads would you be happy if it did?

为了避免这种情况,软件通常检查处理器布局并限制线程的总量。像GetLogicalProcessorInformation这样的函数就是这样使用的。如果软件正在使用它并且检测核心
而不是硬件线程,则它是一种设计选择。

To avoid this situation, software usually checks the processor layout and constrains the total amount of threads to this. There are functions like GetLogicalProcessorInformation which are used like this. If the software is using this and detecting cores and not hardware threads then it is a design choice.

因此,如果它是您编写的软件,请改用硬件线程计数。如果它不是您编写的软件,那么您需要联系开发人员询问他们如何操作,或提供功能请求。

So if it is software that you wrote, use the hardware thread count instead. If it isn't software that you wrote then you will need to contact the developers to ask them how to do it, or provide a feature request.


这篇关于双处理器工作站上的多线程 - 如何在两个处理器上使用所有线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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