Parallel Programming in .NET 4.0: And Much, Much More…
In my Parallel Programming blog series this week, we’ve looked at:
I want to conclude by frantically listing some other parallel support that I didn’t have time to tell you in a week. :) And this is *not* an all-inclusive list!
Thread Pool Improvements
The parallel computing team at Microsoft have made some wicked-cool improvements and optimizations to the Thread Pool, including using work-stealing local queues. I’ve described them in an earlier blog post.
Concurrent Collection Classes
.NET 4.0 provides a number of thread-safe collections: a ConcurrentQueue, ConcurrentStack, ConcurrentBag, and ConcurrentDictionary.
Various Sync Primitives
Some other random cool classes that support parallelism in .NET 4.0 are:
- Partitioner – provides common partitioning strategies
- Lazy – provides thread-safe support for lazy initialization
- AggregateException – bundles together multiple exceptions (which may be thrown from different threads executing in parallel) into a single exception
- Locks and fun stuff: SpinLock, SpinWait, SemaphoreSlim, ManualResetEventSlim
Support for Native Development
Being a .NET girl myself, I’ve focused on the managed code parallel computing support this week. However, there is a ton of support for native code (C++) development in the form of the Concurrency Runtime. A good starting point to learn about this is https://msdn.microsoft.com/en-us/library/dd504870.aspx.
Resources
If you’re into parallel computing, you should keep an eye on these great sites:
- Parallel Computing Developer Center: https://msdn.com/concurrency
- MSDN Documentation: https://msdn.microsoft.com/en-us/library/dd460693(VS.100).aspx
- The Parallel samples that I’ve been referencing all week: https://code.msdn.microsoft.com/ParExtSamples (click the Downloads tab)
- MSDN Forums for Parallel: https://social.msdn.microsoft.com/Forums/en-US/parallelextensions/threads
- The Managed Code Parallelism team blog: https://blogs.msdn.com/pfxteam (the great Stephen Toub blogs here)
- The Native Code Parallelism team blog: https://blogs.msdn.com/nativeconcurrency
- The Parallelism Tools team blog: https://blogs.msdn.com/visualizeparallel
- The Parallel Programming information on my blog: https://blogs.msdn.com/b/jennifer/archive/tags/parallel+programming/
In conclusion, parallel programming really should matter to you as a software developer. Moore’s Law (“The number of transistors in a chip will double every 2 years”) has reached a limit due to the amount of heat generated by that many transistors. Therefore, the way to gain faster performance is shifting from building faster cores to building multiple cores. We as software developers need to understand how to design and write code to take advantage of those multiple cores. The support in .NET 4.0 for parallelism will hopefully make this process easier.