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?