From 1b6693e0c1cab0bd0a24f0eea8b2f70553af647b Mon Sep 17 00:00:00 2001 From: Smit-create Date: Fri, 28 Jul 2023 10:08:58 +0530 Subject: [PATCH 1/5] fixes --- content/blog/lpython_mvp.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/content/blog/lpython_mvp.md b/content/blog/lpython_mvp.md index 750c5d2..a6d3a54 100644 --- a/content/blog/lpython_mvp.md +++ b/content/blog/lpython_mvp.md @@ -58,7 +58,7 @@ LPython implements several machine-independent optimisations via ASR-to-ASR pass 5. Transforming division to multiplication operation 6. Fused multiplication and addition -All optimizations are applied via one command-line argument, --fast. To select individual optimizations instead, write a command-line argument like the following: +All optimizations are applied via one command-line argument, `--fast`. To select individual optimizations instead, write a command-line argument like the following: `--pass=inline_function_calls,loop_unroll` @@ -95,7 +95,7 @@ print(res) ./a.out 0.01s user 0.00s system 89% cpu 0.012 total ``` -You can see that it's very fast. It's still plenty fast with the C backend via the command-line argument --backend=c: +You can see that it's very fast. It's still plenty fast with the C backend via the command-line argument `--backend=c`: ```zsh % time lpython /Users/czgdp1807/lpython_project/debug.py --backend=c @@ -107,13 +107,13 @@ Note that time lpython `/Users/czgdp1807/lpython_project/debug.py --backend=c` i ### Just-In-Time Compilation -Just-in-time compilation in LPython requires only decorating Python function with @lpython. The decorator takes an option for specifying the desired backend, as in, @lpython(backend="c") or @lpython(backend="llvm"). Only C is supported at present; LLVM and others will be added in the near future. The decorator also propagates backend-specific options. For example +Just-in-time compilation in LPython requires only decorating Python function with `@lpython`. The decorator takes an option for specifying the desired backend, as in, `@lpython(backend="c")` or `@lpython(backend="llvm")`. Only C is supported at present; LLVM and others will be added in the near future. The decorator also propagates backend-specific options. For example ```python @lpython(backend="c", - backend_optimization_flags=["-ffast-math", - "-funroll-loops", - "-O1"]) + backend_optimization_flags=["-ffast-math", + "-funroll-loops", + "-O1"]) ``` Note that by default C backend is used without any optimisation flags. @@ -187,7 +187,7 @@ def get_email(text): lpython@lcompilers.org ``` -Note: The `@pythoncall` and `@lpython` decorators are presently supported with just the `C` backend but eventually will work with the LLVM backend and that's work in progress. +*Note*: The `@pythoncall` and `@lpython` decorators are presently supported with just the `C` backend but eventually will work with the LLVM backend and that's work in progress. ## Benchmarks and Demos @@ -261,6 +261,7 @@ test() | Numba | 0.20 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.00 | | LPython | 0.32 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.60 | + | Compiler | Execution Time (s) | System | Relative | |---|---|---|---| | LPython | 0.013 | Apple M1 MBP 2020 | 1.00 | @@ -325,6 +326,7 @@ test() | Numba | 0.21 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.00 | | LPython | 0.31 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.48 | + | Compiler | Execution Time (s) | System | Relative | |---|---|---|---| | Numba | 0.041 | Apple M1 MBP 2020 | 1.00 | @@ -405,6 +407,7 @@ test() | Numba | 0.35 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.00 | | LPython | 0.37 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.06 | + | Compiler | Execution Time (s) | System | Relative | |---|---|---|---| | LPython | 0.11 | Apple M1 MBP 2020 | 1.00 | @@ -538,6 +541,7 @@ test() | LPython | 1.08 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.00 | | Numba | 1.69 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.56 | + | Compiler | Execution Time (s) | System | Relative | |---|---|---|---| | LPython | 0.23 | Apple M1 MBP 2020 | 1.00 | @@ -697,6 +701,7 @@ int main() { | g++ | 1.358 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 2.21 | | Python | 7.365 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 12.01 | + Note the optimization flags furnished to each compiler. | Compiler/Interpreter | Optimization flags used | @@ -706,6 +711,7 @@ Note the optimization flags furnished to each compiler. | g++ | `-ffast-math -funroll-loops -O3`| | Python | - | + **Floyd-Warshall algorithm on array representation of graphs** From 2e481e22de49d21cf9e6ea66552bf499e451a1cc Mon Sep 17 00:00:00 2001 From: Smit-create Date: Fri, 28 Jul 2023 10:14:06 +0530 Subject: [PATCH 2/5] typos --- content/_index.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/content/_index.md b/content/_index.md index 000fb10..cef1704 100644 --- a/content/_index.md +++ b/content/_index.md @@ -5,19 +5,19 @@ features that are being implemented. ## Works today -* **Best possible performance for numerical, array-oriented code** +* **Best possible performance for numerical, array-oriented code** LPython gives you the speed you need for your numerical, array-oriented code. With LPython, you can write Python code that is as fast as C or C++. This is because LPython compiles your code to optimized machine code, which is the fastest way to run code on a computer. -* **Code compatability with CPython** +* **Code compatability with CPython** If LPython compiles and runs a code, then it will run in CPython. -* **Seamless interoperability with CPython** +* **Seamless interoperability with CPython** LPython can call functions in CPython libraries. This feature permits “break-out” to Numpy, TensorFlow, PyTorch, and even to matplotlib. The break-outs will run at ordinary (slow) Python speeds, but LPython accelerates the mathematical portions to near maximum speed. -* **Just-In-Time (JIT) compilation** - LPython also supports Just-in-time compilation which requires only decorating Python function with @lpython. One can also specify the desired backend, as in, `@lpython(backend=“c”)` or `@lpython(backend=“llvm”)`. Only C is supported at present; LLVM and others will be added in the near future. +* **Just-In-Time (JIT) compilation** + LPython also supports Just-in-time compilation which requires only decorating Python function with `@lpython`. One can also specify the desired backend, as in, `@lpython(backend=“c”)` or `@lpython(backend=“llvm”)`. Only C is supported at present; LLVM and others will be added in the near future. -* **Clean, modular design, usable as a library** +* **Clean, modular design, usable as a library** LPython is structured around two independent modules, AST (Abstract Syntax Tree) and ASR (Abstract Semantic Representation), both of which are standalone (completely independent of the rest of LPython) and users are @@ -26,13 +26,13 @@ features that are being implemented. [Developer Tutorial](https://docs.lfortran.org/developer_tutorial/) documents for more details. -* **Create executables** +* **Create executables** It can create fast optimized executables unlike other interpreted compilers. -* **Runs on Linux, Mac, Windows and WebAssembly** +* **Runs on Linux, Mac, Windows and WebAssembly** All four platforms are regularly tested by our CI. -* **Several backends** +* **Several backends** The LLVM can be used to compile to binaries and for interactive usage. The C/C++ backend translates Python code to a readable C/C++ code. The x86 backend allows very fast compilation directly to x86 machine code. The WebAssembly @@ -43,20 +43,20 @@ features that are being implemented. These features are under development: -* **Interactive, Jupyter support** +* **Interactive, Jupyter support** LPython is coming soon to Jupyter. It can be used as a Jupyter kernel, allowing Python/Julia-style rapid prototyping and an exploratory workflow (`conda install jupyter lpython`). It can also be used from the command-line with an interactive prompt (REPL). -* **Support for diverse hardware** +* **Support for diverse hardware** LLVM makes it possible to run LPython on diverse hardware. We plan to support a wide range of hardware platforms, including: - CPUs: compile Python code to run on CPUs of all architectures, including x86, ARM, and POWER. - GPUs: compile Python code to run on GPUs from NVIDIA, AMD, and Intel. - TPUs: compile Python code to run on TPUs from Google. + - CPUs: compile Python code to run on CPUs of all architectures, including x86, ARM, and POWER. + - GPUs: compile Python code to run on GPUs from NVIDIA, AMD, and Intel. + - TPUs: compile Python code to run on TPUs from Google. Please vote on issues in our [issue tracker] that you want us to prioritize (feel free to create new ones if we are missing anything). From 3e7235ad4cc0c5917fd9f2c4a62d150d40cc566a Mon Sep 17 00:00:00 2001 From: Smit-create Date: Fri, 28 Jul 2023 10:24:30 +0530 Subject: [PATCH 3/5] add line breaks --- content/blog/lpython_mvp.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/content/blog/lpython_mvp.md b/content/blog/lpython_mvp.md index a6d3a54..d298281 100644 --- a/content/blog/lpython_mvp.md +++ b/content/blog/lpython_mvp.md @@ -261,6 +261,7 @@ test() | Numba | 0.20 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.00 | | LPython | 0.32 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.60 | +
| Compiler | Execution Time (s) | System | Relative | |---|---|---|---| @@ -326,6 +327,7 @@ test() | Numba | 0.21 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.00 | | LPython | 0.31 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.48 | +
| Compiler | Execution Time (s) | System | Relative | |---|---|---|---| @@ -407,6 +409,7 @@ test() | Numba | 0.35 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.00 | | LPython | 0.37 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.06 | +
| Compiler | Execution Time (s) | System | Relative | |---|---|---|---| @@ -541,6 +544,7 @@ test() | LPython | 1.08 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.00 | | Numba | 1.69 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.56 | +
| Compiler | Execution Time (s) | System | Relative | |---|---|---|---| @@ -701,6 +705,7 @@ int main() { | g++ | 1.358 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 2.21 | | Python | 7.365 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 12.01 | +
Note the optimization flags furnished to each compiler. @@ -812,7 +817,7 @@ int main() { | LPython | 2.933 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 4.22 | | Python | 440.588 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 633.94 | - +
Note the optimization flags furnished to each compiler. From 8874d9d261c8f01300e0c0a1905dcf1eef61aec7 Mon Sep 17 00:00:00 2001 From: Smit-create Date: Fri, 28 Jul 2023 10:26:23 +0530 Subject: [PATCH 4/5] line break after each table --- content/blog/lpython_mvp.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/content/blog/lpython_mvp.md b/content/blog/lpython_mvp.md index d298281..f8babe1 100644 --- a/content/blog/lpython_mvp.md +++ b/content/blog/lpython_mvp.md @@ -274,6 +274,7 @@ test() | LPython | 0.048 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.00 | | Numba | 0.048 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.00 | +
**Pointwise multiplication of two 1-D arrays** @@ -340,6 +341,7 @@ test() | Numba | 0.21 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.00 | | LPython | 0.21 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.00 | +
**Insertion sort on lists** @@ -422,6 +424,7 @@ test() | LPython | 0.10 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.00 | | Numba | 0.36 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 3.60 | +
**Quadratic-time implementation of the Dijkstra shortest-path algorithm on a fully connected graph** @@ -557,6 +560,7 @@ test() | LPython | 0.87 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.00 | | Numba | 1.95 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 2.24 | +
### Ahead-of-Time (AoT) Compilation @@ -716,6 +720,7 @@ Note the optimization flags furnished to each compiler. | g++ | `-ffast-math -funroll-loops -O3`| | Python | - | +
@@ -829,6 +834,7 @@ Note the optimization flags furnished to each compiler. | g++ | `-ffast-math -funroll-loops -O3`| | Python | - | +
### Interoperability with CPython From dbbd78d4c404bf7c4d3520cc28088ad50924651a Mon Sep 17 00:00:00 2001 From: Smit-create Date: Fri, 28 Jul 2023 10:43:14 +0530 Subject: [PATCH 5/5] add system info table --- content/blog/lpython_mvp.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/content/blog/lpython_mvp.md b/content/blog/lpython_mvp.md index f8babe1..8ed2b35 100644 --- a/content/blog/lpython_mvp.md +++ b/content/blog/lpython_mvp.md @@ -200,8 +200,13 @@ We compare JIT compilation of LPython to Numba on **summation of all the element **System Information** -Softwares - The numba version used is `numba-0.57.1`, LPython commit is `a39430386a0e7ea5de2f569e27229017dff78330` and Python version is `Python 3.10.4`. +| Compiler | Version | +|---|---| +| Numba | 0.57.1 | +| LPython | 0.19.0 | +| Python | 3.10.4 | +
**Summation of all the elements of a 1-D array** @@ -569,7 +574,15 @@ Next, we see how LPython compares to other AoT compilers and to the standard CPy **System Information** -The Clang++ version used is `14.0.3`, `g++` version is `11.3.0`, LPython commit is `a39430386a0e7ea5de2f569e27229017dff78330` and Python version is `Python 3.10.4`. + +| Compiler | Version | +|---|---| +| clang++ | 14.0.3 | +| g++ | 11.3.0 | +| LPython | 0.19.0 | +| Python | 3.10.4 | + +
**Quadratic-time implementation of the Dijkstra shortest-path algorithm on a fully connected graph**