logo资料库

Python Parallel Programming Cookbook 无水印pdf.pdf

第1页 / 共286页
第2页 / 共286页
第3页 / 共286页
第4页 / 共286页
第5页 / 共286页
第6页 / 共286页
第7页 / 共286页
第8页 / 共286页
资料共286页,剩余部分请下载后查看
Cover
Copyright
Credits
About the Author
About the Reviewers
www.PacktPub.com
Table of Contents
Preface
1: Getting Started with Parallel Computing and Python
Introduction
The parallel computing memory architecture
Memory organization
Parallel programming models
How to design a parallel program
How to evaluate the performance of a parallel program
Introducing Python
Python in a parallel world
Introducing processes and threads
Start working with processes in Python
Start working with threads in Python
2: Thread-based Parallelism
Introduction
Using the Python threading module
How to define a thread
How to determine the current thread
How to use a thread in a subclass
Thread synchronization with Lock and RLock
Thread synchronization with RLock
Thread synchronization with semaphores
Thread synchronization with a condition
Threads synchronization with an event
Using the with statement
Thread communication using a queue
Evaluating the performance of multithread applications
3: Process-based Parallelism
Introduction
How to spawn a process
How to name a process
How to run a process in the background
How to kill a process
How to use process in a subclass
How to exchange objects between processes
How to synchronize processes
How to manage a state between processes
How to use a process pool
Using the mpi4py Python module
Point-to-point communication
Avoiding deadlock problems
Collective communication using broadcast
Collective communication using scatter
Collective communication using gather
Collective communication using Alltoall
The reduction operation
How to optimize the communication
4: Asynchronous Programming
Introduction
Using the concurrent.futures Python modules
Event loop management with Asyncio
Handling coroutines with Asyncio
Task manipulation with Asyncio
Dealing with Asyncio and Futures
5: Distributed Python
Introduction
Using Celery to distribute tasks
How to create a task with Celery
Scientific computing with SCOOP
Handling map functions with SCOOP
Remote Method Invocation with Pyro4
Chaining objects with Pyro4
Developing a client-server application with Pyro4
Communicating sequential processes with PyCSP
Using MapReduce with Disco
A remote procedure call with RPyC
6: GPU Programming with Python
Introduction
Using the PyCUDA module
How to build a PyCUDA application
Understanding the PyCuda memory model with matrix manipulation
Kernel invocations with GPUArray
Evaluating element-wise expressions with PyCUDA
The MapReduce operation with PyCuda
GPU programming with NumbaPro
Using GPU-accelerated libraries with NumbaPro
Using the PyOpenCL module
How to build a PyOpenCL application
Evaluating element-wise expressions with PyOpenCl
Testing your GPU application with PyOpenCL
Index
Python Parallel Programming Cookbook Master efficient parallel programming to build powerful applications using Python Giancarlo Zaccone BIRMINGHAM - MUMBAI
Python Parallel Programming Cookbook Copyright © 2015 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: August 2015 Production reference: 1210815 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78528-958-3 www.packtpub.com
Credits Author Giancarlo Zaccone Project Coordinator Judie Jose Reviewers Aditya Avinash Ravi Chityala Mike Galloy Ludovic Gasc Commissioning Editor Sarah Crofton Acquisition Editor Meeta Rajani Proofreader Safis Editing Indexer Mariammal Chettiyar Graphics Sheetal Aute Disha Haria Jason Monterio Abhinash Sahu Content Development Editor Production Coordinator Rashmi Suvarna Conidon Miranda Technical Editor Mrunmayee Patil Copy Editor Neha Vyas Cover Work Conidon Miranda
About the Author Giancarlo Zaccone has more than 10 years of experience in managing research projects, both in scientific and industrial domains. He worked as a researcher at the National Research Council (CNR), where he was involved in a few parallel numerical computing and scientific visualization projects. He currently works as a software engineer at a consulting company, developing and maintaining software systems for space and defense applications. Giancarlo holds a master's degree in physics from the University of Naples Federico II and has completed a second-level postgraduate master's program in scientific computing from the Sapienza University of Rome. You can know more about him at https://it.linkedin.com/in/giancarlozaccone.
About the Reviewers Aditya Avinash is a graduate student who focuses on computer graphics and GPUs. His areas of interest are compilers, drivers, physically based rendering, and real-time rendering. His current focus is on making a contribution to MESA (the open source graphics driver stack for Linux), where he will implement OpenGL extensions for the AMD backend. This is something that he is really excited about. He also likes writing compilers to translate high- level abstraction code into GPU code. He has developed Urutu, which gives GPUs thread- level parallelism with Python. For this, NVIDIA funded him with a couple of Tesla K40 GPUs. Currently, he is working on RockChuck, translating the Python code (written using data parallel abstraction) into GPU/CPU code, depending on the available backend. This project was started after he reviewed the opinions of a lot of Python programmers who wanted data parallel abstraction for Python and GPUs. He has a computer engineering background, where he designed hardware and software to fit certain applications (ASIC). From this, he gained experience of how to use FPGAs and HDLs. Apart from this, he mainly programs using Python and C++. In C++, he uses OpenGL, CUDA, OpenCL, and other multicore programming APIs. Since he is a student, most of his work is not affiliated with any institution or person. Ravi Chityala is a senior engineer at Elekta Inc. He has more than 12 years of experience in image processing and scientific computing. He is also a part time instructor at the University of California, Santa Cruz Extension, San Jose, CA, where he teaches advanced Python to programmers. He began using Python as a scripting tool and fell in love with the language's simplicity, power, and expressiveness. He now uses it for web development, scientific prototyping and computing, and he uses it as a glue to automate the process. He combined his experience in image processing and his love for Python and coauthored the book Image Acquisition and Processing using Python, published by CRC Press.
Mike Galloy is a software developer who focuses on high-performance computing and visualization in scientific programming. He works mostly on IDL, but occasionally uses C, CUDA, and Python. He currently works for the National Center for Atmospheric Research (NCAR) at the Mauna Loa Solar Observatory. Previously, he worked for Tech-X Corporation, where he was the main developer for GPULib, a library of IDL bindings for GPU-accelerated computation routines. He is the creator and main developer of the open source projects, IDLdoc, mgunit, and rIDL, as well as the author of the book Modern IDL. Ludovic Gasc is a senior software developer and engineer at Eyepea and ALLOcloud, a highly renowned open source VoIP and unified communications company in Europe. Over the last 5 years, he has developed redundant distributed systems for the telecom sector that are based on Python, AsyncIO, PostgreSQL, and Redis. You can contact him on his blog at http://www.gmludo.eu. He is also the creator of the blog API-Hour: Write efficient network daemons (HTTP, SSH) with ease. For more information, visit http://www.api-hour.io.
www.PacktPub.com Support files, eBooks, discount offers, and more For support files and downloads related to your book, please visit www.PacktPub.com. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. TM https://www2.packtpub.com/books/subscription/packtlib Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books. Why Subscribe? f Fully searchable across every book published by Packt f Copy and paste, print, and bookmark content f On demand and accessible via a web browser Free Access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.
分享到:
收藏