4 threads vs 4 cores

cwalker457

Reputable
Mar 25, 2015
46
0
4,530
My question is what is the difference between a cpu with 4 cores and 4 threads and a cpu with 2 cores and 4 threads through hyper threading? Is there a difference, or would they run pretty much the same? Thanks for any replies and for any help! Greatly appreciated.
 
Solution
Referencing @molletts here: http://www.tomshardware.com/answers/id-1694436/hyperthreading-work.html

"Hyperthreading takes advantage of the highly modular nature of modern CPUs and the fact that, for most workloads, they have a surplus of resources.

For example, a CPU core may have several "modules" (execution units) for doing basic integer (whole number) maths and logic, several for doing more advanced maths, several more for loading and storing data from/to memory and so on.

Without hyperthreading, the core will read in the program from memory on demand and attempt to make best use of as many of those modules as possible by analysing the program code to try and determine which parts of it can be done at the same time and which parts...
Referencing @molletts here: http://www.tomshardware.com/answers/id-1694436/hyperthreading-work.html

"Hyperthreading takes advantage of the highly modular nature of modern CPUs and the fact that, for most workloads, they have a surplus of resources.

For example, a CPU core may have several "modules" (execution units) for doing basic integer (whole number) maths and logic, several for doing more advanced maths, several more for loading and storing data from/to memory and so on.

Without hyperthreading, the core will read in the program from memory on demand and attempt to make best use of as many of those modules as possible by analysing the program code to try and determine which parts of it can be done at the same time and which parts depend on the outcome of others and have to wait until the other parts have been completed. The usual result is that some of the execution units end up sitting idle because, in most cases, it is not possible to split the work into sufficient pieces of the right kinds of tasks to use all of the modules.

With hyperthreading, the core will present itself to the OS as two virtual cores. This allows it to read in two programs from memory (effectively) simultaneously. The two streams are analysed in the same way as before but, because they are separate programs that don't depend on each other's immediate outcomes, there are more opportunities to share out the work and do things at the same time. This way, more of the core's execution units can be kept busy.

A single core with hyperthreading will not be as quick as two real physical cores because there will be times when both programs want to use the same part of the core and the available resources will end up being split between them but in many cases, the variety of different operations that are performed in normal programs means that these "collisions" (resource contention) don't hurt performance too much. Modern HT-capable processors have very good schedulers and are heavily over-provisioned with resources so even when two similar tasks are being run, the performance penalty is relatively small. Older CPUs, such as the Pentium 4 HT, suffered a greater penalty from resource contention and had other disadvantages when HT was enabled, such as splitting the cache between the two threads rather than having a single shared cache and dividing a single register file (the processor's "short term memory") between them instead of having separate dedicated register files.

It is possible to optimise for hyperthreading if performance is a real issue (high-performance computing, for example) by advising the OS scheduler that certain tasks should be run on certain virtual cores to ensure that, for example, of the two virtual threads on one core, one is mostly doing integer maths and the other is mostly doing floating-point maths. This is generally not worth the effort for everyday workloads, though, as it can end up having the opposite effect and reducing performance unless the code is written with this kind of strategy in mind."
 
Solution
It's a hard question to answer with precision, because the real answer is, "it depends on the workload"... but here are a few generally true statements.

Hyperthreading helps with multithreaded workloads, but it's never as good, and usually a long a way short of a genuine CPU core.
So, a 2 core hyperthreaded CPU is usually significantly more capable than a 2 core, 2 thread CPU, but will always fall substantially short of a genuine quad core when it's given tasks that load up all 4 threads.

The thing is that there are still heaps of single threaded workloads. Games are increasingly starting to use 4 threads. Video editing tasks will usually fully saturate as many threads as you can throw at them. But there are still plenty of times when single threaded performance matters. This is why the real answer is "it depends on the workload".

So what are you using the computer for?
- Office, Internet, Media, etc -> Dual core + HT is perfect.
- Budget conscious gaming build, Dual core + HT is okay (graphics card matters more)
- Mid range or higher gaming build, genuine quad core (Intel i5), best (but graphics card is still far more important)
- Heavy Duty content creation, (video editing, streaming), as many cores & threads as you can afford. (i7 4 Core HT, or even 6/8core HT CPUs if you can).
 
4C/4T is inherently superior to 2C/4T which is better than 2C/2T. More threads lets you process more independent things at the same time (eg, running two programs actively) whereas cores let you run intensive tasks (or multiple tasks) concurrently.

For example, with video encoding 2C/2T and 2C/4T performs about the same because a video encoding thread can max out the CPU. While in the latter case the worker may dispatch 4T (meaning an actual thread from the OS) to the task, the first and second would both be physically accessing the 1st core and the core can't do more than 100% of its ability just because of hyperthreading.

Instead, hyperthreading would help run two things that have a lot of idle clock cycles in their processing, so 2C/4T can be as good as 4C/4T. You can think of it as a zipper. If one task will do 1 second of work, then wait a second while another task waits a second then does a second of work, you could have these two tasks execute on the same physical core in a way that the core itself is always active but both tasks look like they're both running normally. It completely depends on the task -- anything that actually uses the CPU at peak for long periods of time will not benefit from HT.

Of course 4C/4T has twice the silicon as 2C/4T, and 4C is always better than 4T that's why the Core i5 series is more expensive than the Core i3 series. However with the Core i7 4C/8T chips (the 4xxx and 6xxx Core i7s; the 5820K and 5930K are 6C/12T while the 5960X is 8C/16T), there's some debate about whether the additional 4T do anything or not because it can be hard to effectively use more than 4T in many programs. Effectively the task of writing properly multi-threaded programs is really hard and we're only in the past few years getting good tools to make this reasonable for many programmers to do it. However there's some overhead so an 8T execution uses more overhead than a 4T execution, and it's possible that 4C/8T CPUs would perform better with 4T running than with 8T while 2C/4T CPUs may perform better with 4T than with 2T. In that case, the Core i3's HT is helpful while the Core i7's is harmful. The trend, however, is to reduce this overhead so that more threads will always be better. It's an ideal, but it's not the case in practice (it's an upside down U curve, essentially).

 
my quick answer:
With hyperthreading, the SAME physical core simply runs another thread of code during the idle times that the CPU core has gone to fetch new code.

In some cases this can add as much as 40% processing compared to no hyperthreading.

Both threads appear to be executing at the same time but in reality the CPU is toggling back and forth between the code for one thread and the other.

If a game isn't very demanding like Tomb Raider on a modern Intel you'd get about the same performance. For well threaded applications like Handbrake you'd probably be closer to 20% time savings vs no hyperthreading.

Hyperthreading can be an issue in games if the MAIN THREAD of the game decides to run in the slower hyperthread. This can cause the same stutter issues you'd get if bottlenecked on a slower core with no hyperthreading.