Advertisment

Processors Get Hyper-fast 

author-image
PCQ Bureau
New Update

Intel introduced the concept of running multiple processes concurrently on a desktop computer with their Pentium Pro processor. For the first time geeks could plug in two CPUs in their machines and have the OS exploit both of them for faster execution of tasks. This was called SMP (symmetric multi-processing). Now, Intel is once again venturing into this territory, albeit with a slightly different approach, with their Prescott core. This new technology is called

Hyperthreading.

Advertisment
The white spaces in the



execution code denote portions of the CPU lying idle

The basics



You might think that computers already have the capability to concurrently run processes–that is what an OS like Windows does, right? Not really. Any modern computer emulates that behavior by rapidly switching between tasks. Every process that is running on the OS is assigned the CPU for a small period of time (in milliseconds or even less) and then put in memory while another process takes control of the CPU. If this is done fast enough, it gives the user an impression that all these processes are running at the same time. This is a technique that is applied in software, and the hardware has no knowledge of all the different processes that are running. Also, a distinction must be made between ‘running’ and ‘executing’. Running means that a process is running on the OS, but not necessarily being executed by the processor. Execution, on the other hand, means just that–the process would be passing through the execution core of the CPU.

On to Hyperthreading



With SMP, the host OS has to decide how to delegate processes to the CPUs present in the system. Since on any modern computer there are usually lots of processes running, this isn’t too much of a problem. However, SMP is quite an expensive proposition since it requires special hardware. This is where Hyperthreading comes into the picture. Hyperthreading uses the normal hardware that we use in our systems, but a CPU with Hyperthreading enabled can act like two virtual processors.

Advertisment
A hyperthreading processor that handles instructions from multiple processes

How does it do this? Lets take a look at how a processor normally works.

In the diagram above, the CPU front-end passes instructions to the execution core. Different processes are shown in different colors. Notice the huge white spaces in the execution pipelines? These are the pipelines stages lying empty, waiting for instructions to pass through them. Hence, you can make out that large portions of the CPU are simply idle, while others are

working on some data. Hyperthreading tries to minimize this waste.

Advertisment

Now take a look at an SMP system. Here, twice as much work gets done per unit time, but the problem of CPU wastage remains.

Shown above is a Hyperthreading processor. With Hyperthreading, the processor front-end can feed instructions from multiple processes to the execution units (unlike normal processors or even SMP, where only one process’s instruction can be fed to the execution core at a time). As you can see, Hyperthreading’s strength lies in more efficient use of the execution units by allowing for more flexible scheduling. If you look carefully, you’ll notice that this diagram is the same as the two CPU diagrams in the SMP configuration superimposed over each other. Thus, with only one CPU in Hyperthreading mode we are doing the same amount of work as with two in SMP. Real life isn’t always as accommodating as the above diagrams, so the performance benefit may not be as great.

In an SMP system, twice as much work happens per unit time
Advertisment

In Hyperthreading, from the user or the OS’s perspective, the CPU is split into two or more logical processors. Threads can be scheduled to work on either one of these virtual processors, just like an SMP system. For this to work, several resources of a processor must be shared while others have to be replicated. For example, one of the most basic registers used by a processor is called the IP (Instruction Pointer). With Hyperthreading, a processor must have two IPs to keep track of the two threads that are being executed. Other components, like the cache and execution units are shared. Unfortunately, Hyperthreading’s strength–shared resources –is also its greatest weakness. Problems arise when threads contend for the same resource like cache. This can actually lead to a performance degradation compared even to a single CPU system without Hyperthreading. Thus, one has to be careful with the applications and the OS that are written to work on a Hyperthreading system.

Having gone through the basic architecture of a Hyperthreading system, it is quite clear that Hyperthreading is something that we need to keep an eye on. Till now, Intel has used hyperthreading only on its high-end Xeon systems. Now with desktop systems entering the picture, the stakes are much higher. Be on the lookout for our benchmarks of the hyperthreading enabled P4 3.06 GHz as soon as it’s available.

Anuj Jain

Advertisment