Linux – Unexpected processor/core counts for AMD processor

amdcpuhyperthreadinglinuxx86

I wanted to determine if a machine has hyperthreading enabled or not. To determine this, I used advice I found online, which operates as follows:

physical_proc_count = `grep "physical id" /proc/cpuinfo | sort -u  | wc -l`
logical_proc_count = `grep "processor" /proc/cpuinfo | wc -l`
core_count = `grep "core id" /proc/cpuinfo | sort -u | wc -l`

The idea is that if the number of logical processors is twice the number of cores, hyperthreading is enabled.

In my naivete at the time, I was oblivious to the fact that AMD processors don't have hyperthreading. I knew that they don't have the exact technology called "Hyper-Threading", but I mistakenly believed that they had a functional equivalent. So I ran the script on a machine with four AMD Opteron Processor 6276, and the output was:

  • 4 physical CPUs
  • 64 logical CPUs
  • 8 cores per physical CPU

8 cores per physical CPU == 32 cores. Yet there are 64 logical CPUs. Therefore I concluded that the machine had hyperthreading enabled. This was further compounded by the fact that the processor flags in /proc/cpuinfo include the "ht" flag. Which I have since learned stands for "HyperTransport" in the case of AMD chips — doh!

A co-worker noticed my mistake and stepped in and politely informed me that AMD processors don't have hyperthreading. I still don't understand why I got the above numbers that I did.

Checking the tech specs of the processor, it says there are actually 16 cores per physical CPU: http://products.amd.com/en-us/OpteronCPUDetail.aspx?id=759

Basically the output looks to me like there is hyperthreading. Where did I go wrong? How can I parse /proc/cpuinfo to get the true counts for all AMD and Intel (HT and non-HT) chips?

Best Answer

AMD's Bulldozer/Piledriver/Steamroller/Excavator microarchitecture, which is used in most of its current and recent processors including your 6276, has "modules" that are pairs of "cores" sharing certain components. The modules are somewhere between a single hyperthreaded core and a true pair of independent cores, with performance varying between being like one core and like two cores depending on the application.

AMD market each such module as two cores, calling the Opteron 6276 as a 16-core. Some software instead regards each module as a single physical core with two logical cores, and it looks like Linux is doing it that way.

Related Question