Chapter 2. Imperative Data Parallelism


  • Understanding pure data-parallel problems

  • Launching parallel tasks

  • Understanding the differences between parallelism and concurrency

  • Refactoring loops to run in parallel using Parallel.For and Parallel.ForEach

  • Working with different techniques to partition input data in parallelized loops

  • Controlling parallelized loops

  • Transforming existing sequential code into parallelized code

  • Measuring the speedups and the scalability offered by parallelized code

  • Working with different degrees of parallelism

Visual C# 2010 (C# 4.0) and .NET Framework 4 offer exciting features designed to tackle the multicore and manycore complexity. However, because they include completely new features, programmers and architects must learn a new programming model.

This chapter is about some of the new classes, structures, and enumerations that allow you to deal with data parallelism scenarios. Instead of focusing on the most complex problems related to parallel programming, this chapter shows you how to create parallel code and describes the new concepts related to each scenario. This way, you will more fully understand the performance improvements.


With previous .NET Framework versions, it was difficult to develop applications capable of taking full advantage of multicore microprocessors. It was necessary to launch, control, manage, and synchronize multiple threads using complex structures that were capable of handling some concurrency ...

Get Professional Parallel Programming with C#: Master Parallel Extensions With .NET 4 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.