The Secret Of CPU HYPERTHREADING In Depth


👤 Diwas Poudel    🕒 14 May 2022    📁 TECH

HyperThreading

In fact, most of us are unfamiliar with Hyperthreading technology. However, this technology is not new to the world. Intel has been using it for about 18 to 20 years. This technology represents one of the most significant revolutions in the processor industry.

If you are a gamer or a technology enthusiast, you should be interested in this technology.

Short History of Hyperthreading

HyperThreading Technology is originally developed by Digital Equipment Corporation, however, it was brought to market by Intel with x86 bit architecture Foster MP-Based Xeon Processor in February 2002 and in Pentium 4 Desktop CPUs in November 2002. This Intel Pentium 4 with a 3.06 GHz processor was the first processor in history to break the 3 GHz barrier (officially announced). Intel Pentium 4 becomes the first HyperThreading desktop processor. So, we can say the Pentium 4 desktop was the first to process two independent threads at the same time.

Later, in the ItaniumAtomand Core seriesIntel also included the technology.

Intel has already licensed the patents for "Hyperthreading" in 1997 AD and was bought late to the market in 2002 AD.

Evolution of CPU Hyperthreading 

There are mainly three types of CPUs available in the market.

1 Single Core CPU

In a single-core-based CPU,  multitasking is done with context switching but can do just one task at a time. Each core has only one thread. Then came MultiCore CPU

2 MultiCore CPU

In a multi-core CPU, each core has its own circuitry (hardware) and cache and can read and execute instructions independently. Core and Core operate in parallel and do not interact. A dual-core processor has two physical cores, whereas a quad-core processor has four physical cores. Then there was a Hyperthreading CPU.

Also read: Can I start a computer without a CPU Cooler?

3 Hyperthreading CPU

Explained below 👇

Intel Pentium 4 Processor

fig: Intel Pentium4 Processor

Intel® first Hyperthreading Pentium® 4 Processor features are:

Product Collection Legacy Intel® Pentium® Processor
Code Name Products formerly Northwood
No. of Cores 1
No. of Thread  2
Processor Base Frequency 3.06 GHz
Cache 512 KB L2 Cache
Bus Speed 533 MHz FSB
Intel Turbo Boost Technology
Intel 64
Intel Hyperthreading Technology
Instruction Set 32 bit

for more visits here.

What is Hyperthreading?

Hyperthreading Technology is a hardware technique of the simultaneous multithreading (SMT) implementation from Intel and is mainly developed to improve overall superscalar CPU performance by properly utilizing CPU idle time while performing several tasks. It's usually known as HT Technology.

SMT is the most widely used multithreading technique nowadays.

Also read: Why AMD CPU is cheaper than Intel CPU? 

In general, Hyper-threading is a mechanism whereby a CPU divides up its physical cores into virtual/logical cores and OS treated those logical cores as if they are actually physical cores. So, here OS got tricked.Therefore, OS schedules two tasks on 2 virtual cores as used to do on 2 physical cores in a multiprocessor system. 

Note that such virtual cores / logical cores are also known as threads. Suppose Intel CPU has 2 cores then using HT Technology, 4 Threads or 4 Logical Cores/ Virtual Cores is created.

Example:

If I have a computer that has a 4-core processor, and runs two threads per core, then


Logical Cores = # of Physical Core * Thread on each core

Therefore, Logical Cores = 4 * 2 = 8 cores

Explanation: This above-mentioned hardware has a 4 core (4 physical processor units) processor and has 2 threads in every core so this has a total of (4 *2) = 8 logical CPU.

This concept of behaving 1 processor (physical processor) as 2 processors (logical processor) is hyperthreading.

In a nutshell, we can run a lot of applications at the same time with high performance if you have a hyperthreaded CPU. Also, Hyper-threading usually doesn't make your CPU much faster, but what it does is make it smoother and more responsive and help you clean up the hits and stutters that occur when you run out of threads.

Technical Details on HyperThreading

Hyperthreading creates two logical processors from one physical core. There are two separate hardware registers ( called architectural states) on each core. Therefore each hardware register has a separate program counter and stack pointer. But both of them will share internal microarchitecture components called execution units. So, hardware can switch between two threads ( two logical processors) by selecting register set A or register set B.

Fig: CPU with Hyperthreading (source info )

During the processing of threads, some of the inner components of the core (called executive units) are always idle in any clock cycle. By enabling hyper-threading, the execution units will simultaneously process instructions from two threads so that only for much less time execution units will be idle during each clock cycle.

Also read: What is nm in the processor? | 5nm,7nm,10nm and 14nm

In other words, Hyperthreading helps to hide the latency of the memory and allows prefetch buffers and other elements within the CPU instruction pipeline to remain full by alternating the tasks. The tasks that they are operating on ensuring that all the various execution units within the CPU are basically busy at any given point in time.

Myth of HyperThreading

  • Physical Core is the same as Logical / Virtual Core.
  • Hyper-Threading is the same as HyperTransport.
  • Hyperthreading does practically double the physical core of the CPU.

Performance Claims of HyperThreading

Intel boosts up to a 30% performance improvement compared with an otherwise identical, non-simultaneous multithreading Pentium 4 Computer.(source)

HyperThreading Parallelism

Hyperthreading can't do much for a single-threaded processor in your computer where you can operate only one task at a time.

A task running in one virtual core is unaffected by other virtual cores running in the same core processor. Furthermore, two virtual cores within a single physical core cannot truly operate in parallel. However, work interleaving or concurrency, in which one logical processor performs half of the task on one work and another logical processor performs half of the task on another work, is soon and continuously interleaved.

Also read: Why AMD processor has pins and the Intel does not have pins?

Application of HyperThreading

How much benefit you will get from hyperthreading depends on what you are actually doing. The advantage of hyperthreading depends on the types of workloads and it falls into two categories in general:

1 Extensive Multi-Tasking workflows.

Hyperthreading is a valuable feature if your workflow consists of a long chain of resources using tasks and you need to do many tasks at once. 

2 Workloads that make CPU load for a maximum of 100% of the time.

You will not get any benefit of hyperthreading when you are just using common applications like web browsers, wordprocessors, emailing. To take advantage of Hyperthreading you must run heavy applications like graphics, multimedia gaming. You may get the benefit of hyperthreading if runs application like MAYA, Photoshop, Illustrator, etc

Hyper Threading's greatest advantage is that the CPU remains active all/much of the time.

Image Depicting CPU Hyperthreading

Check Hyperthreading is available in your System

Do you have hyperthreading in your system? There are various ways of knowing whether your system is a hyperthreading enabled system or not?

Method 1: Using TaskManager (Simplest Way)

  • To open the Task Manager, press Ctrl + Shift + Esc keys simultaneously.
  • Go to the Performance tab
  • Select the CPU section from the left pane.
  • On the bottom right you will see the number of physical processors and logical processors.

 

💡 Note! If the number of the logical processors is the same as the core then it's clear that your system has no hyperthreading support or hyperthreading is not enabled.

Method 2: Using wmic command ( For Command Lover )

Open the command prompt and type "wmic" and press "Enter"

 wmic

This will activate wmic interface and then type the below code and press Enter

CPU Get NumberOfCores,NumberOfLogicalProcessors /Format:List

There you get the totally logical and physical processor as shown below:

  • NumberOfCores=2

  • NumberOfLogicalProcessors=4

Here, Total Logical Processor is 4 so , on each physical processor we have 4/2 = 2 logical processor.

Check-in Your Linux System 

Type lscpu in the command line and press Enter and look at the "Thread(s) per core" section as shown below:

 

Architecture:        x86_64                                                                                                                            
CPU op-mode(s):      32-bit, 64-bit                                                                                                                    
Byte Order:          Little Endian                                                                                                                     
CPU(s):              8                                                                                                                                 
On-line CPU(s) list: 0-7                                                                                                                               
Thread(s) per core:  2     // Look Here                                                                                                                             
Core(s) per socket:  4                                                                                                                                 
Socket(s):           1                                                                                                                                 
NUMA node(s):        1                                                                                                                                 
Vendor ID:           GenuineIntel                                                                                                                      
CPU family:          6                                                                                                                                 
Model:               158                                                                                                                               
Model name:          Intel(R) Xeon(R) CPU E3-1270 v6 @ 3.80GHz                                                                                         
-----      

If you haven't enabled hyperthreading in your system then these techniques will not work.

When to test Hyperthreading

You can test and know-how actually hyperthreading is helping if the below condition meets:

  • If the server has more than one CPU socket.
  • If the server supports a large number of cores per socket.
  • If the running application is a single-threaded application or does not efficiently handle multiple threads.
  • The application has an extremely high memory rate.
Also read: Parts of Motherboard and its Function Explained

It is also important to remember that hyperthreading is not routinely used by the system with the Windows Performance Monitor tool with a CPU load of 0 -50 per cent.

Hyperthreading enabled CPU vs Hyperthreading disabled CPU

If there are two programs running in hyperthreading enabled system, let's call them Program 1 and Program 2. The operating system detects two logical processors and queues them (Q1). These two programs can run in two separate logical processors if they are available, and when they require shared resources, they must wait in the processor's internal queue (Qx). So they only have to wait for shared resources. This demonstrates that in the case of shared resources, only one program is influenced by the activity of another.

In the hyperthreading disabled system, Only one thread seems to be active at a time. As OS sees only one processor if one program is processing then another has to be in the queue even in the nonshared environment.

hyper-threading-enabled-MT-and-hyperthreading-disabled-MT
fig.Hyperthreading Enabled CPU vs Hyperthreading Disabled CPU

The goal of Hyperthreading CPU

1 If you have to buy a CPU with 4 cores then it cost more than 4 logical cores CPU. So the main goal of CPU hyperthreading technology is to minimize cost so that the logical processor technology will get more improvements in the future.

2 Also other is for making the CPU fully active all the time.

Also read: Can I use my computer without Thermal Paste? 

Hyperthreading helps to fully utilize idle and underutilized resources of CPU and hence increase throughput for certain workload types. Some applications may observe a decrease in performance with hyperthreading and some found performance improvements and this is highly application-dependent because resources of the processor are shared between virtual/logical processors.

Advantage of HyperThreading

  • It increases core performance.
  • It can use high ends apps and games.
  • It can enhance the time for response and reaction of the system.
  • It increases no. of transactions that can be executed.
  • It can handle increased server workloads.
  • It reduces memory latency.
  • It can improve overall system performance
  • It makes the system more responsive.
  • It smoothes out computer experiences.
  • Utilize existing 32-bit application technologies while ensuring and maintaining 64-bit future readiness.
  • The number of transactions that can be executed can be increased.

Disadvantage of Hyperthreading

  • Shared resource conflicts may occur.
  • Threads are non-deterministic and involved extra design overload.

Hyperthreading Processor List

CPU Series Nomenclature Hyperthreading
Pentium 4 5xx, 6xx
Intel Core i3 i3-xxx, i3-2xxx, i3-3xxx, i3-4xxx, i3-61xx, i3-63xx
Intel Core i5 i5-7xx, i5-6xx, i5-2xxx, i5-3xxx, i5-4xxx, i5-64xx, i5-65xx, i5-66xx, i5-74xx, i5-75xx, i5-76xx, i5-84xx, i5-85xx, i586xx
Intel Core i7 i7-6xx, i7-7xx, i7-8xx, i7-9xx, i7-2xxx, i7-37xx, i7-38xx, i7-47xx, i7-48xx, i7-58xx, i7-59xx, i7-67xx, i7-68xx, i7-69xx, i7-7700K
Intel Core i9 i7-970, i7-980, i7-980x, i7-990x, i7-39xx, i7-49xx, i7-5820K, i7-59xx, i7-6800K, i7-6850K, i7-6900K, i7-6950X, (i5-7640X), i7-7740X, i7-7820X,i9-9900K, i9-9900, i9-9900T, i9-9880H, i9-9980HK, 8950HK,i9-7900X, i9-7920X, i9-7940X, i9-7960X, i9-7980XE, i9-9900T

Hyperthreading vs Multithreading

Hyperthreading is a very specific hardware technology that uses Multithreading techniques.

Hyperthreading Multithreading
Hyperthreading converts a single physical processor into two virtual or logical processors. Multithreading executes multiple threads in a single process simultaneously.

Parallel Execution vs Concurrent Execution of Thread

In parallel execution of threads, two threads run independently upon each other which is only possible if these two threads run in separate processors.
In a single cores/processor, concurrent execution occurs when threads always switch with some time slice and perform a job in a multi-threaded environment.

Hyper-Threading vs overclocking

Hyperthreading and Overclocking are practically separate terms.

Overclocking is the process where motherboard settings are made changed and increase the CPU clock speed than the normal one.
This helps to increase the performance of the overall system. Practically useful for game applications because one application runs overclocked and performs better.

Hyperthreading is different. It is the process where 1 core of the processor behalfs as two cores to the operating system which allows two cores
to run concurrently with one another rapidly. This helps in increasing the performance of the overall system. Practically useful for rendering applications like MAYA, and Autocad, because hyperthreading allows multiple software to run at the same processing speed by interleaving.

Note that the Hyperthreaded CPU can be Overclocked.

Frequently Asked Questions

1) How many threads are in a core?

Ans: 2 threads

2) How many cores does the i7 processor have?

Ans: In the i7 processor, hyperthreading is enabled so can process 8 threads at once.

3)  What do 4 cores and 8 threads mean?

Ans: 4 cores are like 4 processors working independently from one another and can work parallelly. But threads we mean 2 threads are sharing one core. Any thread in a core works by interleaving or concurrently by sharing the same resources.No, two threads in a core can work parallelly.

4) Are physical cores better than threads?

Ans: Yes, physical cores are better than threads because physical cores can work parallelly without disturbing each other. But any two threads within a core cannot work parallel. They share the same resources and work by interleaving or concurrently(not at the same time). So, physical cores are better than threads.

5) Is Hyperthreading necessary?

Ans: If you want to get the best out of your CPU by scheduling intelligently then a hyperthreading-based CPU is one of the best choices. Tasks like Gaming, Video Editing, and 3D rendering may require a hyperthreaded CPU.

6) Is it better to have multiple cores or hyperthreading?

Ans: Having actual cores is better than having hyperthreading. So, if you have 4 cores with no hyperthreading and 2 cores with hyperthreading. Then 4 cores with no hyperthreading perform better.

7) Does hyperthreading double the cores?

Ans: Hyperthreading does not double the physical cores but double cores logically. Suppose you have 2 cores with hyperthreading then you will have 2 extra logical processors. So, it behalf of 4 total processors to OS.

8) Does AMD use hyperthreading?

Ans: Hyperthreading is Intel Trademark. So, AMD uses different names for achieving the same things and the name is Clustered Multithreading (CMT).In Bulldozer family of AMD processors uses CMT designs. Eg. AMD Ryzen 5 2600 has 6 cores that handle 12 threads altogether.

Note: Hyperthreading is just a name given for SMT by Intel.

9) Does a Single Hyperthreading CPU equivalent to two physical CPU Cores?

Ans: It's not fair to say that a single CPU with hyperthreading provides equivalent performance of two full CPU cores.

10) Does CPU hyperthreading Improve Parallel Code performance?

Ans: When Hyperthreading is enabled, each physical core has two logical cores. This enables a single physical core to run two threads simultaneously. In terms of enhancing the performance of CPU-bound code, virtual cores don't do much.