##// END OF EJS Templates
Final work on the Win HPC whitepaper.
Brian Granger -
Show More
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
@@ -13,5 +13,7 b' Using IPython for parallel computing'
13 13 parallel_task.txt
14 14 parallel_mpi.txt
15 15 parallel_security.txt
16 parallel_winhpc.txt
17 parallel_demos.txt
16 18
17 19
@@ -116,10 +116,10 b' using IPython by following these steps:'
116 116 1. Copy the text files with the digits of pi
117 117 (ftp://pi.super-computing.org/.2/pi200m/) to the working directory of the
118 118 engines on the compute nodes.
119 2. Use :command:`ipcluster` to start 15 engines. We used an 8 core cluster
120 with hyperthreading enabled which makes the 8 cores looks like 16 (1
121 controller + 15 engines) in the OS. However, the maximum speedup we can
122 observe is still only 8x.
119 2. Use :command:`ipcluster` to start 15 engines. We used an 8 core (2 quad
120 core CPUs) cluster with hyperthreading enabled which makes the 8 cores
121 looks like 16 (1 controller + 15 engines) in the OS. However, the maximum
122 speedup we can observe is still only 8x.
123 123 3. With the file :file:`parallelpi.py` in your current working directory, open
124 124 up IPython in pylab mode and type ``run parallelpi.py``.
125 125
@@ -136,7 +136,9 b' calculation can also be run by simply typing the commands from'
136 136 In [1]: from IPython.kernel import client
137 137 2009-11-19 11:32:38-0800 [-] Log opened.
138 138
139 # The MultiEngineClient allows us to use the engines interactively
139 # The MultiEngineClient allows us to use the engines interactively.
140 # We simply pass MultiEngineClient the name of the cluster profile we
141 # are using.
140 142 In [2]: mec = client.MultiEngineClient(profile='mycluster')
141 143 2009-11-19 11:32:44-0800 [-] Connecting [0]
142 144 2009-11-19 11:32:44-0800 [Negotiation,client] Connected: ./ipcontroller-mec.furl
@@ -148,6 +150,7 b' calculation can also be run by simply typing the commands from'
148 150
149 151 In [5]: filestring = 'pi200m-ascii-%(i)02dof20.txt'
150 152
153 # Create the list of files to process.
151 154 In [6]: files = [filestring % {'i':i} for i in range(1,16)]
152 155
153 156 In [7]: files
@@ -190,18 +193,6 b' compared to the 10,000 digit calculation.'
190 193
191 194 .. image:: two_digit_counts.*
192 195
193 To conclude this example, we summarize the key features of IPython's parallel
194 architecture that this example demonstrates:
195
196 * Serial code can be parallelized often with only a few extra lines of code.
197 In this case we have used :meth:`MultiEngineClient.map`; the
198 :class:`MultiEngineClient` class has a number of other methods that provide
199 more fine grained control of the IPython cluster.
200 * The resulting parallel code can be run without ever leaving the IPython's
201 interactive shell.
202 * Any data computed in parallel can be explored interactively through
203 visualization or further numerical calculations.
204
205 196
206 197 Parallel options pricing
207 198 ========================
@@ -217,33 +208,34 b' purposes: hedging against risk, speculation, etc.'
217 208 Much of modern finance is driven by the need to price these contracts
218 209 accurately based on what is known about the properties (such as volatility) of
219 210 the underlying asset. One method of pricing options is to use a Monte Carlo
220 simulation of the underlying assets. In this example we use this approach to
221 price both European and Asian (path dependent) options for various strike
211 simulation of the underlying asset price. In this example we use this approach
212 to price both European and Asian (path dependent) options for various strike
222 213 prices and volatilities.
223 214
224 215 The code for this example can be found in the :file:`docs/examples/kernel`
225 directory of the IPython source.
226
227 The function :func:`price_options`, calculates the option prices for a single
228 option (:file:`mcpricer.py`):
216 directory of the IPython source. The function :func:`price_options` in
217 :file:`mcpricer.py` implements the basic Monte Carlo pricing algorithm using
218 the NumPy package and is shown here:
229 219
230 220 .. literalinclude:: ../../examples/kernel/mcpricer.py
231 221 :language: python
232 222
233 To run this code in parallel, we will use IPython's :class:`TaskClient`, which
234 distributes work to the engines using dynamic load balancing. This client
235 can be used along side the :class:`MultiEngineClient` shown in the previous
236 example.
237
238 Here is the code that calls :func:`price_options` for a number of different
239 volatilities and strike prices in parallel:
223 To run this code in parallel, we will use IPython's :class:`TaskClient` class,
224 which distributes work to the engines using dynamic load balancing. This
225 client can be used along side the :class:`MultiEngineClient` class shown in
226 the previous example. The parallel calculation using :class:`TaskClient` can
227 be found in the file :file:`mcpricer.py`. The code in this file creates a
228 :class:`TaskClient` instance and then submits a set of tasks using
229 :meth:`TaskClient.run` that calculate the option prices for different
230 volatilities and strike prices. The results are then plotted as a 2D contour
231 plot using Matplotlib.
240 232
241 233 .. literalinclude:: ../../examples/kernel/mcdriver.py
242 234 :language: python
243 235
244 To run this code in parallel, start an IPython cluster using
245 :command:`ipcluster`, open IPython in the pylab mode with the file
246 :file:`mcdriver.py` in your current working directory and then type:
236 To use this code, start an IPython cluster using :command:`ipcluster`, open
237 IPython in the pylab mode with the file :file:`mcdriver.py` in your current
238 working directory and then type:
247 239
248 240 .. sourcecode:: ipython
249 241
@@ -252,7 +244,7 b' To run this code in parallel, start an IPython cluster using'
252 244
253 245 Once all the tasks have finished, the results can be plotted using the
254 246 :func:`plot_options` function. Here we make contour plots of the Asian
255 call and Asian put as function of the volatility and strike price:
247 call and Asian put options as function of the volatility and strike price:
256 248
257 249 .. sourcecode:: ipython
258 250
@@ -263,8 +255,28 b' call and Asian put as function of the volatility and strike price:'
263 255
264 256 In [10]: plot_options(sigma_vals, K_vals, prices['aput'])
265 257
266 The plots generated by Matplotlib will look like this:
258 These results are shown in the two figures below. On a 8 core cluster the
259 entire calculation (10 strike prices, 10 volatilities, 100,000 paths for each)
260 took 30 seconds in parallel, giving a speedup of 7.7x, which is comparable
261 to the speedup observed in our previous example.
267 262
268 263 .. image:: asian_call.*
269 264
270 265 .. image:: asian_put.*
266
267 Conclusion
268 ==========
269
270 To conclude these examples, we summarize the key features of IPython's
271 parallel architecture that have been demonstrated:
272
273 * Serial code can be parallelized often with only a few extra lines of code.
274 We have used the :class:`MultiEngineClient` and :class:`TaskClient` classes
275 for this purpose.
276 * The resulting parallel code can be run without ever leaving the IPython's
277 interactive shell.
278 * Any data computed in parallel can be explored interactively through
279 visualization or further numerical calculations.
280 * We have run these examples on a cluster running Windows HPC Server 2008.
281 IPython's built in support for the Windows HPC job scheduler makes it
282 easy to get started with IPython's parallel capabilities.
@@ -1,18 +1,19 b''
1 ========================================
2 Getting started
3 ========================================
1 ============================================
2 Getting started with Windows HPC Server 2008
3 ============================================
4 4
5 5 Introduction
6 6 ============
7 7
8 The Python programming language is increasingly popular language for numerical
9 computing. This is due to a unique combination of factors. First, Python is a
10 high-level and *interactive* language that is well matched for interactive
11 numerical work. Second, it is easy (often times trivial) to integrate legacy
12 C/C++/Fortran code into Python. Third, a large number of high-quality open
13 source projects provide all the needed building blocks for numerical
14 computing: numerical arrays (NumPy), algorithms (SciPy), 2D/3D Visualization
15 (Matplotlib, Mayavi, Chaco), Symbolic Mathematics (Sage, Sympy) and others.
8 The Python programming language is an increasingly popular language for
9 numerical computing. This is due to a unique combination of factors. First,
10 Python is a high-level and *interactive* language that is well matched to
11 interactive numerical work. Second, it is easy (often times trivial) to
12 integrate legacy C/C++/Fortran code into Python. Third, a large number of
13 high-quality open source projects provide all the needed building blocks for
14 numerical computing: numerical arrays (NumPy), algorithms (SciPy), 2D/3D
15 Visualization (Matplotlib, Mayavi, Chaco), Symbolic Mathematics (Sage, Sympy)
16 and others.
16 17
17 18 The IPython project is a core part of this open-source toolchain and is
18 19 focused on creating a comprehensive environment for interactive and
General Comments 0
You need to be logged in to leave comments. Login now