Code generation framework for automated finite difference computation
Latest commit 8c95a76 Dec 15, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
devito documentation: Drop more annoying :class: Dec 14, 2018
docker Docker: Add env variables inside Docker environment, and update README Nov 12, 2018
docs Installation page updated as should Dec 15, 2018
examples extent->size (part 1) Dec 14, 2018
scripts scripts,advisor: Add Jul 2, 2018
tests tests: Fix test_docstrings when there's no py.test exec available Dec 14, 2018
.coveragerc Travis: Add .coveragerc Dec 29, 2017
.deploy_key.enc docs: Introduce doctr for deployment Nov 29, 2017
.gitattributes Versioneer: Adding basic version tracking with versioneer Jan 27, 2017
.gitignore Docs: Add a preliminary Developer Docs page to the website Oct 6, 2017
.travis.yml documentation: Update doctr's html path Dec 14, 2018 Localise CoC. Nov 1, 2018
Dockerfile.pipelines Add files to support Azure Pipelines CI Dec 6, 2018 Pip: Adding MIT license with Imperial College as the author Nov 24, 2016 Versioneer: Adding basic version tracking with versioneer Jan 27, 2017 Update Dec 14, 2018 tests: Add test_docstrings Dec 14, 2018
azure-pipelines.yml Restrict testing on pipelines Dec 14, 2018
docker-compose.yml Use whatever gcc is available Nov 9, 2018
environment.yml jenkins setup Nov 9, 2018
requirements-optional.txt new setup Nov 13, 2018
requirements.txt new setup Nov 13, 2018
setup.cfg Update flake8 ignore-rules Oct 29, 2018 Merge remote-tracking branch 'origin/master' into no-mpi Nov 21, 2018 Versioneer: Adding basic version tracking with versioneer Jan 27, 2017

Devito: Fast Finite Difference Computation from Symbolic Specification

Build Status Code Coverage

Devito is a software to implement optimised finite difference (FD) computation from high-level symbolic problem definitions. Starting from symbolic equations defined in SymPy, Devito employs automated code generation and just-in-time (JIT) compilation to execute FD kernels on multiple computer platforms.

Get in touch

If you're using Devito, we would like to hear from you. Whether you are facing issues or just trying it out, join the conversation.


The recommended way to install Devito uses the Conda package manager for installation of the necessary software dependencies. Please install either Anaconda or Miniconda using the instructions provided at the download links. You will need the Python 3.6 version.

To install Devito, including examples, tests and tutorial notebooks, follow these simple passes:

git clone
cd devito
conda env create -f environment.yml
source activate devito
pip install -e .

Alternatively, you can also install and run Devito via Docker:

# get the code
git clone
cd devito

# run the tests
docker-compose run devito /tests

# start a jupyter notebook server on port 8888
docker-compose up devito

# start a bash shell with devito
docker-compose run devito /bin/bash


At the core of the Devito API are the so-called Operator objects, which allow the creation and execution of efficient FD kernels from SymPy expressions. Examples of how to define operators are provided:

  • A set of introductory notebook tutorials introducing the basic features of Devito operators can be found under examples/cfd. These tutorials cover a range of well-known examples from Computational Fluid Dynamics (CFD) and are based on the excellent introductory blog "CFD Python:12 steps to Navier-Stokes" by the Lorena A. Barba group. To run these, simply go into the tutorial directory and run jupyter notebook.
  • A set of tutorial notebooks for seismic inversion examples is available in examples/seismic/tutorials.
  • Example implementations of acoustic forward, adjoint, gradient and born operators for use in full-waveform inversion (FWI) methods can be found in examples/seismic/acoustic.
  • An advanced example of a Tilted Transverse Isotropy forward operator for use in FWI can be found in examples/seismic/tti.
  • A benchmark script for the acoustic and TTI forward operators can be found in examples/seismic/


Devito's JIT compiler engine supports multiple backends, with provided presets for the most common compiler toolchains. By default, Devito will use the default GNU compiler g++, but other toolchains may be selected by setting the DEVITO_ARCH environment variable to one of the following values:

  • gcc or gnu - Standard GNU compiler toolchain
  • clang or osx - Mac OSX compiler toolchain via clang
  • intel or icpc - Intel compiler toolchain via icpc

Thread parallel execution via OpenMP can also be enabled by setting DEVITO_OPENMP=1.

For the full list of available environment variables and their possible values, simply run:

from devito import print_defaults

Or with Docker, run:

docker-compose run devito /print-defaults

Performance optimizations

Devito supports two classes of performance optimizations:

  • Flop-count optimizations - They aim to reduce the operation count of an FD kernel. These include, for example, code motion, factorization, and detection of cross-stencil redundancies. The flop-count optimizations are performed by routines built on top of SymPy, implemented in the Devito Symbolic Engine (DSE), a sub-module of Devito.
  • Loop optimizations - Examples include SIMD vectorization and parallelism (via code annotations) and loop blocking. These are performed by the Devito Loop Engine (DLE), another sub-module of Devito.

Further, YASK is being integrated as a Devito backend, for optimized execution on Intel architectures.

Devito supports automatic auto-tuning of block sizes when loop blocking is enabled. Enabling auto-tuning is simple: it can be done by passing the special flag autotune=True to an Operator. Auto-tuning parameters can be set through the special environment variable DEVITO_AUTOTUNING.

For more information on how to drive Devito for maximum run-time performance, see here or ask the developers on the Slack channel linked above.