c#仍然返回错误的内核数 [英] c# STILL returning wrong number of cores

查看:50
本文介绍了c#仍然返回错误的内核数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好,所以我在C#中将帖子发布在 ("NUMBER_OF_PROCESSORS")返回错误的数字,询问如何在C#中获得正确的内核数.一些乐于助人的人将我引向几个类似的问题,但我已经尝试过这些解决方案.我的问题与另一个问题相同,因此被关闭,的确如此,但是那里给出的解决方案没有用.因此,我打开了另一个窗口,希望有人能够帮助您意识到其他解决方案无法正常工作.

Ok, so I posted in In C# GetEnvironmentVariable("NUMBER_OF_PROCESSORS") returns the wrong number asking about how to get the correct number of cores in C#. Some helpful people directed me to a couple of questions where similar questions were asked but I have already tried those solutions. My question was then closed as being the same as another question, which is true, it is, but the solution given there didn't work. So I'm opening another one hoping that someone may be able to help realising that the other solutions DID NOT work.

该问题为如何找到通过.NET/C#?的CPU内核数,该内核使用WMI尝试获取正确的内核数.好吧,这是给定代码的输出:

That question was How to find the Number of CPU Cores via .NET/C#? which used WMI to try to get the correct number of cores. Well, here's the output from the code given there:

Number Of Cores: 32
Number Of Logical Processors: 32
Number Of Physical Processors: 4

根据我的最后一个问题,该计算机是运行Windows Server 2008 R2 HPC版的64核AMD Opteron 6276(4x16核).

As per my last question, the machine is a 64 core AMD Opteron 6276 (4x16 cores) running Windows Server 2008 R2 HPC edition.

不管我做什么,Windows似乎总是返回32个内核,即使有64个可用.我已经确认该机器仅使用32个内核,如果我对64个内核进行硬编码,那么该机器将使用所有这些内核.我想知道检测AMD CPU的方式是否有问题.

Regardless of what I do Windows always seems to return 32 cores even though 64 are available. I have confirmed the machine is only using 32 and if I hardcode 64 cores, then the machine uses all of them. I'm wondering if there might be an issue with the way the AMD CPUs are detected.

仅供参考,如果您还没有读完最后一个问题,如果我在命令行中键入echo%NUMBER_OF_PROCESSORS,它将返回64.在编程环境中不会这样做.

FYI, in case you haven't read the last question, if I type echo %NUMBER_OF_PROCESSORS" at the command line, it returns 64. It just won't do it in a programming environment.

谢谢, 贾斯汀

更新:输出PROCESSOR_ARCHITECTURE从命令行返回AMD64,但从程序返回x86.该程序是在64位硬件上运行的32位程序.我被要求将其编译为64位,但它仍显示32个内核.

UPDATE: Outputting PROCESSOR_ARCHITECTURE returns AMD64 from the command line, but x86 from the program. The program is 32-bit running on 64-bit hardware. I was asked to compile it to 64-bit but it still shows 32 cores.

推荐答案

感谢您的协助,但我发现了问题.如我所料,这是由于AMD的设计.他们正在使用一种称为MCM(我认为是多芯片模块)的新体系结构,该体系结构会导致Windows无法正确识别内核数.我将其发布为解决方案,以防其他任何人遇到它.一位工作人员将我定向到一个修补程序,该修补程序位于 http://support.microsoft.com/kb/2711085

Thanks for your assistance, but I've found the problem. As I expected, it was due to AMDs design. They're using a new architecture called MCM (multi chip module I think) that causes Windows to not correctly identify the number of cores. I'm posting this as a solution in case anyone else runs into it. A work collegue directed me to a hotfix available at http://support.microsoft.com/kb/2711085

这篇关于c#仍然返回错误的内核数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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