【问题标题】:Detect if AMD CPU has modules检测 AMD CPU 是否有模块
【发布时间】:2014-07-15 13:34:01
【问题描述】:

一些 Intel CPU 具有超线程,我可以通过阅读 bit 28 in register EDX from CPUID 检测到。 AMD CPU 没有超线程,但其中一些有modules which have two integer units and one floating point unit。有没有办法,比如通过CPUID,来检测一个CPU是否有模块?

编辑:根据 Jester 的回答,我提出了以下未经测试的函数(我无法使用 AMD 处理器)来确定每个“计算单元”(又名模块)的内核数。

// input:  eax = functionnumber, ecx = 0
// output: eax = output[0], ebx = output[1], ecx = output[2], edx = output[3]
//static inline void cpuid (int output[4], int functionnumber)  

void coresPerComputeUnit() {
    int abcd[4];
    int cores = 1;
    cpuid(abcd,0x80000000);
    if(abcd[0]<0x8000001E) return; // Fn8000_001E not available 
    cpuid(abcd,0x8000001E);  
    cores += (abcd[1] & 0xff00) >> 8; //ebx bit 15:8 CoresPerComputeUnit
}

http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2012/10/42301_15h_Mod_00h-0Fh_BKDG1.pdf

【问题讨论】:

  • 这还不足以回答您的问题,但the AMD architecture programmer's manual volume 3 中的 E5 部分(多核计算)提到了如何找出处理器有多少个内核。作为Bulldozer is a microarchitecture,而不是架构本身,这可能是您可以做的最好的事情来确定 AMD 处理器是否看起来像是在使用 Bulldozer。 (我链接的手册至少没有“推土机”的实例。)

标签: assembly x86 intrinsics amd-processor cpuid


【解决方案1】:

您可以使用 cpuid Fn8000_001E 计算单元标识符。 EBX(即BH)的位 15:8 保存 CoresPerComputeUnit:每个计算单元的核心数。价值:特定于产品。每个计算单元的核心数为 CoresPerComputeUnit+1。

请参阅 AMD BIOS 和内核开发人员指南。

【讨论】:

  • 我添加了一些未经测试的代码来执行此操作。我不太确定是否要检查 Fn8000_001E 的可用性。我没有 AMD 系统来测试这个。
  • 在我的 FX-8350 上运行良好。
  • 你测试了我的功能,它给出了 cores = 2?
  • 感谢您的检查!
猜你喜欢
  • 1970-01-01
  • 2014-09-09
  • 1970-01-01
  • 2020-07-09
  • 2021-01-18
  • 2013-03-05
  • 2017-09-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多