Detect if AMD CPU has modules

0

Some Intel CPUs have hyper-threading which I can detect by reading bit 28 in register EDX from CPUID. AMD CPUs don't have hyper-threading but some of them have modules which have two integer units and one floating point unit. Is there a way, such as through CPUID, to detect if a CPU has modules?

Edit: based on Jester's answer I have come up with the following untested function (I don't have access to an AMD processor) to determine the number of cores per "compute unit" (aka module).

// 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

assembly
x86
intrinsics
amd-processor
cpuid
asked on Stack Overflow Jul 15, 2014 by Z boson • edited Nov 19, 2014 by Montag451

1 Answer

1

You can use cpuid Fn8000_001E Compute Unit Identifiers. Bits 15:8 of EBX (ie. BH) holds CoresPerComputeUnit: cores per compute unit. Value: Product-specific. The number of cores per compute unit is CoresPerComputeUnit+1.

See the AMD Bios and Kernel Developer's Guide.

answered on Stack Overflow Jul 15, 2014 by Jester

User contributions licensed under CC BY-SA 3.0