Intel® Hyper-Threading Technology: Your Questions Answered

What is it?
Intel® Hyper-Threading Technology is a performance feature on our new Intel® Core™ i7 processor and the Xeon® 5500 series processors. Put simply, it allows one core on the processor to appear like 2 cores to the operating system. This doubles the execution resources available to the O/S, which potentially increases the performance of your overall system. For the visually-oriented, you can view a graphical explanation of Intel® Hyper-Threading Technology by clicking on the demo here.

Talking about cores, threads, and Hyper-Threads can get a bit confusing. To make things simple for the rest of this article, Hyper-Threads will be called hardware threads, and O/S level threads software threads. Just as a refresher, a core is 1 CPU. Each Core™ i7 or Xeon® 5500 series processor shipping currently has 4 cores (we may offer other versions in the future).

How can I tell if my system is using Hyper-Threading Technology?
You must have a processor, chipset, operating system, and BIOS that all support the technology. Luckily, that is not much of a problem. Many of the desktop and server platforms that ship with Nehalem-based processors include this support. Most of these platforms will allow you to enable or disable Hyper-Threading Technology as a BIOS option (it should be enabled by default). You can view your CPU information using the Task Manager in Windows*, and /proc/cpuinfo in Linux*. If you have a supported platform and Hyper-Threading is enabled, you should see twice the number of CPUs as you have physical cores in your platform. For example, if you have a dual-processor Xeon® 5500 series server, you should see 16 CPUs. (16 hardware threads running on 8 physical cores, 2 threads per core.)

HyperThreading_Disabled.JPG  HyperThreading_Enabled.JPG
Available CPUs on the same platform with Hyper-Threading Technology enabled (right) and disabled (left).

Can I run 2 applications simultaneously on 2 different threads on the same core?
Yes. The 2 software threads running on a single core do not have to be threads of the same process. They could be (in the case of multi-threaded software), or they could be from 2 separate applications. Which 2 software threads would run on the 2 hardware threads of a Hyper-Threaded core would be up to the operating system. So, yes, you could have 2 different applications running on the same core at the same time. (Whether you would get equal performance in this scenario as you would with the 2 apps running on separate cores is a different issue – see question 6.)

How is it implemented, under the covers?
The entire pipeline of the Nehalem-based processor core is set up to recognize 2 separate streams of instructions (one for each hardware thread). Various events cause the pipeline to switch from decoding and dispatching one stream to decoding/dispatching the other stream. All the resources in the pipeline are either shared or duplicated amongst the 2 hardware threads. For more information, see the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 1, section 2.2.7.

Can I give one hardware thread priority or ensure that it doesn’t get “starved” for execution time?
As a developer, there are various ways you can optimize your code for Hyper-Threading (all having to do with optimizing your code for threads in general); however – you can’t exactly give one thread priority. (Although there are some O/S level tools that allow you to assign priorities to processes and pin those processes to specific hardware threads.) The Hyper-Threading implementation does ensure that one hardware thread would not be starved. What you can do is use tools such as Intel® VTune™ Performance Analyzer and Intel® Thread Profiler to diagnose whether you are using your hardware threads efficiently and optimize things.

What kind of performance benefit will I get from using Intel® Hyper-Threading Technology?
There are many different ways in which Hyper-Threading Technology can provide a benefit. On a desktop system, it can allow a user to run more applications at once. For a developer, it provides more cores on which to run software threads. On a server with high CPU utilization, it can open up more performance on each core. In general, you will see the most benefit from Hyper-Threading when running software threads that experience large memory or other latencies. Suppose for example you have 2 software threads running on 2 hardware threads both running on the same core. If the 2 software threads each have some I/O, long memory access, or sleep times then you are more likely see a significant benefit from Hyper-Threading. (Because having 2 hardware threads allows for more efficient use of resources during long periods of waiting.) Many review sites have published benchmark results showing the benefit of Intel® Hyper-Threading Technology as well.
Finally, one last thing to note is that you can still run single-threaded applications on a platform with Hyper-Threading enabled. Intel® Hyper-Threading is designed to not reduce the performance of single-threaded applications.

Etiquetas:
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.