devito

DSL and compiler framework for automated finite-differences and stencil computation

https://github.com/devitocodes/devito

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    23 of 106 committers (21.7%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.5%) to scientific vocabulary

Keywords

code-generation compiler dsl finite-difference fwi gpu hpc jit performance rtm stencil sympy ultrasound-imaging

Keywords from Contributors

normalizing-flow computer-algebra transformers bayesian-inference deep-invertible-networks invertible-1x1-convolutions invertible-neural-networks geophysics
Last synced: 4 months ago · JSON representation ·

Repository

DSL and compiler framework for automated finite-differences and stencil computation

Basic Info
Statistics
  • Stars: 617
  • Watchers: 31
  • Forks: 238
  • Open Issues: 132
  • Releases: 47
Topics
code-generation compiler dsl finite-difference fwi gpu hpc jit performance rtm stencil sympy ultrasound-imaging
Created almost 10 years ago · Last pushed 4 months ago
Metadata Files
Readme Contributing License Code of conduct Citation

README.md

Devito: Fast Stencil Computation from Symbolic Specification

Build Status for the Core backend Build Status with MPI Build Status on GPU Code Coverage Slack Status asv PyPI version Binder Docker

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.

About Devito

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

```python

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))) ```

An Operator generates 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

```python

op(t=timesteps, dt=dt) ```

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:

  • A functional language to express finite difference operators.
  • Straightforward mechanisms to adjust the discretization.
  • Constructs to express sparse operators (e.g., interpolation), classic linear operators (e.g., convolutions), and tensor contractions.
  • Seamless support for boundary conditions and adjoint operators.
  • A flexible API to define custom stencils, sub-domains, sub-sampling, and staggered grids.
  • Generation of highly optimized parallel code (SIMD vectorization, CPU and GPU parallelism via OpenMP and OpenACC, multi-node parallelism via MPI, blocking, aggressive symbolic transformations for FLOP reduction, etc.).
  • Distributed NumPy arrays over multi-node (MPI) domain decompositions.
  • Inspection and customization of the generated code.
  • Autotuning framework to ease performance tuning.
  • Smooth integration with popular Python packages such as NumPy, SymPy, Dask, and SciPy, as well as machine learning frameworks such as TensorFlow and PyTorch.

Installation

The easiest way to try Devito is through Docker using the following commands: ```bash

get the code

git clone https://github.com/devitocodes/devito.git cd devito

start a jupyter notebook server on port 8888

docker-compose up devito `` After running the last command above, the terminal will display a URL such as https://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.

See here for detailed installation instructions and other options. If you encounter a problem during installation, please see the installation issues we have seen in the past.

Resources

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 FAQs are discussed here.

Performance

If you are interested in any of the following

  • Generation of parallel code (CPU, GPU, multi-node via MPI);
  • Performance tuning;
  • Benchmarking operators;

then you should take a look at this README.

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.

Interactive jupyter notebooks

The tutorial jupyter notebook are available interactively at the public binder jupyterhub.

Owner

  • Name: Devito Codes
  • Login: devitocodes
  • Kind: organization
  • Email: g.gorman@imperial.ac.uk

Citation (CITATION.md)

# Citing Devito

If you publish results using Devito, we would be grateful if you would cite the following papers:

```bibtex
@article{devito-compiler,
  author = {Luporini, Fabio and Louboutin, Mathias and Lange, Michael and Kukreja, Navjot and Witte, Philipp and H\"{u}ckelheim, Jan and Yount, Charles and Kelly, Paul H. J. and Herrmann, Felix J. and Gorman, Gerard J.},
  title = {Architecture and Performance of Devito, a System for Automated Stencil Computation},
  year = {2020},
  issue_date = {March 2020},
  publisher = {Association for Computing Machinery},
  address = {New York, NY, USA},
  volume = {46},
  number = {1},
  issn = {0098-3500},
  url = {https://doi.org/10.1145/3374916},
  doi = {10.1145/3374916},
  journal = {ACM Trans. Math. Softw.},
  month = {apr},
  articleno = {6},
  numpages = {28},
  keywords = {stencil, domain-specific language, symbolic processing, performance optimization, compiler, structured grid, Finite-difference method}
}

@article{devito-api,
  author = {Louboutin, M. and Lange, M. and Luporini, F. and Kukreja, N. and Witte, P. A. and Herrmann, F. J. and Velesko, P. and Gorman, G. J.},
  title = {Devito (v3.1.0): an embedded domain-specific language for finite differences and geophysical exploration},
  journal = {Geoscientific Model Development},
  volume = {12},
  year = {2019},
  number = {3},
  pages = {1165--1187},
  url = {https://www.geosci-model-dev.net/12/1165/2019/},
  doi = {10.5194/gmd-12-1165-2019}
}
```

Additionally, if you use Devito for distributed runs, you may want to cite the following paper as well:

```bibtex
@misc{bisbas2024automatedmpixcodegeneration,
  title={Automated MPI-X code generation for scalable finite-difference solvers},
  author={Bisbas, George and Nelson, Rhodri and Louboutin, Mathias and Luporini, Fabio and Kelly, Paul H.J. and Gorman, Gerard},
  booktitle={2025 IEEE International Parallel and Distributed Processing Symposium (IPDPS)}, 
  title={Automated MPI-X Code Generation for Scalable Finite-Difference Solvers}, 
  year={2025},
  volume={},
  number={},
  pages={689-701},
  keywords={Codes;Source coding;Parallel processing;Throughput;Mathematical models;Hybrid power systems;DSL;Kernel;Tuning;Finite difference methods;DSLs;finite-difference method;symbolic computation;stencil computation;MPI;distributed-memory parallelism;compilation;high-performance computing;CPUs;GPUs},
  doi={10.1109/IPDPS64566.2025.00067}
}
```

## Citing a specific release of Devito through Zenodo

To cite a specific release of Devito through Zenodo, you can follow this link pointing to the latest release:
https://doi.org/10.5281/zenodo.597277 .

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 9,417
  • Total Committers: 106
  • Avg Commits per committer: 88.84
  • Development Distribution Score (DDS): 0.519
Top Committers
Name Email Commits
Fabio Luporini f****2@i****k 4,534
mloubout m****n@g****m 1,022
Michael Lange m****e@i****k 708
Navjot Kukreja n****k@g****m 475
George Bisbas g****8@i****k 385
Rhodri Nelson r****n@g****m 334
Fabio Luporini f****o@g****m 278
FabioLuporini f****o@d****m 200
wask w****k@c****m 137
beterraba t****r@g****m 111
Tim Burgess t****b@d****m 103
Vincenzo Pandolfo v****5@i****k 89
Mathias Louboutin M****n@g****m 85
Vincenzo Pandolfo p****e@g****m 85
ofmla o****l@h****m 65
Gerard Gorman g****n@i****k 55
Ken Hester k****r@n****m 55
EdCaunt e****5@i****k 41
vmickus v****r@g****m 41
dependabot[bot] 4****]@u****m 39
sheino p****7@y****k 36
Victor Leite l****d@g****m 35
jack-lascala g****8@i****k 30
Chris Dinneen c****n@g****m 27
maelso m****o@d****r 26
Joao Speglich s****j@g****m 26
Gabriel Sebastian von Conta m****l@g****m 25
Peterson Nogueira n****n@g****m 21
italoaug i****1@g****m 19
Jaime Freire de Souza j****a@g****m 18
and 76 more...

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 133
  • Total pull requests: 814
  • Average time to close issues: over 1 year
  • Average time to close pull requests: about 1 month
  • Total issue authors: 49
  • Total pull request authors: 29
  • Average comments per issue: 2.04
  • Average comments per pull request: 1.61
  • Merged pull requests: 593
  • Bot issues: 1
  • Bot pull requests: 90
Past Year
  • Issues: 27
  • Pull requests: 370
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 4 days
  • Issue authors: 16
  • Pull request authors: 12
  • Average comments per issue: 0.41
  • Average comments per pull request: 1.4
  • Merged pull requests: 260
  • Bot issues: 0
  • Bot pull requests: 57
Top Authors
Issue Authors
  • FabioLuporini (23)
  • mloubout (14)
  • EdCaunt (14)
  • deckerla (7)
  • georgebisbas (6)
  • vahid-honarbakhsh (6)
  • ggorman (6)
  • ofmla (4)
  • rhodrin (3)
  • jiwei08 (3)
  • navjotk (3)
  • ccuetom (3)
  • jkwashbourne (3)
  • ZoeLeibowitz (2)
  • gfkdliucheng (2)
Pull Request Authors
  • mloubout (255)
  • FabioLuporini (209)
  • dependabot[bot] (90)
  • EdCaunt (81)
  • georgebisbas (57)
  • ZoeLeibowitz (25)
  • JDBetteridge (24)
  • ggorman (17)
  • enwask (12)
  • AndrewCheng827 (7)
  • ccuetom (5)
  • rhodrin (5)
  • Copilot (3)
  • AtilaSaraiva (3)
  • nogueirapeterson (3)
Top Labels
Issue Labels
compiler (13) bug-py-minor (11) bug-py (10) API (6) documentation (5) bug-C (5) examples (4) GPU (4) MPI (3) testing (2) arch (2) bug-performance-C (2) python (1) installation (1) CI (1) dependencies (1) bug-performance-py (1) feature-request (1) bug-performance-gpu (1)
Pull Request Labels
compiler (174) dependencies (134) API (106) bug-py-minor (60) bug-py (42) CI (41) MPI (40) examples (39) arch (38) bug-C (33) installation (31) python (29) testing (26) documentation (23) github_actions (17) misc (16) bug-C-minor (13) WIP (10) bug-performance-C (9) feature-request (9) benchmarking (5) GPU (3) codex (1) performance (1) bug-performance-gpu (1)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 3,036 last-month
  • Total dependent packages: 2
  • Total dependent repositories: 6
  • Total versions: 30
  • Total maintainers: 2
pypi.org: devito

Finite Difference DSL for symbolic computation.

  • Documentation: https://www.devitoproject.org/devito/index.html
  • License: The MIT License (MIT) Copyright (c) 2016, Imperial College, London Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  • Latest release: 4.8.19
    published 6 months ago
  • Versions: 30
  • Dependent Packages: 2
  • Dependent Repositories: 6
  • Downloads: 3,036 Last month
Rankings
Stargazers count: 2.9%
Forks count: 3.6%
Average: 4.5%
Dependent packages count: 4.8%
Downloads: 5.4%
Dependent repos count: 6.0%
Maintainers (2)
Last synced: 4 months ago