Chapter 2. Imperative Data Parallelism
WHAT'S IN THIS CHAPTER?
Understanding pure data-parallel problems
Launching parallel tasks
Understanding the differences between parallelism and concurrency
Refactoring loops to run in parallel using
Parallel.For
andParallel.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.
LAUNCHING PARALLEL TASKS
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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.