Friday, November 16, 2007

Parallel Computing Made Easy

At the Developer Conference, Øredev, earlier this week I had a chance to see a session about Microsoft's upcoming ParallelFX - the .NET toolkit for working utilizing multiprocessor machines - and it really looks promising!

The basic idea is that it should be a lot easier to utilize multi-processors from code than it is today. Sure, we have System.Threading and it's QueueUserWorkItem, Threads and some Async execution - but they are difficult to use in the most efficient manner. It's not easy to distribute a series of parallel tasks to threads in the way so that they will be distributed among the processors in the most sensible way!

This is where ParallelFX comes in. A part of it are some simple classes - both for Data Distribution (when you distribute the data you need processed so it's processed in parallel) and also to some degree Task Distribution - where you split up your tasks to run parallel wherever it makes sense.  The methods that make it all possible are for example the Parallel.For( ... ), Parallel.ForEach(...) and Parallel.Do(...) that all take delegates - or Lambda expressions (essentially the same). By introducing these methods it'll now be a lot easier to take typical tasks like For loops and speed them up a lot!

I can imagine a lot of For loops out there that perform non-interrelated operations (e.g. they are not dependent on each others execution) that will benefit with a small ParallelFX performance refactoring.

No comments: