So how do we write code that take advantage of multicores? Fortunately application servers like Microsoft IIS and SQL Server already ship with support for multicore but how can our applications leverage it? Relying on the developers to write code optimized for multicore would be too much to ask, the good folks at Microsoft are working on a framework (for managed code) that can greatly enhance developer productivity when targeting multicore systems. The framework is called the .NET PFX , the December 2007 CTP can be downloaded from here.
What do you do when you have an 8 core server around at your disposal … run PFX of course :) … beats running it off my dual core laptop. Have created a simple project that simulates computation work via 2 for loops, later the outer for loop was changed to a Parallel.For (new set of features in the PFX available in the System.Threading namespace)
The results are as follows:
When running the basic nested loop the overall operation takes 11792 milliseconds and as can be seen in the figure below only one core is being leveraged (behind the scene only one thread is being used)

When the same code is run using the PFX the same set of operations take 1746 milliseconds ie almost 1/10th the time taken in the previous case and as can be seen in the figure multiple cores are being used to complete the task (behind the scene multiple threads are being used)

This post demonstrates a simple case where the PFX can be used, in the future post we will take a look at using PFX (and PLINQ) to build more complex applications.

0 comments:
Post a Comment