Effective CPU Utilizing with Parallel Extensions for .NET 3.5
Second CTP (Community Technology Preview) of Parallel Extension for .NET Framework 3.5 was released on June ( 2nd) .
This enables utilizing of Parallel Hardware for application developed by .NET developers & improves performance as the numbers of cores and processors increases. With just a little bit of learning programmers can easily exploit the benefits of concurrent programming.
Normally application would need parallelism for 2 things.
a) Data Parallelism: Enables you to break problems into individual parallel units of work by partitioning data, like arrays, lists, loop iterations, or XML files.
b) Task Parallelism: Provides more control over the expression of parallelism, enabling you to divide work based on the way your program's logic is grouped into functions and statements.
Parallel Extensions for .NET 3.5 gives 2 flavors for Parallelism.
Imperative parallelism: requires explicit calls to be made to begin and wait for work to finish.
Declarative Parallelism: Hides these things underneath higher-level APIs that do not require these individual steps to be spelled out in the program.
All in all there are only 3 mechanisms for achieving parallelism in one's code namely Declarative Data Parallelism, Imperative Data Parallelism and Imperative Task Parallelism.
From the Documentations, Here is a quick guide to choose which type of parallelism should be used for what type of a situation that your problem involves.
Declarative Data Parallelism – Choose PLINQ if you…
- Don't have a strong preference of model. There are patterns for using PLINQ to express task-based parallelism.
- Want to be forward looking as parallelism blockers become addressed in future releases.
- Already have LINQ code that you want to parallelize.
- Want a declarative syntax. You want to describe what the program should do rather than how the program should do it.
- Think more in terms of the data than the tasks.
Imperative Data Parallelism – Choose Parallel if you…
- Already have loops in your code that you want to parallelize.
- Think well in terms of existing loop and region semantics.
- Want to translate sequential imperative code to be parallel.
Imperative Task Parallelism – Choose Tasks and Futures if you…
- Need more control than PLINQ and Parallel provide?
- Think in terms of how you want to achieve parallelism in terms of tasks or actions.
- Want a semantic similar to how threads and the threadpool work today, but you want it to be more lightweight.
Download Microsoft Parallel Extensions to .NET Framework 3.5, June 2008 Community Technology Preview
Comments