Optimised symbolic finite difference computation with Devito

Welcome to the interactive hands-on tutorial for Devito. Devito is a domain-specific language (DSL) and code generation framework for the design of highly optimised finite difference kernels, and was primarily designed for use in seismic inversion methods. Devito utilises SymPy to allow the definition of matrix-free finite difference operators from high-level symbolic equations and generates optimised and automatically tuned code specific to a given target architecture.

This hands-on tutorial is intended to give you an initial flavour of the Devito framework and the power of symbolic computation. We will demonstrate how quickly explicit finite difference operators can be created from only a few lines of Python code, and how we can use them to implement complex imaging algorithms in very little time (literally!). For a more in-depth overview (and as cheat-sheet if you can speed read), you can find another set of tutorial notebooks on our webpage that go through the covered topics in more detail.

Installation and setup

On entering the tutorial you should have been given an IP address for your own cloud instance that contains the full setup for this tutorial. To get started, you should log into this node and execute the following commands to start the Jupyter Notebook server:

cd devcon-tutorial
jupyter notebook

Once that is setup you should simply open the following in your browser:

http://<instance_ip>:9889

Now you should see a set of Jupyter notebooks, inlcuding this one called 00_index.ipynb. The procedure is explained in more detail here.

Once the above installation step has finished, we should run a quick sanity check that we have everything that we need. The following cell should simply complete without any errors.


In [ ]:
from devito import *
from examples.seismic import model, source

For the final part of this tutorial we will have a quick look at the stencil compiler YASK, which is currently being integrated with Devito. To verify YASK works smoothly you can run:


In [ ]:
import yask

Instructors and helpers

This tutorial will be given by the Devito development team:

  • Michael Lange (Introduction)
  • Gerard Gorman (Seismic imaging)
  • Fabio Luporini (Performance)
  • Chuck Yount (YASK)
  • Navjot Kukreja

Learning objectives

  • How to use SymPy and Devito to create simple finite difference expressions from governing equations
  • Creating Devito operators to perform highly optimized stencil computations from the symbolic kernel definitions
  • Create basic seismic modelling operator to model wave propagation for a seismic survey
  • Implement a functional FWI algorithm usign high-level components from Devito and scipy.optimize
  • Gain an overview of the various performance optimization techniques used in Devito operators
  • Get a "sneak-preview" of the new backend that allows individual parts to be offload to the YASK stencil DSL

Outline

  • Session 3: Performance Optimization and Analysis
    • Introduction to performance optimization in Devito [2min]
    • Setup for shared-memory parallelism [5min]
    • Devito Symbolic Engine (DSE) [5min]
    • Devito Loop Engine (DLE) [5min]
    • Exercise 4: performance analysis of a TTI forward operator [8min]
    • A sneak peek at the YASK backend [5min]

Bonus Material and further reading

References

  • M. Lange, N. Kukreja, F. Luporini, M. Louboutin, C. Yount, J. Hückelheim and G. Gorman. Optimised finite difference computation from symbolic equations. Accepted for publication in Proceedings of the 15th Python in Science Conference, 2017. [doi:10.25080/shinma-7f4c6e7-00d] [arxiv]

  • M. Louboutin, M. Lange, N. Kukreja, F. Herrmann, and G. Gorman. Performance prediction of finite-difference solvers for different computer architectures. Accepted for publication in Computers & Geosciences, 2016, doi:10.1016/j.cageo.2017.04.014

This notebook is part of the tutorial "Optimised Symbolic Finite Difference Computation with Devito" presented at the Intel® HPC Developer Conference 2017.