Code generation framework for automated finite difference computation
Devito is a Python package to implement optimized stencil computation (e.g., finite differences, image processing, machine learning) from high-level symbolic problem definitions. Devito builds on SymPy and employs automated code generation and just-in-time compilation to execute optimized computational kernels on several computer platforms, including CPUs, GPUs, and clusters thereof.
Devito provides a functional language to implement sophisticated operators that can be made up of multiple stencil computations, boundary conditions, sparse operations (e.g., interpolation), and much more. A typical use case is explicit finite difference methods for approximating partial differential equations. For example, a 2D diffusion operator may be implemented with Devito as follows
>>> grid = Grid(shape=(10, 10)) >>> f = TimeFunction(name='f', grid=grid, space_order=2) >>> eqn = Eq(f.dt, 0.5 * f.laplace) >>> op = Operator(Eq(f.forward, solve(eqn, f.forward)))
Operatorgenerates low-level code from an ordered collection of
Eq(the example above being for a single equation). This code may also be compiled and executed
There is virtually no limit to the complexity of an
Operator-- the Devito compiler will automatically analyze the input, detect and apply optimizations (including single- and multi-node parallelism), and eventually generate code with suitable loops and expressions.
Key features include:
The easiest way to try Devito is through Docker using the following commands: ```
git clone https://github.com/devitocodes/devito.git cd devito
docker-compose up devito ``
After running the last command above, the terminal will display a URL such ashttps://127.0.0.1:8888/?token=XXX`. Copy-paste this URL into a browser window to start a Jupyter notebook session where you can go through the tutorials provided with Devito or create your own notebooks.
To learn how to use Devito, here is a good place to start, with lots of examples and tutorials.
The website also provides access to other information, including documentation and instructions for citing us.
Some FAQ are discussed here.
If you are interested in any of the following
then you should take a look at this README.
You may also be interested in TheMatrix -- a cross-architecture benchmarking framework showing the performance of several production-grade seismic operators implemented with Devito. This is now our flagship project towards neat, open, and reproducible science.
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 tutorial jupyter notebook are available interactively at the public binder jupyterhub.