English | 中文 | Русский | Français
2,595 Posts served
8,341 Conversations started
Yesterday Microsoft announced the "Parallel Extensions to the .NET FX CTP" (Community Technology Preview). Called ParallelFX for short, the new technology runs on .NET FX 3.5, relying on features available in C# 3.0 and Visual Basic 9.0.
I've downloaded .NET FX 3.5 and ParallelFX and started looking into what ParallelFX offers, in comparison with Threading Building Blocks and other parallelization technologies. It's going to take longer than just this morning to fully assess what ParallelFX offers, but I do have some first impressions from browsing the documentation resources Microsoft has provided.
It's a given that most open source developers will find ParallelFX unattractive:
Still, Microsoft has a history of working hard to make it easy for experienced Microsoft platform developers to embrace Microsoft's own implementations of new software development paradigms; so, we can expect that ParallelFX's ongoing emergence will be closely watched by the Microsoft-centric developer community.
Do platform independence and open source computation libraries matter?
To me, one of the huge advantages of TBB is that it is an extension to C++, a template library, like the Standard Template Library. Hence, Threading Building Blocks can be applied on (ported to) any platform that supports C++. Thus, we see TBB running on Linux, Solaris, FreeBSD, Windows, and the list of supported platforms is growing rapidly. On Windows, TBB can easily be built and applied using Visual C++ (as well as GCC and the Intel ICC compiler).
This feature of TBB brings to Windows platform developers who are familiar primarily with the Microsoft Visual Studio development suite the capability to integrate parallelized versions of a wide array of existing open source computational libraries written in highly efficient languages (C++, C, and Fortran, for example) into Windows applications. The threading management would be handled by TBB in a C++ function that calls the lower level computational algorithms (which, of course, would have to be threadsafe). Fortran libraries would be wrapped in C code, which is called by a TBB-multithreaded C++ function.
It might be possible to do something similar using ParallelFX and C# or Visual Basic (or C# wrapped by other .NET languages?), but I don't see any references to such an objective thus far. Instead, it looks like the intended purpose for ParallelFX will be parallelization of existing single threaded .NET applications and development of new multithreaded .NET applications. For example, the recent MSDN Magazine article "Optimize Managed Code For Multi-Core Machines" adapts an existing ray tracer program written in C# and multithreads it using ParallelFX.
The use of a ray tracing programming to demonstrate a threading package will be familiar to developers who have downloaded and built TBB, or seen TBB demonstrated at a conference. If you go into the examples/parallel_for/tacheon directory that comes with the TBB source download, and execute (assuming you've built TBB):
tacheon.tbb dat/teapot.dat
you'll soon see a teapot on a white and black checkerboard table, with the pattern of the table reflected on the body of the teapot:

Threading Building Blocks tacheon program teapot example
The tacheon program was used to demonstrate Threading Building Blocks at OSCON this past July, and it was demoed by Intel at conferences and trade shows long before TBB became an open source project.
The ParallelFX concept
The MSDN Magazine article says this about the structure of ParallelFX:
The library is built upon just two primitive concepts: tasks and replicable tasks. All other abstractions, such as futures and parallel for loops, are expressed in terms of those two primitives.
A "future" is "a task that computes a result."
The result of the future is retrieved through the Value property. The Value property calls Wait internally to ensure that the task has completed and the result value has been computed. Since Wait is called, calling Value throws any exceptions raised during the computation of the value.
This implies that a Windows developer can indeed program without having to be concerned about the multithreading that is occuring "under the hood." An attempt to access a value that has not yet been computed simply induces a block until the value has been computed and becomes accessible.
An interesting start...
The ParallelFX Community Technology Preview is certainly an interesting starting point. At present, the technology is fairly limited in terms of breadth of capability. For example, there are three methods in the Parallel class:
There are task-related classes, including the Future class. There is a ParallelState class, a System.Linq namespace. As I said above, it will take more than a morning for me to gain a meaningful understanding of what the current ParallelFX release offers (and some inkling of what its future may hold).
One thing I wonder about is whether ParallelFX offers an equivalent to TBB's task stealing. Without task stealing, a multithreading platform risks having an application block because the tasks assigned to some threads take much longer to complete than the tasks assigned to other threads. Threading Building Blocks handles this situation smartly, as was shown in my TBB task stealing experiments (see "Threading Building Blocks Parallel_for Task Stealing Demo", "TBB Task Stealing Demo: Further Analysis", and "TBB Task Stealing on a Quad-Core Windows System").
But how long to maturity?
This brings to mind an important question: can Windows developers (and companies that sell Windows applications) afford to wait until ParallelFX gains maturity and becomes a fully supported Microsoft product? And how much longer, beyond Version 1.0, will it take before a highly reliable version -- one that you'd be willing to stake your company's software products on -- is available?
If you're working on a processing-intensive Windows application today, what is your best path to parallelization (where your work is abstracted from the low-level threading)? We now have a preview edition of ParallelFX, but the preview is not an actual supported product. So you certainly wouldn't want to apply ParallelFX in any commercial application at this point.
When will ParallelFX become a fully-supported Microsoft product? I don't actually see any information about that at the moment. In this sense, compared with Threading Building Blocks, ParallelFX has a long, long way to go. TBB has existed as a supported commercial product for multiple years and is already integrated into several major high performance commercial applications.
Still, ParallelFX is an interesting technology. I've always highly respected what comes out of Microsoft Research, and I consider .NET a superb technology. I'll be continuing my investigation of ParallelFX and writing more soon.
Kevin Farnham
O'Reilly Media
| December 3, 2007 7:33 AM PST
Kevin Farnham | Jonathan: I am not aware of such an initiative at this time. I think that given that TBB is open source, there is an opportunity for someone (or a small team) from the community to take up that effort. Such an effort would surely open the door to much greater application of TBB by Windows developers. |
| December 3, 2007 7:36 PM PST
Vincent Tan |
Kevin, that MSDN article has a section named "Dynamic Work Distribution" that describes work stealing so TPL does appear to have task stealing. Also, the PFX team have a blog at which details the changes they are making. |
| December 3, 2007 7:38 PM PST
Vincent Tan |
That's odd. The link disappeared?!? Anyway, the PFX blog is at http://blogs.msdn.com/pfxteam/archive/tags/Parallel+Extensions/default.aspx |
| December 3, 2007 8:36 PM PST
Kevin Farnham |
Vincent: I think there may have been a glitch on the site a while ago (I see other comments about missing links, etc.). Thanks for pointing out the "Dynamic Work Distribution" section in the MSDN article. When I wrote this post I had downloaded ParallelFX and browsed a lot of materials, but I missed that section. It's good to know ParallelFX has implemented a task-stealing mechanism right from the start. That's critical, in my view. |

Jonathan