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

Montag451
  • 1,168
  • 3
  • 14
  • 30
Z boson
  • 32,619
  • 11
  • 123
  • 226
  • This isn't complete enough to answer your question, but section E5 (Multiple Core Calculation) in [the AMD architecture programmer's manual volume 3](http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2008/10/24594_APM_v3.pdf) mentions how to find out how many cores a processor has. As [Bulldozer is a microarchitecture](http://en.wikipedia.org/wiki/Bulldozer_%28microarchitecture%29), rather than an architecture itself, this may be the best you can do to find out if an AMD processor looks like it's using Bulldozer. (The manual I linked has no instances of "Bulldozer", at least.) – bouteillebleu Jul 15 '14 at 13:54

1 Answers1

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.

Jester
  • 56,577
  • 4
  • 81
  • 125