Zum Inhalt springen

„Parallel Extensions“ – Versionsunterschied

aus Wikipedia, der freien Enzyklopädie
[ungesichtete Version][ungesichtete Version]
Inhalt gelöscht Inhalt hinzugefügt
Un brice (Diskussion | Beiträge)
Mention JSR 166
FatalError (Diskussion | Beiträge)
some minor cleanup
Zeile 1: Zeile 1:
{{future software}}
{{future software}}
[[Image:DotNet.svg|thumb|right|250px|The [[.NET Framework]] stack.]]
[[Image:DotNet.svg|thumb|right|250px|The [[.NET Framework]] stack.]]
'''Parallel Extensions''', previously known as the Parallel Framework Extensions or ('''PFX'''), is a [[Managed code|managed]] [[Concurrent programming|concurrency]] [[Library (computing)|library]] being developed by a collaboration between [[Microsoft Research]] and the [[Common Language Runtime|CLR]] team at [[Microsoft]]. It is composed of two parts: '''Parallel LINQ''' ('''PLINQ''') and '''Task Parallel Library''' ('''TPL''').<ref name="channel9">{{cite web | url = http://channel9.msdn.com/Showpost.aspx?postid=347531 | title = Programming in the Age of Concurrency: Concurrent Programming with PFX | accessdate = 2007-10-16}}</ref><ref name="msdnmag">{{cite web | url = http://msdn.microsoft.com/msdnmag/issues/07/10/Futures/default.aspx | title = MSDN Magazine: Task Parallel Library | accessdate = 2007-10-16}}</ref> It also consists of a set of '''Coordination Data Structures''' (CDS) - a set of [[data structure]]s used to synchronize and co-ordinate the execution of concurrent tasks.<ref name="somajune"/> The library was released as a [[Community Technology Preview|CTP]] on [[November 29]], [[2007]]<ref>{{cite web | url = http://blogs.msdn.com/somasegar/archive/2007/11/29/parallel-extensions-to-the-net-fx-ctp.aspx | title = Parallel Extensions to the .NET FX CTP | accessdate = 2007-11-30}}</ref> and refreshed again in December 2007 and June 2008.<ref name="somajune"/> Microsoft has announced that the '''Parallel Extensions to .NET''' will release as part of the .NET 4.0 Framework release<ref>{{cite web | url = http://blogs.msdn.com/pfxteam/archive/2008/10/10/8994927.aspx | title = Parallel Programming and the .NET Framework 4.0 | accessdate = 2009-01-25}}</ref>.
'''Parallel Extensions''', previously known as the Parallel Framework Extensions or ('''PFX'''), is a [[Managed code|managed]] [[Concurrent programming|concurrency]] [[Library (computing)|library]] being developed by a collaboration between [[Microsoft Research]] and the [[Common Language Runtime|CLR]] team at [[Microsoft]]. It is composed of two parts: [[#Parallel LINQ|''Parallel LINQ'']] (PLINQ) and [[#Task Parallel Library|''Task Parallel Library'']] (TPL).<ref name="channel9">{{cite web | url = http://channel9.msdn.com/Showpost.aspx?postid=347531 | title = Programming in the Age of Concurrency: Concurrent Programming with PFX | accessdate = 2007-10-16}}</ref><ref name="msdnmag">{{cite web | url = http://msdn.microsoft.com/msdnmag/issues/07/10/Futures/default.aspx | title = MSDN Magazine: Task Parallel Library | accessdate = 2007-10-16}}</ref> It also consists of a set of ''coordination data structures'' (CDS) - sets of [[data structure]]s used to synchronize and co-ordinate the execution of concurrent tasks.<ref name="somajune"/> The library was released as a [[Community Technology Preview|CTP]] on November 29, 2007<ref>{{cite web | url = http://blogs.msdn.com/somasegar/archive/2007/11/29/parallel-extensions-to-the-net-fx-ctp.aspx | title = Parallel Extensions to the .NET FX CTP | accessdate = 2007-11-30}}</ref> and refreshed again in December 2007 and June 2008.<ref name="somajune"/> Microsoft has announced that the Parallel Extensions to .NET will release as part of the .NET 4.0 Framework release.<ref>{{cite web | url = http://blogs.msdn.com/pfxteam/archive/2008/10/10/8994927.aspx | title = Parallel Programming and the .NET Framework 4.0 | accessdate = 2009-01-25}}</ref>


==PLINQ==
==Parallel LINQ==
{{see also|Language Integrated Query}}
{{see also|Language Integrated Query}}
'''PLINQ''' is a concurrent query execution engine for [[Language Integrated Query|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.<ref name="channel9"/> Any computation on objects that has been implemented as queries can be parallelized by PLINQ. However, the objects need to implement the <code>IParallelEnumerable</code> interface, which is defined by PLINQ itself. Internally it uses [[#Task Parallel Library|TPL]] for execution.<ref name="somajune">{{cite web | url = http://blogs.msdn.com/somasegar/archive/2008/06/02/june-2008-ctp-parallel-extensions-to-the-net-fx.aspx | title = June 2008 CTP - Parallel Extensions to the .NET FX | accessdate = 2008-08-06}}</ref><ref>{{cite web | url = http://blogs.msdn.com/pfxteam/archive/2008/06/05/8576194.aspx | title = More powerful aggregations in PLINQ | accessdate = 2008-08-06}}</ref>
'''Parallel LINQ''' ('''PLINQ''') is a concurrent query execution engine for [[Language Integrated Query|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.<ref name="channel9"/> Any computation on objects that has been implemented as queries can be parallelized by PLINQ. However, the objects need to implement the <code>IParallelEnumerable</code> interface, which is defined by PLINQ itself. Internally it uses [[#Task Parallel Library|TPL]] for execution.<ref name="somajune">{{cite web | url = http://blogs.msdn.com/somasegar/archive/2008/06/02/june-2008-ctp-parallel-extensions-to-the-net-fx.aspx | title = June 2008 CTP - Parallel Extensions to the .NET FX | accessdate = 2008-08-06}}</ref><ref>{{cite web | url = http://blogs.msdn.com/pfxteam/archive/2008/06/05/8576194.aspx | title = More powerful aggregations in PLINQ | accessdate = 2008-08-06}}</ref>


==Task Parallel Library==
==TPL==
'''Task Parallel Library''' ('''TPL''') is the [[task parallelism]] component of the Parallel Extensions to .NET.<ref name="Concurrent Programming on Windows Appendix B"/> It exposes parallel constructs like parallel <code>For</code> and <code>ForEach</code> loops, using regular method calls and [[Delegate (.NET)|delegates]]. As such, the constructs can be used from any language supporting the [[.NET Framework]]. The job of spawning and terminating [[Thread (computing)|threads]], as well as scaling the number of threads according to the number of available processors, is done by the library itself.<ref name="msdnmag"/>
The '''Task Parallel Library''' ('''TPL''') is the [[task parallelism]] component of the Parallel Extensions to .NET.<ref name="Concurrent Programming on Windows Appendix B"/> It exposes parallel constructs like parallel <code>For</code> and <code>ForEach</code> loops, using regular method calls and [[Delegate (.NET)|delegates]]. As such, the constructs can be used from any language supporting the [[.NET Framework]]. The job of spawning and terminating [[Thread (computing)|threads]], as well as scaling the number of threads according to the number of available processors, is done by the library itself.<ref name="msdnmag"/>


TPL also includes other constructs such as ''Task'' and ''[[Future (programming)|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 pattern|thread pool]] when their turn comes.
TPL also includes other constructs such as ''Task'' and ''[[Future (programming)|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 pattern|thread pool]] when their turn comes.

Version vom 1. September 2009, 02:13 Uhr

Vorlage:Future software

The .NET Framework stack.

Parallel Extensions, previously known as the Parallel Framework Extensions or (PFX), is a managed concurrency library being developed by a collaboration between Microsoft Research and the CLR team at Microsoft. It is composed of two parts: Parallel LINQ (PLINQ) and Task Parallel Library (TPL).[1][2] 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.[3] The library was released as a CTP on November 29, 2007[4] and refreshed again in December 2007 and June 2008.[3] Microsoft has announced that the Parallel Extensions to .NET will release as part of the .NET 4.0 Framework release.[5]

Parallel LINQ

Vorlage:See also Parallel LINQ (PLINQ) is a concurrent query execution engine for 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.[1] 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.[3][6]

Task Parallel Library

The Task Parallel Library (TPL) is the task parallelism component of the Parallel Extensions to .NET.[7] It exposes parallel constructs like parallel For and ForEach loops, using regular method calls and delegates. As such, the constructs can be used from any language supporting the .NET Framework. 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.[2]

TPL also includes other constructs such as 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.[2] If an attempt is made to retrieve the result before it has been computed then the asking thread will block until the result is available.[8]

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. In addition, 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. Each thread, when idle, picks up a batch of Tasks, and puts on its local queue, and then executes them 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

References

Vorlage:Reflist

Vorlage:MSNav

  1. a b Programming in the Age of Concurrency: Concurrent Programming with PFX. Abgerufen am 16. Oktober 2007.
  2. a b c MSDN Magazine: Task Parallel Library. Abgerufen am 16. Oktober 2007.
  3. a b c June 2008 CTP - Parallel Extensions to the .NET FX. Abgerufen am 6. August 2008.
  4. Parallel Extensions to the .NET FX CTP. Abgerufen am 30. November 2007.
  5. Parallel Programming and the .NET Framework 4.0. Abgerufen am 25. Januar 2009.
  6. More powerful aggregations in PLINQ. Abgerufen am 6. August 2008.
  7. Referenzfehler: Ungültiges <ref>-Tag; kein Text angegeben für Einzelnachweis mit dem Namen Concurrent Programming on Windows Appendix B.
  8. Joe Duffy: Concurrent Programming on Windows. 2009, ISBN "032143482X"(?!), S. "887–929".