Published November 15, 2022 | Version v1

LPython: Interactive LLVM-based Python Compiler for Modern Architectures

  • 1. GSI Technology
  • 2. IIT Guwahati
  • 3. IIT BHU
  • 4. University of Iceland / Quansight Labs
  • 5. Fortran-Lang / LFortran

Description

We are developing a modern open-source Python compiler called LPython
(https://lpython.org/) that can execute user's code interactively in Jupyter to
allow exploratory work (much like CPython, MATLAB or Julia) as well as compile
to binaries with the goal to run user's code on modern architectures such as
multi-core CPU, GPU, as well as unfamiliar, new architectures like GSI's APU,
which features programmable compute-in memory. We aim to provide the best
possible performance for numerical array oriented code. Live demo in a Jupyter
notebook will be shown. The compiler itself is written in C++ for robustness
and speed.
 

More details at: https://rgoswami.me/posts/scipycon-2022-meta

Notes

We demonstrate to the community that it is possible to use Python in a modern interactive way and yet have execution speed as fast or faster than other compiled languages such as C++ or Fortran. Python is one of the most used languages today. For performance applications such as High Performance Computing (HPC) or any other kind of numerical computing the standard CPython implementation is often not fast enough and it is difficult to run Python code on GPUs and other accelerators. To address these issues we have developed LPython, a Python compiler that can compile Python code to binaries, work interactively, and run on all platforms. LPython is written in C++ and it has multiple backends to generate code including LLVM [1] and C++. The compiler has been open sourced under BSD license, available at https://github.com/lcompilers/lpython. The Abstract Syntax Tree (AST) and the intermediate Abstract Semantic Representation (ASR) is represented using the ASDL domain-specific language [2], just like CPython's AST. LPython is designed as a library with separate building blocks (parser, AST, ASR, semantic phase, codegen) that are all exposed to the user/developer in a natural way to make it easy to contribute back. LPython is using the same internal representation (ASR) as in LFortran [3], and both the LPython and LFortran frontends are effectively surface languages that share the same middle end and backends, as well as high and low level optimizations. Both LPython and LFortran are part of LCompilers [4]. The speed of LPython comes from high level optimizations at the ASR level, as well as the low level optimizations that LLVM can do. In addition it is remarkably easy to customize back ends.

Files

lpython.pdf

Files (647.4 kB)

Name Size Download all
md5:bfcd6ed206adc671d10064f4cc8f9992
647.4 kB Preview Download