Parallel Extensions

Short description: .NET managed concurrency library

.NET Store APIs

Async model

Parallel LINQ

TPL

LINQ

WPF

WCF

WCS

WinForms

ASP.NET

ADO.NET

Framework Class Library

Common Language Runtime

The .NET Framework stack

Parallel Extensions was the development name for a managed concurrency library developed by a collaboration between Microsoft Research and the CLR team at Microsoft. The library was released in version 4.0 of the .NET Framework.[1] It is composed of two parts: Parallel LINQ (PLINQ) and Task Parallel Library (TPL).[2][3] It also consists of a set of coordination data structures (CDS) – sets of data structures used to synchronize and co-ordinate the execution of concurrent tasks.[4]

## Contents

* 1 Parallel LINQ
* 2 Task Parallel Library
* 3 Architecture
* 4 See also
* 5 References
* 6 External links

## Parallel LINQ

PLINQ, or Parallel LINQ, parallelizing the execution of queries on objects (LINQ to Objects) and XML data (LINQ to XML). PLINQ is intended for exposing data parallelism by use of queries.[2] Any computation on objects that has been implemented as queries can be parallelized by PLINQ. However, the objects need to implement the `IParallelEnumerable` interface, which is defined by PLINQ itself. Internally it uses TPL for execution.[4][5]

## Task Parallel Library

The Task Parallel Library (TPL) is the task parallelism component of the Parallel Extensions to .NET.[6] It exposes parallel constructs like parallel `For` and `ForEach` loops, using regular method calls and delegates, thus the constructs can be used from any CLI languages. The job of spawning and terminating threads, as well as scaling the number of threads according to the number of available processors, is done by the library itself,[3] using a work stealing scheduler.[7]

TPL also includes other constructs like Task and Future. A Task is an action that can be executed independent of the rest of the program. In that sense, it is semantically equivalent to a thread, except that it is a more light-weight object and comes without the overhead of creating an OS thread. Tasks are queued by a Task Manager object and are scheduled to run on multiple OS threads in a thread pool when their turn comes.

Future is a task that returns a result. The result is computed in a background thread encapsulated by the Future object, and the result is buffered until it is retrieved.[3] If an attempt is made to retrieve the result before it has been computed then the requesting thread will block until the result is available.[6]

The other construct of TPL is Parallel class. TPL provides a basic form of structured parallelism via three static methods in the Parallel class:

Parallel.Invoke
Executes an array of Action delegates in parallel, and then waits for them to complete
Parallel.For
Parallel equivalent of a C# for loop
Parallel.ForEach
Parallel equivalent of a C# foreach loop

## Architecture

The main concept in the Parallel Extensions to .NET is a `Task`, which is a small unit of code, usually represented as a lambda function, that can be executed independently. Both PLINQ and the TPL API provides methods to create the Tasks – PLINQ divides a query into smaller Tasks, and the `Parallel.For`, `Parallel.ForEach` and `Parallel.Invoke` methods divide a loop into Tasks.

PFX includes a `Task Manager` object which schedules the Tasks for execution. A Task Manager contains a global queue of Tasks, which are then executed. It also encapsulates multiple threads onto which the Tasks are executed. By default, as many threads as there are processors (or processor cores) on the system are created, though this number may be manually modified. Each thread is associated with a thread-specific queue of Tasks. When idle, each thread picks up a batch of Tasks and puts them on its local queue, where they are then executed, one by one. If the global queue is empty, a thread will look for Tasks in the queues of its peers, and will take the Tasks which have been in the queue the longest (task stealing). When in execution, the Tasks will be executed independently, with the change in state of one Task independent of others. As a result, if they use a shared resource, they still need to be synchronized manually using locks or other constructs.

## See also

* Concurrency and Coordination Runtime
* Joins
* Cilk/Cilk Plus – comparable technology for C and C++
* Grand Central Dispatch – comparable technology in Mac OS X 10.6 developed by Apple.
* Java Concurrency – comparable technology in Java (also known as JSR 166).
* Threading Building Blocks (TBB) – comparable technology for C++ available for many systems created originally by Intel (also open source)
* Thread pool pattern
* Task parallelism
* ReactiveX (Reactive Extensions)

## References

1. ↑ "What's New in the .NET Framework 4". http://msdn.microsoft.com/en-us/library/ms171868.aspx#parallel_computing.
2. ↑ 2.0 2.1 "Programming in the Age of Concurrency: Concurrent Programming with PFX". http://channel9.msdn.com/Showpost.aspx?postid=347531.
3. ↑ 3.0 3.1 3.2 "MSDN Magazine: Task Parallel Library". http://msdn.microsoft.com/msdnmag/issues/07/10/Futures/default.aspx.
4. ↑ 4.0 4.1 "June 2008 CTP – Parallel Extensions to the .NET FX". http://blogs.msdn.com/somasegar/archive/2008/06/02/june-2008-ctp-parallel-extensions-to-the-net-fx.aspx.
5. ↑ "More powerful aggregations in PLINQ". http://blogs.msdn.com/pfxteam/archive/2008/06/05/8576194.aspx.
6. ↑ 6.0 6.1 Duffy, Joe (2009). Concurrent Programming on Windows. pp. 887–929. ISBN 978-0321434821.
7. ↑ Leijen, Daan; Schulte, Wolfram; Burckhardt, Sebastian (2009). "The Design of a Task Parallel Library". ACM SIGPLAN Notices 44 (10): 227. doi:10.1145/1639949.1640106.

## External links

| Wikibooks has a book on the topic of: .NET Development Foundation

|

* Parallel FX CTP June 2008
* Parallel Computing Developer Center

* v
* t
* e

.NET Framework

* Version history
* .NET strategy

Architecture|

* Common Language Runtime (CLR)
* COM Interop
* Framework Class Library (FCL)

Components|

* ADO.NET
* Entity Framework
* ASP.NET
* Web Forms
* AJAX
* Core
* Dynamic Data
* MVC
* Razor
* ClickOnce
* Dynamic Language Runtime
* Extensible Application Markup Language (XAML)
* Language Integrated Query (LINQ)
* Managed Extensibility Framework
* Microsoft Silverlight
* Microsoft XNA
* Parallel Extensions
* Windows Communication Foundation (WCF)
* WCF Data Services
* Windows Forms (WinForms)
* Windows Identity Foundation (WIF)
* Windows Presentation Foundation (WPF)
* Windows Workflow Foundation (WF)
* .NET Remoting

Tools|

| Decompilers|

* .NET Reflector
* dotPeek

|

Obfuscators|

* Dotfuscator
* SmartAssembly
* CodeArmor

Misc|

* CLR Profiler
* ILAsm
* .NET Compiler Platform
* Native Image Generator (NGen)
* XAMLPad

IDEs|

* Visual Studio
* Blend
* Express
* MonoDevelop
* SharpDevelop
* Xamarin Studio

Organizations|

* .NET Foundation
* Microsoft
* Xamarin

* Category
* List

* v
* t
* e

Parallel computing

General|

* Distributed computing
* Parallel computing
* Massively parallel
* Cloud computing
* High-performance computing
* Multiprocessing
* Manycore processor
* GPGPU
* Computer network
* Systolic array

Levels|

* Bit
* Instruction
* Thread
* Task
* Data
* Memory
* Loop
* Pipeline

Multithreading|

* Temporal
* Simultaneous (SMT)
* Speculative (SpMT)
* Preemptive
* Cooperative
* Clustered Multi-Thread (CMT)
* Hardware scout

Theory|

* PRAM model
* PEM Model
* Analysis of parallel algorithms
* Amdahl's law
* Gustafson's law
* Cost efficiency
* Karp–Flatt metric
* Slowdown
* Speedup

Elements|

* Process
* Thread
* Fiber
* Instruction window
* Array data structure

Coordination|

* Multiprocessing
* Memory coherency
* Cache coherency
* Cache invalidation
* Barrier
* Synchronization
* Application checkpointing

Programming|

* Stream processing
* Dataflow programming
* Models
* Implicit parallelism
* Explicit parallelism
* Concurrency
* Non-blocking algorithm

Hardware|

* Flynn's taxonomy
* SISD
* SIMD
* SIMT
* MISD
* MIMD
* Dataflow architecture
* Pipelined processor
* Superscalar processor
* Vector processor
* Multiprocessor
* symmetric
* asymmetric
* Memory
* shared
* distributed
* distributed shared
* UMA
* NUMA
* COMA
* Massively parallel computer
* Computer cluster
* Grid computer
* Hardware acceleration

APIs|

* Ateji PX
* Boost.Thread
* Chapel
* HPX
* Charm++
* Cilk
* Coarray Fortran
* CUDA
* HIP
* Dryad
* C++ AMP
* Global Arrays
* MPI
* OpenMP
* OpenCL
* OpenHMPP
* OpenACC
* TPL
* PLINQ
* PVM
* POSIX Threads
* RaftLib
* UPC
* TBB
* ZPL

Problems|

* Automatic parallelization
* Deadlock
* Livelock
* Deterministic algorithm
* Embarrassingly parallel
* Parallel slowdown
* Race condition
* Software lockout
* Scalability
* Starvation

* Category: parallel computing
* Media related to Parallel computing at Wikimedia Commons

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/Parallel Extensions. Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Parallel_Extensions&oldid=4150231"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template