文档介绍:A Tutorial on Parallel and Concurrent
Programming in Haskell
Simon Peyton Jones and Satnam Singh
Microsoft Research Cambridge
simonpj@ satnams@
Abstract. This practical tutorial introduces the features available in
Haskell for writing parallel and concurrent programs. We first describe
how to write semi-explicit parallel programs by using annotations to ex-
press opportunities for parallelism and to help control the granularity of
parallelism for effective execution on modern operating systems and pro-
cessors. We then describe the mechanisms provided by Haskell for writing
explicitly parallel programs with a focus on the use of software transac-
tional memory to help share information between threads. Finally, we
show how nested data parallelism can be used to write deterministically
parallel programs which allows programmers to use rich data types in
data parallel programs which are automatically transformed into flat
data parallel versions for efficient execution on multi-core processors.
1 Introduction
The introduction of multi-core processors has renewed interest in parallel func-
tional programming and there are now several interesting projects that explore
the advantages of a functional language for writing parallel code or implicitly par-
alellizing code written in a pure functional language. These lecture notes present
a variety of techniques for writing concurrent parallel programs which include
existing techniques based on semi-implicit parallelism and explicit thread-based
parallelism as well as more recent developments in the areas of software trans-
actional memory and nested data parallelism.
We also use the terms parallel and concurrent with quite specific meanings.
A parallel program is one which is written for performance reasons to exploit
the potential of a real puting resource like a multi-core processor.
For a parallel program we have the expectation of some genuinely simultaneous
execution. Concurrency