Skip to content
Code generation framework for automated finite difference computation
Python Other
  1. Python 99.7%
  2. Other 0.3%
Branch: master
Clone or download
Latest commit 14b475c Jan 16, 2020
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows Clean up: whitespaces, import ordering, docstrings ... Jan 15, 2020
benchmarks Fixup slack links Jan 3, 2020
devito Fixup comments and docstrings Jan 16, 2020
docker Clean up: whitespaces, import ordering, docstrings ... Jan 15, 2020
docs doc: update doc and paths Jan 11, 2020
examples flake8. Jan 13, 2020
scripts scripts: Fixup create_ipyparallel_mpi_profile Jun 5, 2019
tests tests: Drop some dle=noop so that YASK behaves Jan 15, 2020
.coveragerc CI: Farewell Travis + trim down pipelines Jan 10, 2020
.deploy_key.enc doctr deploy Jan 2, 2020
.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 Localise CoC. Nov 1, 2018 Update Jan 2, 2020
Dockerfile.pipelines CI: Farewell Travis + trim down pipelines Jan 10, 2020 Pip: Adding MIT license with Imperial College as the author Nov 24, 2016 Versioneer: Adding basic version tracking with versioneer Jan 27, 2017 Update Jan 10, 2020 CI: Farewell Travis + trim down pipelines Jan 10, 2020
azure-pipelines.yml CI: Farewell Travis + trim down pipelines Jan 10, 2020
codecov.yml cov: swith to 1% target to always pass Jan 14, 2020
docker-compose.yml Use whatever gcc is available Nov 9, 2018
environment.yml CI: add python 3.8 Jan 3, 2020
requirements-optional.txt fabio's comments Dec 24, 2019
requirements.txt CI: twek req order becaUSE OF NBVAL Dec 27, 2019
setup.cfg CI: Farewell Travis + trim down pipelines Jan 10, 2020 Purge all references to opesci. Dec 29, 2019 Versioneer: Adding basic version tracking with versioneer Jan 27, 2017

Devito: Fast Finite Difference Computation from Symbolic Specification

Build Status for the Core backend Build Status with MPI 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 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.
  • A set of tutorial notebooks concerning the Devito compiler can be found in examples/compiler.
  • Devito with MPI can be explored in examples/mpi.
  • 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 benchmarks/user/


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.

You can’t perform that action at this time.