Thursday, January 17, 2013

Multicore CPUs and their processing speed.

Its common  to assume that a quad core CPU for example , quoted 2 GHz would offer a 8GHz .      
  4 x 2Ghz = 8GHz ? !?

But does this really happen? Answer is No and also Yes.

Its purely dependent on the software used. Software here means the Applications (Games, Browser , word processor etc)  and the way how the  operating system (Linux or windows) handles it.

Lets have a brief look .

Simplicity sake I use a quad core 2Ghz example in this article from now on, whereas it can be scaled to any number of cores.

I have written an article long back on 'what' and 'why' multicore processors quite some time back here

So,first lets see why a NO 8GHz?

A Multicore processor consists two or more  functionally independent processing cores embedded into a single physical chip.
I remember reading this analogy somewere, four cars each at at 20kms/h racing  parallel in the same direction never means 20 x4 = 80Kms/h.

It similar. Performance of independent cores cannot be seen as a combined one.So its more apt to call it a four core processor with each 2 GHz and not a single 8 GHz one.

Now, the answer for  YES. How can it give a 8 GHz operation?


Bit more technical way.

Ultimately the operating system controls the processors and coordinates the actions between the cores.

Any application will run as a process in an operating system and in turn processes are just a collection of operating units called threads. These threads run  in  the CPU core as per the scheduling algorithm for a particular execution time.

Assuming a Game like Need for Speed  (NFS) creates 4 equal priority threads and its the only application being executed. In an Unicore CPU , one of four processes get executed and other 3 wait.

If there are multiple cores, the operating system may a allow waiting threads to get executed in the other cores.Purely the OS discretion which thread executes in a particular core.

It is also possible that processes may be waiting for execution in single core even though other cores are idle. This phenomena is called CPU affinity. Windows allows setting CPU affinity in task manager by right clicking a process.


Assume only the above four NFS application process threads with equal priorities having 1 minute execution time (practical values in msecs or less) get assigned to four independent cores rated 2GHz at the same time. Only now the NFS application can be theoretically called to be running at 8GHz for the next 1 minute.

But this condition will never occur in our systems due reasons which include the following.

* Most of the applications we use are still not coded with proper threading for multicore architectures. It needs a major operation and code overhaul. These applications will always prove reduced efficiency on multicores.

* Practically the OS will run many more threads which may be scheduled simultaneously and different cores might be running different process threads

*Priority of each thread in single process itself can vary.

Even if the above factors are taken care, still a 2 x 4GHz  will never be equal to a single 8GHz core because of overhead involved in instruction level parallelism defined by Amdahl's Law.

Any mistakes above, discussions and comments welcome :-)

No comments:

Post a Comment