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 :-)

Wednesday, January 16, 2013

Destiny?

Playing with and still an amateur  even after 4-5 years of meddling with Linux and Embedded environments.  Defining in short , it is random learning in bits and pieces rather than a structured learning approach , which I had tried to adopt many a times and failed. Professional commitments and pressure triggers the thinking process but the  learning is the same, slow and un-organized. Since college days it became customary to find something interesting, work on it  (sometimes a mad learning), Get the feel and shelve the topic in concern.
 
Two and a half years in the industry and recent times, the self started throwing some serious idealistic questions and learning seemed to be stagnant without answering .
* There is always more interesting and high paying jobs available.What did you achieve by entering or being in this domain?
* There are experts and people with high knowledge and experience ratings along with.How do you differ?
* As and with, its an IT job again, which has it own buzz. Beyond certain limits it becomes mandatory to take up management roles. How to cope with the technical interest?

Such kind of thoughts with the mere  motto of questioning my  professional existence.

Answering and above all satisfying the self is one of the most tedious work according to me. The mind doesn’t just settle for anything.

Looking back 4-5 years it was a time where I was ready to learn anything and everything  other than college curriculum which was forced.It was a search and even got few options to work on some technologies. Either took those opportunities light and lost it or handled it to a decent state but never attained mastery. Mindless actions. Krisshnan and Dhanasekar were the funny partners.

Got introduced to Linux and it was sluggish learning. Had took up some courses on embedded systems but then came the ultimate college corporate placement phase projected as the only future to exist. Not placed? then Life is gone. Such was the mental picture created.

Attended 8 ‘eligible’ companies. No sign of clearing. Finally Got a job in 9th one. Seemed to be at the top of the world. 2-3 months of vacation, joy and came the joining letter.

Destiny planned  a Mainframe computer career for me . When I requested for a domain of interest the Human resource personnel gave a blunt answer that , a fresher cannot have such attitude of not accepting what was offered.

The first time in life self simply told QUIT. Some gut feel and  help of Harish Kumar, there started a fresh work on the domain of interest. Parents were supportive accepting me to leave a high paying job (relatively).
Professional commitments and the area of work is purely dependent on the projects won by companies, especially small firms, that too for freshers its no where a concern. Thrown into different areas but the ground state was fixed interest in linux systems.

It was another point of time after an year , self told to fight again,  where I was deployed into a Vxworks project which only later I knew that it was a ever happening long term project and my skills would be locked.  for a newbie and young soul with full of thoughts on interest and future, it is a mental disaster. You don’t have power or voice in a corporate /semi-corporate setup.The same gut feel, managed to get it changed and there came the android into picture.

One more year passed there came a state where it at least seems my interest would be there in the road map some way or other. Advantage of joining a huge (in terms of quality) service company, it gives a chance to have in peep into all big semiconductor companies in the world as a consultant.
All over It has been a fight with self  for self. Even though many people with same or better skill sets the answer becomes,

“ It’s the career by CHOICE  and not by CHANCE ”

Now gonna be a consultant for a biggie in the build,  integration and debugging  role for a large software architecture. Hectic work presumed but the learning would be gorgeous.

It’s the path  and Miles to Go…