MulticoreInfo.com header image 2

PLINQ: Tap into extra power but with little extra work

January 5th, 2009 · No Comments




By Paul Kimmel for Dr. Dobb’s Journal
Multicore processors are a standard part of computing these days. For instance, the laptop I’m writing this article on has a Core 2 Duo Intel 64-bit processor and 3 GBs of RAM. That’s a lot of computing power for single-threaded code. Luckily, Parallel LINQ (PLINQ), which is part of the Parallel FX extensions for .NET, lets me use the basic LINQ keywords to tap into that extra power with little extra work on my part. The the Parallel FX Library is a managed concurrency library that includes PLINQ and the Task Parallel Library (TPL).

The basic use of PLINQ is to add a reference to the downloaded System.Threading.dll installed by default at C:\ Program Files\ Microsoft Parallel Extensions Jun08 CTP and call the IParallelEnumerable.AsParallel extension method on your collection. IParallelEnumerable&ltT> inherits from IEnumerable&ltT> and generally appears in a LINQ query at the end of the from range in collection clause. For instance, if the collection were an array of integers named numbers, then you would substitute collection with numbers.As Parallel().

Full Story

  • Share/Save/Bookmark

Tags: MulticoreInfo · Programming

Like what you're reading? Come back every day for multicore news, or subscribe to RSS updates.



Stumble It!