Single Threaded Qaud Core v.s Hyper-Threading Dual Core [duplicate]
Let's say we have two CPUs, One is Quad Core 3.2 Ghz with 4 Cores, and We have a Dual Core 3.2 Ghz with 2 Cores with 2 threads in each Core (Hyper-Threading). My assumption as a programmer will be, the 4 cores 4 threads should perform faster than 2 cores 4 threads since the second CPU needs to switch between threads in order to emulate 4 cores while the first one doesn't need to perform such switching as each core can perform independently and individually.
I want to confirm that my assumption is true, if not please explain why one is better than the other.
Solution 1:
I do believe thats true - since hyper threading does share some elements - specifically the main execution resources, you'll be able to run 4 full threads at once, rather than waiting for those resources to be freed up.
The point of HT is to get better performance with a smaller use of die area - your quad core would generally be a bigger chip - say almost twice as large, than a non HT dual core chip, while a HT dual core chip would be about 5% larger. The Quad core could see up to twice the speed under the right work load (though, unlikely since you probably won't be running 4 threads at full capacity in most cases), while the dual core HT processor would see 15-30% better performance (according to wikipedia) than a dual core non HT processor.
More actual cores is usually better.
Solution 2:
From Wikipedia:
Hyper-threading works by duplicating certain sections of the processor— those that store the architectural state— but not duplicating the main execution resources. This allows a hyper-threading processor to appear as the usual "physical" processor and an extra "logical" processor to the host operating system (HTT-unaware operating systems see two "physical" processors), allowing the operating system to schedule two threads or processes simultaneously and appropriately. When execution resources would not be used by the current task in a processor without hyper-threading, and especially when the processor is stalled, a hyper-threading equipped processor can use those execution resources to execute another scheduled task. (The processor may stall due to a cache miss, branch misprediction, or data dependency.)
If you have a quad core system, then 4 threads can run each on a full core. If you have a dual core hyperthreading system, then 2 threads could run each on a full core, but with 4 threads the threads 1 and 2 will share one core and threads 3 and 4 will share the other core. Hyperthreading allows two threads to run in parallel (only) if they do not use the same processor resources. So in an ideal case you might get a high degree of parallelization, but as Wikipedia states the performance gain is not 100%, but only 15-30%.
Solution 3:
In hyper-threading, the idle time of the core for taskA(the said core could have sent a request to the disk for data, wait for the disk to seek the area of the platters, read the data and send it back to the core) is exploited to perform another taskB. So, when taskB is being serviced by the so called thread 2, and if data fetch request by taskA is completed, taskA still have to wait for the core to finish thread 2. Both threads cannot be executed simultaneously in one core. Again, HT exploits the speed mismatch between the core/processor and the various subsystems in your computer. HT uses your cores to full capacity...it is like full capacity utilisation. So, if you open four tabs in your browser, each tab will have a core in a 4 core system and two tabs will have to share a core in a 2 core system.