Python and Parallelism

AMΛογισμικό & κατασκευή λογ/κού

30 Νοε 2011 (πριν από 5 χρόνια και 8 μήνες)

916 εμφανίσεις

Introduction
Python and Parallelism
Summary
Python and Parallelism
Zuzanna Krawczyk
1
krawczyz@iem.pw.edu.pl
1
Warsaw University of Technology
Faculty of Electrical Engineering
November 17 2011
Zuzanna Krawczyk
Python and Parallelism 1/17
Introduction
Python and Parallelism
Summary
Outline
1
Introduction
What does Parallelism mean?
Why Parallelism in Python?
2
Python and Parallelism
MPI implementation
Code example
Efficiency and speed
3
Summary
Zuzanna Krawczyk
Python and Parallelism 2/17
Introduction
Python and Parallelism
Summary
What Parallelism mean?
Why Parallelism in Python?
Why Parallelism
Why?
Increasing demand on processing big amount of data
Limitations of increasing clock rate
Parallelism as cheaper and more available solution
Increase of network connection speed
Where?
Scientific computations - climate simulation,
electro-magnetic simulation,chemical reactions...
Commercial applications - media broadcast,huge data
bases...
home computer computations
Zuzanna Krawczyk
Python and Parallelism 3/17
Introduction
Python and Parallelism
Summary
What Parallelism mean?
Why Parallelism in Python?
Types of Parallel Programming
Zuzanna Krawczyk
Python and Parallelism 4/17
Introduction
Python and Parallelism
Summary
What Parallelism mean?
Why Parallelism in Python?
Python - A bit of history
General-purpose,high-level,intepreted,dynamic typing
Created in 1991 by Guido Van Rossum
Allows multiple programming paradigms
imperative (object-oriented,procedural)
supports functional programming
reflective
Very wide area of usage
scripting language for web applications (CGI,WSGI)
scientific computing
artificial intelligence
embedded as scripting language in many applications
system tools and other applications e.g.mercurial
Zuzanna Krawczyk
Python and Parallelism 5/17
Introduction
Python and Parallelism
Summary
What Parallelism mean?
Why Parallelism in Python?
Why Parallelismin Python?
Used in areas where Parallel programmes are required
Make execution on heterogeneous environments easier
Shorter and more elegant code
Object-oriented
Zuzanna Krawczyk
Python and Parallelism 6/17
Introduction
Python and Parallelism
Summary
MPI implementation
Code example
Efficiency and speed
MPI – Message Passing Interface
Message Passing Interface
Library specification
Proposed as a standard
Suited to distributed memory
Rich library of functions
Point to point communication
Group communication
Process grouping (communicators)
Public domain code
Well documented
Zuzanna Krawczyk
Python and Parallelism 7/17
Introduction
Python and Parallelism
Summary
MPI implementation
Code example
Efficiency and speed
MPI implementations for Python
Pypar
pyMPI
Scientific Python
mpi4py
Zuzanna Krawczyk
Python and Parallelism 8/17
Introduction
Python and Parallelism
Summary
MPI implementation
Code example
Efficiency and speed
MPI and Python are simple
(Almost) All we need to know about MPI...
MPI – Python module
MPI.Comm – Python object representing global
communicator
Get_rank(self)
Get_size(self)
send(self,obj=None,int dest=0,int tag=0)
recv(self,obj=None,int source=0,int tag=0,Status
status=None)
Zuzanna Krawczyk
Python and Parallelism 9/17
Introduction
Python and Parallelism
Summary
MPI implementation
Code example
Efficiency and speed
Group communication
Zuzanna Krawczyk
Python and Parallelism 10/17
Introduction
Python and Parallelism
Summary
MPI implementation
Code example
Efficiency and speed
MPI code:Python vs.C
Zuzanna Krawczyk
Python and Parallelism 11/17
Introduction
Python and Parallelism
Summary
MPI implementation
Code example
Efficiency and speed
Calculating PI via numerical integration
Z
1
0
1
1 +x
2
dx = atan(1) atan(0) =

4
We are counting:
Z
1
0
4
1 +x
2
dx
Zuzanna Krawczyk
Python and Parallelism 12/17
Introduction
Python and Parallelism
Summary
MPI implementation
Code example
Efficiency and speed
Speed-up in relation to number of Processors
Execution time on 8-processors machine
Comparison of execution time
Nr of Processors
Total time [s]
2
110.729322433
4
58.6123695374
6
39.7080996037
8
29.59043264393
Zuzanna Krawczyk
Python and Parallelism 13/17
Introduction
Python and Parallelism
Summary
MPI implementation
Code example
Efficiency and speed
We have to choose - elegance or speed.
Comparison of execution time
Language
Nr of Processors
Total time [s]
C
2
1.05173
Python
2
110.729322433
C
8
0.273723
Python
8
29.59043264393
C is...
29:59043264393
0:273723
= 108:10 faster!
Zuzanna Krawczyk
Python and Parallelism 14/17
Introduction
Python and Parallelism
Summary
MPI implementation
Code example
Efficiency and speed
Another Parallel libraries
PVM implementation
pypvm
pynpvm (for NumPy)
GPU computations
PyCUDA
0MQ
Google App Engine
and much more...
Zuzanna Krawczyk
Python and Parallelism 15/17
Introduction
Python and Parallelism
Summary
Summary
There is a lot of possibilities to write parallel code in Python
Python MPI code looks more readable than C/Fortran code
Python code is portable between different heterogenous
nodes of system
Question:Can we obtain sufficient speed with Python?
Zuzanna Krawczyk
Python and Parallelism 16/17
Introduction
Python and Parallelism
Summary
Bibliography
I.Foster:Designing and Building Parallel Programs
http://wiki.python.org/moin/ParallelProcessing
http://mpi4py.scipy.org/
Zuzanna Krawczyk
Python and Parallelism 17/17