0

一些英特尔 CPU 具有超线程,我可以通过从 CPUID 读取寄存器 EDX 中的第 28 位来检测它。AMD CPU 没有超线程,但其中一些具有 具有两个整数单元和一个浮点单元的模块。有没有办法,比如通过 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

4

1 回答 1

1

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

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

于 2014-07-15T14:02:39.140 回答