Escolar Documentos
Profissional Documentos
Cultura Documentos
Interactive and
Collaborative
Parallel Computing
B r i a n E . G r a n g e r
S a n t a C l a r a U n i v e r s i t y
F e r n a n d o P e r e z
U n i v e r s i t y o f C o l o r a d o
A n d r e w G i u s t i n i
S a n t a C l a r a U n i v e r s i t y
The Challenge
Hardware
Cheap, fast and widely available.
Our free lunch is over -> Single CPUs aren’t getting much faster.
Transition to multi-CPU and multi-core CPU based machines.
Clusters and grids.
Software
Software development is labor intensive.
Development of parallel codes is very labor intensive.
Parallel programming tools and paradigms have not evolved much
in the last 2 decades.
Python
Kernel Kernel
- Objects
- Commands Kernel Kernel
IPython Session
In [1]: Kernel Kernel
Authenticate users
In [3]: ic.start(16)
# Start 16 kernels
...do interactive parallel calculations...
In[56]: ic.start(16)
# Start 16 more kernels
...do more calculations...
In[97]: ic.save("mycluster")
# Save the cluster to a file
...turn off laptop, go home, eat dinner, resume...
In [2]: ic = InteractiveCluster()
In [3]: ic.load(“mycluster”)
#Reload cluster from a file
...do interactive parallel calculations with ic1...
...work with both simultaneously...
In [101]: ic3.remove(45)
# Removes a dead kernel
In [150]: ic3.reset()
# Resets a running kernel
In [151]: ic3.kill()
# Kill a running kernel
Sending Python Commands
execute(): execute command on kernels
In [4]: ic.execute("a = 5")
# Execute a = 5 on all
...Can also select a kernel using a list/array syntax...
In [16]: q = sin(a)
In [17]: p = sin(b)
In [18]: %autopx
Auto Parallel Disabled
In [36]: ic.push("x",2.4,kernels=[0,1,2,3])
# Only to a subset
In [7]: ic['a']
# ic.pull(‘a’)
Out[7]: [20, 20, 20, 20, 20, 20, 20, 20, 20, 20]
In [9]: ic[0]['b']
# ic.pull(‘b’,kernels=[0])
Out[9]: 100.0
In [12]: ic['mylist']
Out[12]:
[[0, 1],[2, 3],[4, 5],[6, 7],[8, 9],[10, 11],[12, 13],[14, 15],
[16, 17],[18, 19]]
In [16]: ic.pull('a',flatten=True)
Out[16]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Parallel Functions
Parallel functions: instant trivial parallelization
In [5]: psin = ic.parallelize('sin')
# psin is a ParallelFunction
In [6]: psin(range(100))
# [sin(0),sin(1),...,sin(99)]
Out[6]:
[0.0,0.8414709848078965,...]
...once a ParallelFunction has been created, it can be reused...
In [30]: ic.push_module(mymodule)
# Send to kernels
...Can now use mymodule on the kernels...
...This calls MPI_Send() on 0 and MPI_Recv() on 1...
...Automatic synchronization...
Other Future Directions
Collaborative visualization/plotting/GUI control
Other network interfaces (web, ssh)
Notebook-like frontend (like Mathematica)
Integration into other cluster environments (PBS,
Condor, GridEngine, Globus)
Scalability + Performance
Security
Full MPI integration
Other high-level parallel constructs
Distribution
The system is open source (BSD) and is part of the IPython
project:
http://ipython.scipy.org
IPython is the de facto shell for interactive scientific computing
in Python and comes with every major Linux distribution.
The kernel will become the foundation of a new version of
IPython.
The working prototype is publicly available on the IPython
subversion repository:
svn co http://ipython.scipy.org/svn/ipython/ipython/branches/chainsaw ipython1
Conclusion
Python is a useful tool in scientific
computation.