13

I've heard the terms hyper-threading and multi-threading, but what exactly is the difference between them? What kind of Intel processor uses them?

6

2 Answers 2

27

Multithreading refers to the general task of running more than one thread of execution within an operating system. Multithreading is more generically called "multiprocessing", which can include multiple system processes (a simple example on Windows would be, e.g., running Internet Explorer and Microsoft Word at the same time), or it can consist of one process that has multiple threads within it.

Multithreading (or should I say, multiprocessing) is a software concept. Practically any Turing-complete CPU can perform multithreading, even if the computer only has one CPU core and that core does not support hyperthreading. In order to support multiprocessing, the CPU will interleave execution of different threads of execution, by executing one, then another, then another, where the operating system will divide up the time available into "slices" and give a roughly equal amount of time to each thread (the time doesn't have to be equal, but that's typically how it's done unless a process requests a higher priority).

Note that, whenever there are more software threads of execution trying to execute at any given time than there are available hardware (simultaneous) threads of execution, then these software threads will be "interleaved" among the available cores. In the case of a "uniprocessor" (one CPU core with no hyperthreading), if you have more than one software thread, they will always be interleaved. If you have a 4-core CPU with hyperthreading, that's 8 "hardware threads", meaning the CPU can execute 8 simultaneous threads of execution at the same instant, so if you had 8 software threads trying to run, they could all run at once; but if you had 9 software threads, one of the hardware threads would have to interleave a pair of threads (the exact pair of threads chosen would depend on the operating system's scheduler implementation).


Hyperthreading, on the other hand, refers to a very specific hardware technology created by Intel, which allows a single processor core to interleave multiple threads of execution more efficiently. In other words, a CPU with hyperthreading is going to provide performance which is somewhat greater than a CPU which is otherwise the same but without hyperthreading, because the hyperthreaded CPU will be able to concurrently balance two (sometimes more, but hyperthreading is usually 2-way) threads of execution on a given core.

However, hyperthreading is strictly slower than having completely separate physical cores, because there are some types of operations that can disrupt the performance advantages of hyperthreading, while there are fewer operations that can cause such an event with completely separate cores.

Take the following example, where "1 core" is assumed to perform exactly the same in all examples:

Example 1: 2 cores, no hyperthreading.
Example 2: 4 cores, no hyperthreading.
Example 3: 2 cores with hyperthreading.
Example 4: 4 cores with hyperthreading.

In this case, Example 4 will always be fastest. Example 2 might sometimes be about as fast as Example 4, on workloads that are extremely poorly suited to taking advantage of hyperthreading's optimizations.

Example 3, on the other hand, might sometimes, on workloads where hyperthreading is most advantageous, be almost as fast as Example 2, even though it has half as many physical cores.

Example 1 of course, will be slowest of all the examples, but it might sometimes be about as fast as Example 3, when running a workload poorly suited to hyperthreading.

In real world benchmarks with modern Intel CPUs, we typically find that hyperthreading results in, speakly very generally, 20% to 40% improvement in performance compared to no hyperthreading (with the "no hyperthreading" case being benchmarked by disabling the hyperthreading feature in the BIOS). Occasionally there will be workloads where disabling hyperthreading shows a performance advantage, but these workloads can be rare in actual usage. But, if I had a choice between 4 cores with hyperthreading or 8 cores, assuming that each core itself has the same performance, I would choose the 8 core CPU every time.

5
  • 3
    To be exact, multithreading and multiprocessing are not the same thing. Threads share execution context with the process they are associated with, while processes have their own execution contexts. However, for this answer this distinction is not that important. Apr 11, 2014 at 17:39
  • 2
    Hyperthreading technology was not "created by Intel"; for mainline x86 it is just a trademarked name for simultaneous multithreading. If the Alpha 21464 had been produced, it would have been one of the first prominent users of SMT. Intel did produce the first released use of SMT (possibly excluding lesser known processors) with some Pentium 4s, but basic idea was not an Intel invention.
    – user180742
    Apr 12, 2014 at 0:02
  • 3
    Quibble: hyperthreading is not strictly slower than separate cores. One can devise (artificial) cases where sharing L1 caches is a greater benefit than having full use a core's resources. Another peculiar case might be when one thread is persistently active and another briefly handles intermittent events; waking up a core intermittently is more expensive than waking up a thread on an active core. For threads with extremely low ILP, if cache contention is not an issue, then the greater energy efficiency of using a single core could allow greater turboboosting (better performance).
    – user180742
    Apr 12, 2014 at 16:11
  • 5
    Answers are editable on SU, so if you guys want to improve it, please feel free. Also, keep in mind the apparent level of knowledge of the OP; even my answer standing on its own is probably more technical than they expected or wanted. I intentionally glossed over some details in favor of ease of explanation. I doubt if the OP is going to be designing processors any time soon and desperately needs to know all these details. Interesting comments nonetheless. Apr 13, 2014 at 0:00
  • 1
    Suggested edits that change the content (i.e., not just grammar/typo corrections or rephrasing for clarity) are likely to be rejected.
    – user180742
    Apr 14, 2014 at 2:37
5

Multithreading is a term for parallel processing on the operating system level. The processor has nothing to do with multithreading.

Hyperthreading is an Intel concept that implements "simultaneous" processing of multiple threads in a single processor core. The operating system sees two processor cores, although there is only one physical core.

Not the answer you're looking for? Browse other questions tagged .