Hyper-Threading Technology and Multi-Core Processor Detection

Categories:

Introduction

Hyper-Threading Technology and Multi-Core Processor Detection, Part One (Flash* 8.0MB)

Intel engineer Phil Kerly explains how to detect both Hyper-Threading Technology-enabled processors and multi-core processors. More importantly, he presents how to associate which multi-core processors share the same physical processor package as well as how to associate which Hyper-Threading Technology logical processors with which core.

Hyper-Threading Technology and Multi-Core Processor Detection, Part Two (Flash* 9.0MB)

In Part 2, Phil steps through sample code in debug mode to demonstrate the information presented in Part 1. This same code could be incorporated into an application to enable tailored performance optimizations based on the logical-to-physical processor topology.


For more complete information about compiler optimizations, see our Optimization Notice.

Comments

asgehrke's picture

Thank you for these helpful videos. I was hoping to see the last part of the CPUCount function - the Part two video didn't display all the code.

Thanks, Allison

's picture

Thanks a lot for the Videos..They were very Informative..

's picture

The hyper-thread detection method described in this video is bogus.

The video used this formula:

(CPUID EAX=1 -> EBX[23:16])
- (CPUID EAX=4, ECX=0 -> EAX[31:26]) - 1
= Hyper-Threading Processors per core

For example for with a dual Intel Xeon E5520 has the following values:

(16) - (7) - 1 = 8

But this machine has 2 hyper-threading processors per core not 8.

The correct formula should be:

(CPUID EAX=1 -> EBX[23:16]) /
((CPUID EAX=4, ECX=0 -> EAX[31:26]) + 1)
= Hyper-Threading Processors per core

'(CPUID EAX=1 -> EBX[23:16])' is the total number of logical processors and '(CPUID EAX=4, ECX=0 -> EAX[31:26]) + 1' is the total number of actual cores.

I don't know how this "Senior Software Engineer" at Intel came up with his formula but it doesn't make much sense. In his defense, it may have worked on the processors available at that time.

todd-bezenek's picture

I have seen some cool stuff where algorithms detect the number of cores available, the cache size, or the pipeline architecture before they start. This is cool stuff!

-Todd

Todd Bezenek Computer Architect / Performance Analyst bezenek@gmail.com