【实例简介】Python Parallel Programming Cookbook
【实例截图】










【核心代码】
Table of Contents
Preface
v
Chapter 1: Getting Started with Parallel Computing and Python
1
Introduction
2
The parallel computing memory architecture
3
Memory organization
6
Parallel programming models
14
How to design a parallel program
16
How to evaluate the performance of a parallel program
19
Introducing Python
21
Python in a parallel world
26
Introducing processes and threads
26
Start working with processes in Python
27
Start working with threads in Python
29
Chapter 2: Thread-based Parallelism
33
Introduction
34
Using the Python threading module
35
How to define a thread
35
How to determine the current thread
37
How to use a thread in a subclass
39
Thread synchronization with Lock and RLock
41
Thread synchronization with RLock
45
Thread synchronization with semaphores
48
Thread synchronization with a condition
52
Thread synchronization with an event
55
Using the with statement
59
Thread communication using a queue
62
Evaluating the performance of multithread applications
66
www.allitebooks.comii
Table of Contents
Chapter 3: Process-based Parallelism
73
Introduction
74
How to spawn a process
75
How to name a process
77
How to run a process in the background
79
How to kill a process
81
How to use a process in a subclass
82
How to exchange objects between processes
84
How to synchronize processes
90
How to manage a state between processes
93
How to use a process pool
95
Using the mpi4py Python module
97
Point-to-point communication
101
Avoiding deadlock problems
104
Collective communication using broadcast
108
Collective communication using scatter
110
Collective communication using gather
114
Collective communication using Alltoall
116
The reduction operation
118
How to optimize communication
120
Chapter 4: Asynchronous Programming
127
Introduction
127
Using the concurrent.futures Python modules
128
Event loop management with Asyncio
134
Handling coroutines with Asyncio
138
Task manipulation with Asyncio
143
Dealing with Asyncio and Futures
147
Chapter 5: Distributed Python
151
Introduction
151
Using Celery to distribute tasks
152
How to create a task with Celery
154
Scientific computing with SCOOP
158
Handling map functions with SCOOP
163
Remote Method Invocation with Pyro4
167
Chaining objects with Pyro4
171
Developing a client-server application with Pyro4
177
Communicating sequential processes with PyCSP
184
Using MapReduce with Disco
190
A remote procedure call with RPyC
195iii
Table of Contents
Chapter 6: GPU Programming with Python
199
Introduction
200
Using the PyCUDA module
201
How to build a PyCUDA application
207
Understanding the PyCUDA memory model with matrix manipulation
212
Kernel invocations with GPUArray
218
Evaluating element-wise expressions with PyCUDA
220
The MapReduce operation with PyCUDA
225
GPU programming with NumbaPro
229
Using GPU-accelerated libraries with NumbaPro
234
Using the PyOpenCL module
240
How to build a PyOpenCL application
243
Evaluating element-wise expressions with PyOpenCl
248
Testing your GPU application with PyOpenCL
251
Index
257
网友评论
我要评论