InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

Parallel Programming with Microsoft .NET

Posted by Abel Avram on Sep 02, 2010

Sections
Development,
Architecture & Design
Topics
.NET ,
Parallel Programming
Tags
Patterns and Practices ,
Patterns

The patterns&practices team has released Parallel Programming with Microsoft .NET, a book containing guidance for writing parallel programs for .NET. In essence the book contains 6 design patterns for parallel programming accompanied by code samples.

Parallel Programming with Microsoft .NET attempts to deal with the difficult job of decomposing a problem in multiple tasks which can be run in parallel, coordinating the parallel tasks and using data sharing between tasks in order to avoid the need for synchronization which dramatically can affect the performance of a parallel program. For that purpose, the book introduces 6 design patterns used with .NET 4 Task Parallel Library (TPL) and PLINQ:

  1. Parallel Loops - Used when one needs to apply the same operation to multiple similar data inputs.
  2. Parallel Tasks – Used when one needs to apply different operations, each with its own data input.
  3. Parallel Aggregation - “Parallel aggregation introduces special steps in the algorithm for merging partial results. This pattern expresses a reduction operation and includes map/reduce as one of its variations.”
  4. Futures – Used to integrate data flow with control flow. “A future is a stand-in for a computational result that is initially unknown but becomes available at a later time. The process of calculating the result can occur in parallel with other computations.”
  5. Dynamic Task Parallelism – Also known as recursive decomposition, this pattern helps adding dynamically created tasks during a computation.
  6. Pipelines – this pattern combines the parallel task concept with the concurrent queues one, allowing a program to concurrently execute tasks on data inputs and respecting the order in which data is processed.

Each design pattern is accompanied by C#, VB.NET and F# code samples, all available on the Parallel Programming with Microsoft .NET project on CodePlex. The project mentions the intent of the patterns&practices team to produce a companion book for C++ developers using the Parallel Patterns Library (PPL) and Asynchronous Agents Library.

The guide contains advice on integrating the parallel design patterns with other OOP patterns such as Façades, Decorators, and Repositories. It also shows how to debug and profile parallel applications in Visual Studio 2010.

This is a long time coming... by Lou Marco Posted
  1. Back to top

    This is a long time coming...

    by Lou Marco

    Parallel programming will soon be an essential skill set of any programmer. I've done my fair share, as lots have, and I know that each time the experience was like a dentist visit - developing the code was a nightmare but, once done, the results were wonderful.

    To have some material, such as SAMPLES and 'accessable' reading matter available to other-than-Master-Jedi-programmers, the black art of parallel programming will seem less arcane and, with hope, more natural.

    Full-features languages like C# and rather (for now) escoteric languages like F# are in the right place to exploit parallelism. And the .NET platform is widely used, robust and getting better with each release (and, no, I'm not a Microsoft bigot!)

    Machines with multiple cores are the norm. In 5 years, how many cores and how much memory will be on 'standard' desktops? 16 cores? 128 gig? Imagine the tasks deemed impractical today because of resource limitations will be implemented!

    It's a great time to be in this business...

Educational Content

10 tips on how to prevent business value risk

One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.

Interview: Software Systems Architecture: Working With Stakeholders Using Viewpoints and Perspectives

InfoQ spoke to the authors of Software Systems Architecture on a couple of new topics, the System Context viewpoint and Agile, which have been added to the second edition.

Beauty Is in the Eye of the Beholder

Alex Papadimoulis discusses ugly code, where it comes from, how to avoid it, and how to get rid of it.

Architecting Visa for Massive Scale and Continuous Innovation

John Davies examines Visa’s architecture and shows how enterprises have architected complex integrations incorporating Hadoop, memcached, Ruby on Rails, and others to deliver innovative solutions.

Max Protect: Scalability and Caching at ESPN.com

Sean Comerford unveils ESPN.com’s architecture, what components are used and why, and the current changes the website goes through.

The Seven Deadly Sins of Enterprise Agile Adoption

Are there repeated patterns of failure on Enterprise Agile Enablement efforts? Sanjiv and Arlen discuss Seven Deadly Sins to avoid when adopting Agile in an enterprise.

Questions for an Enterprise Architect

Erik Dörnenburg answers: What is Enterprise and Evolutionary Architecture?, discussing 4 issues: Turning strategy into execution, Ensuring conformance, Where do the architects sit? Buying or building?

Wrap Your SQL Head Around Riak MapReduce

Sean Cribbs explains what Map-Reduce and Riak are, why and how to use Map-Reduce with Riak, and how to convert SQL queries into their Map-Reduce equivalents.