{ "metadata": { "name": "InteractiveMPI" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": { "slideshow": { "slide_start": false } }, "source": [ "Interactive monitoring of a parallel MPI simulation with the IPython Notebook" ] }, { "cell_type": "code", "collapsed": false, "input": [ "%pylab inline\n", "from IPython.parallel import Client, error\n", "cluster = Client(profile=\"mpi\")\n", "view = cluster[:]\n", "view.block = True" ], "language": "python", "metadata": { "slideshow": { "slide_start": false } }, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "\n", "Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.kernel.zmq.pylab.backend_inline].\n", "For more information, type 'help(pylab)'.\n" ] } ], "prompt_number": 12 }, { "cell_type": "code", "collapsed": false, "input": [ "cluster.ids" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 13, "text": [ "[0, 1, 2, 3]" ] } ], "prompt_number": 13 }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_start": false } }, "source": [ "Now, we load the MPI libraries into the engine namespaces, and do a simple printing of their MPI rank information to verify that all nodes are operational and they match our cluster's real capacity. \n", "\n", "Here, we are making use of IPython's special `%%px` cell magic, which marks the entire cell for parallel execution. This means that the code below will not run in this notebook's kernel, but instead will be sent to *all* engines for execution there. In this way, IPython makes it very natural to control your entire cluster from within the notebook environment:" ] }, { "cell_type": "code", "collapsed": false, "input": [ "%%px\n", "# MPI initialization, library imports and sanity checks on all engines\n", "from mpi4py import MPI\n", "import numpy as np\n", "import time\n", "\n", "mpi = MPI.COMM_WORLD\n", "bcast = mpi.bcast\n", "barrier = mpi.barrier\n", "rank = mpi.rank\n", "print \"MPI rank: %i/%i\" % (mpi.rank,mpi.size)" ], "language": "python", "metadata": { "slideshow": { "slide_start": false } }, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "[stdout:0] MPI rank: 3/4\n", "[stdout:1] MPI rank: 2/4\n", "[stdout:2] MPI rank: 0/4\n", "[stdout:3] MPI rank: 1/4\n" ] } ], "prompt_number": 14 }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_start": false } }, "source": [ "We write a utility that reorders a list according to the mpi ranks of the engines, since all gather operations will return data in engine id order, not in MPI rank order. We'll need this later on when we want to reassemble in IPython data structures coming from all the engines: IPython will collect the data ordered by engine ID, but our code creates data structures based on MPI rank, so we need to map from one indexing scheme to the other. This simple function does the job:" ] }, { "cell_type": "code", "collapsed": false, "input": [ "ranks = view['rank']\n", "rank_indices = np.argsort(ranks)\n", "\n", "def mpi_order(seq):\n", " \"\"\"Return elements of a sequence ordered by MPI rank.\n", "\n", " The input sequence is assumed to be ordered by engine ID.\"\"\"\n", " return [seq[x] for x in rank_indices]" ], "language": "python", "metadata": { "slideshow": { "slide_start": false } }, "outputs": [], "prompt_number": 15 }, { "cell_type": "heading", "level": 2, "metadata": { "slideshow": { "slide_start": false } }, "source": [ "MPI simulation example" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_start": false } }, "source": [ "This is our 'simulation', a toy example that computes $\\sin(f(x^2+y^2))$ for a slowly increasing frequency $f$ over a gradually refined mesh. In a real-world example, there typically is a 'simulate' method that, afer setting up initial parameters, runs the entire computation. But having this simple example will be sufficient to see something that changes visually as the computation evolves and that is quick enough for us to test.\n", "\n", "And while simple, this example has a realistic decomposition of the spatial domain in one array per MPI node that requires care in reordering the data for visualization, as would be needed in a real-world application (unless your code accumulates data in the rank 0 node that you can grab directly)." ] }, { "cell_type": "code", "collapsed": false, "input": [ "%%px\n", "\n", "stop = False\n", "nsteps = 100\n", "delay = 0.1\n", "\n", "xmin, xmax = 0, np.pi\n", "ymin, ymax = 0, 2*np.pi\n", "dy = (ymax-ymin)/mpi.size\n", "\n", "def simulation():\n", " \"\"\"Toy simulation code, computes sin(f*(x**2+y**2)) for a slowly increasing f\n", " over an increasingly fine mesh.\n", "\n", " The purpose of this code is simply to illustrate the basic features of a typical\n", " MPI code: spatial domain decomposition, a solution which is evolving in some \n", " sense, and local per-node computation. In this case the nodes don't really\n", " communicate at all.\n", " \"\"\"\n", " # By making these few variables global, we allow the IPython client to access them\n", " # remotely for interactive introspection\n", " global j, Z, nx, nyt\n", " freqs = np.linspace(0.6, 1, nsteps)\n", " for j in range(nsteps):\n", " nx, ny = 2+j/4, 2+j/2/mpi.size\n", " nyt = mpi.size*ny\n", " Xax = np.linspace(xmin, xmax, nx)\n", " Yax = np.linspace(ymin+rank*dy, ymin+(rank+1)*dy, ny, endpoint=rank==mpi.size)\n", " X, Y = np.meshgrid(Xax, Yax)\n", " f = freqs[j]\n", " Z = np.cos(f*(X**2 + Y**2))\n", " # We add a small delay to simulate that a real-world computation\n", " # would take much longer, and we ensure all nodes are synchronized\n", " time.sleep(delay)\n", " # The stop flag can be set remotely via IPython, allowing the simulation to be\n", " # cleanly stopped from the outside\n", " if stop:\n", " break" ], "language": "python", "metadata": { "slideshow": { "slide_start": false } }, "outputs": [], "prompt_number": 17 }, { "cell_type": "heading", "level": 2, "metadata": { "slideshow": { "slide_start": false } }, "source": [ "IPython tools to interactively monitor and plot the MPI results" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_start": false } }, "source": [ "We now define a local (to this notebook) plotting function that fetches data from the engines' global namespace. Once it has retrieved the current state of the relevant variables, it produces and returns a figure:" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from IPython.display import clear_output\n", "\n", "def plot_current_results(in_place=True):\n", " \"\"\"Makes a blocking call to retrieve remote data and displays the solution mesh\n", " as a contour plot.\n", " \n", " Parameters\n", " ----------\n", " in_place : bool\n", " By default it calls clear_output so that new plots replace old ones. Set\n", " to False to allow keeping of all previous outputs.\n", " \"\"\"\n", " \n", " # We make a blocking call to load the remote data from the simulation into simple named \n", " # variables we can read from the engine namespaces\n", " #view.apply_sync(load_simulation_globals)\n", " # And now we can use the view to read these variables from all the engines. Then we\n", " # concatenate all of them into single arrays for local plotting\n", " try:\n", " Z = np.concatenate(mpi_order(view['Z']))\n", " except ValueError:\n", " print \"dimension mismatch in Z, not plotting\"\n", " ax = plt.gca()\n", " return ax.figure\n", " \n", " nx, nyt, j, nsteps = view.pull(['nx', 'nyt', 'j', 'nsteps'], targets=0)\n", " fig, ax = plt.subplots()\n", " ax.contourf(Z)\n", " ax.set_title('Mesh: %i x %i, step %i/%i' % (nx, nyt, j+1, nsteps))\n", " axis('off')\n", " # We clear the notebook output before plotting this if in-place plot updating is requested\n", " if in_place:\n", " clear_output()\n", " display(fig)\n", " return fig" ], "language": "python", "metadata": { "slideshow": { "slide_start": false } }, "outputs": [], "prompt_number": 18 }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_start": false } }, "source": [ "It will also be useful to be able to check whether the simulation is still alive or not. Below we will wrap the main simulation function into a thread to allow IPython to pull data from the engines, and we will call this object `simulation_thread`. So to check whether the code is still running, all we have to do is call the `is_alive` method on all of our engines and see whether any of them returns True:" ] }, { "cell_type": "code", "collapsed": false, "input": [ "def simulation_alive():\n", " \"\"\"Return True if the simulation thread is still running on any engine.\n", " \"\"\"\n", " return any(view.apply_sync(lambda : simulation_thread.is_alive()))" ], "language": "python", "metadata": { "slideshow": { "slide_start": false } }, "outputs": [], "prompt_number": 19 }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_start": false } }, "source": [ "Finally, this is a convenience wrapper around the plotting code so that we can interrupt monitoring at any point, and that will provide basic timing information:" ] }, { "cell_type": "code", "collapsed": false, "input": [ "def monitor_simulation(refresh=5.0, plots_in_place=True):\n", " \"\"\"Monitor the simulation progress and call plotting routine.\n", "\n", " Supress KeyboardInterrupt exception if interrupted, ensure that the last \n", " figure is always displayed and provide basic timing and simulation status.\n", "\n", " Parameters\n", " ----------\n", " refresh : float\n", " Refresh interval between calls to retrieve and plot data. The default\n", " is 5s, adjust depending on the desired refresh rate, but be aware that \n", " very short intervals will start having a significant impact.\n", "\n", " plots_in_place : bool\n", " If true, every new figure replaces the last one, producing a (slow)\n", " animation effect in the notebook. If false, all frames are plotted\n", " in sequence and appended in the output area.\n", " \"\"\"\n", " import datetime as dt, time\n", " \n", " if not simulation_alive():\n", " plot_current_results(in_place=plots_in_place)\n", " plt.close('all')\n", " print 'Simulation has already finished, no monitoring to do.'\n", " return\n", " \n", " t0 = dt.datetime.now()\n", " fig = None\n", " try:\n", " while simulation_alive():\n", " fig = plot_current_results(in_place=plots_in_place)\n", " plt.close('all') # prevent re-plot of old figures\n", " time.sleep(refresh) # so we don't hammer the server too fast\n", " except (KeyboardInterrupt, error.TimeoutError):\n", " msg = 'Monitoring interrupted, simulation is ongoing!'\n", " else:\n", " msg = 'Simulation completed!'\n", " tmon = dt.datetime.now() - t0\n", " if plots_in_place and fig is not None:\n", " clear_output()\n", " plt.close('all')\n", " display(fig)\n", " print msg\n", " print 'Monitored for: %s.' % tmon" ], "language": "python", "metadata": { "slideshow": { "slide_start": false } }, "outputs": [], "prompt_number": 20 }, { "cell_type": "heading", "level": 2, "metadata": { "slideshow": { "slide_start": false } }, "source": [ "Making a simulation object that can be monitored interactively" ] }, { "cell_type": "code", "collapsed": false, "input": [ "%%px\n", "from threading import Thread\n", "stop = False\n", "nsteps = 100\n", "delay=0.5\n", "# Create a thread wrapper for the simulation. The target must be an argument-less\n", "# function so we wrap the call to 'simulation' in a simple lambda:\n", "simulation_thread = Thread(target = lambda : simulation())\n", "# Now we actually start the simulation\n", "simulation_thread.start()" ], "language": "python", "metadata": { "slideshow": { "slide_start": false } }, "outputs": [], "prompt_number": 24 }, { "cell_type": "code", "collapsed": false, "input": [ "monitor_simulation(refresh=1);" ], "language": "python", "metadata": { "slideshow": { "slide_start": false } }, "outputs": [ { "metadata": {}, "output_type": "display_data", "png": "iVBORw0KGgoAAAANSUhEUgAAAXMAAAEICAYAAACtXxSQAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XuMlNXBx/Hf7BbLZXdhAYXKJQvFUGsBKchrJTVKoqYQ\nQGkjEbmIRUuiVgox2lbKwUsMasHQ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bt3SUDngS9Txh9vBWENE3Mfkw6UQxTxhygDHPDOVhtzTqzk+9lCNMn4Ah\nIvompoIeO+YKQg4w5pmjNOqcejFHmD6BFInom8QNeuoxVxRygDHPpKyM0oEMRB3IRthF9E3SDLrp\nUTnAmGcaR+nxWBv1PGH6BDQR0TeJE/TUYq4w5ABjnnlZCTrAqHtBRN8kjaCnEfNKIQeSxbwq9pbk\np7hfQy5D+xPOE9L94GHvbX0j+jZC+VkQGHMvBF3tfaLjYQQMekz5kMcJOinHmFNPlo/OMxV0YfoE\n7GD9dJg1oT7jAAABaElEQVQFGHOi/7I26DbiaNw6jLknlE+1ZHB0DjDoqRGmT0ABxb9HkmLMyVkM\nuiGlRuUcqRvHmHska6NzIpfovlGBMadUcbolBmH6BLrgCNxajDlVZtm8YCmZCDpRAMbcMy7cc+7S\ndAuD3gVH5VZjzClYhkfnAIMeWtTYi2hv573mlTHmHsrq6JxB14ijcusx5hSOhtG5S9MtAIPuGtWL\nstmOMSev6BydAwaDLswcFgBH5Y5gzD2lZarFkdG57qBTBQy/MYw5UUSZmm5hnJ3BmHuMo3N9MhV0\nnYTpE/AHY07eYtAT4qhcmTTuMGPMKTpHRudpSDXoIr1DJcKLgBHangFKRETp4ciciMgDjDkRkQcY\ncyIiDzDmREQeYMyJiDzAmBMReYAxJyLyAGNOROQBxpyIyAOMORGRBxhzIiIPMOZERB5gzImIPMCY\nExF5gDEnIvIAY05E5AHGnIjIA4w5EZEHGHMiIg/8P0ACaoJOhEAtAAAAAElFTkSuQmCC\n", "text": [ "" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "Simulation has already finished, no monitoring to do.\n" ] } ], "prompt_number": 27 }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_start": false } }, "source": [ "If you execute the following cell before the MPI code is finished running, it will stop the simulation at that point, which you can verify by calling the monitoring again:" ] }, { "cell_type": "code", "collapsed": false, "input": [ "view['stop'] = True" ], "language": "python", "metadata": { "slideshow": { "slide_start": false } }, "outputs": [], "prompt_number": 26 }, { "cell_type": "code", "collapsed": false, "input": [ "%%px --target 0\n", "from IPython.parallel import bind_kernel; bind_kernel()\n", "%connect_info" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "{\n", " \"stdin_port\": 62126, \n", " \"ip\": \"127.0.0.1\", \n", " \"control_port\": 41092, \n", " \"hb_port\": 42611, \n", " \"key\": \"00d832a7-200f-41e2-9d74-aac119f126a3\", \n", " \"shell_port\": 60748, \n", " \"transport\": \"tcp\", \n", " \"iopub_port\": 55151\n", "}\n", "\n", "Paste the above JSON into a file, and connect with:\n", " $> ipython --existing \n", "or, if you are local, you can connect with just:\n", " $> ipython --existing kernel-32429.json \n", "or even just:\n", " $> ipython --existing \n", "if this is the most recent IPython session you have started.\n" ] } ], "prompt_number": 14 }, { "cell_type": "code", "collapsed": false, "input": [ "%%px --target 0\n", "%qtconsole" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 15 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }