Skip to content

Commit 6e28690

Browse files
authored
Merge pull request #10 from Smit-create/blog_1
Blog fixes
2 parents 3e40ff5 + dbbd78d commit 6e28690

File tree

2 files changed

+54
-24
lines changed

2 files changed

+54
-24
lines changed

content/_index.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ features that are being implemented.
55

66
## Works today
77

8-
* **Best possible performance for numerical, array-oriented code**
8+
* **Best possible performance for numerical, array-oriented code**
99
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.
1010

11-
* **Code compatability with CPython**
11+
* **Code compatability with CPython**
1212
If LPython compiles and runs a code, then it will run in CPython.
1313

14-
* **Seamless interoperability with CPython**
14+
* **Seamless interoperability with CPython**
1515
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.
1616

17-
* **Just-In-Time (JIT) compilation**
18-
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.
17+
* **Just-In-Time (JIT) compilation**
18+
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.
1919

20-
* **Clean, modular design, usable as a library**
20+
* **Clean, modular design, usable as a library**
2121
LPython is structured around two independent modules, AST (Abstract Syntax
2222
Tree) and ASR (Abstract Semantic Representation), both of which are
2323
standalone (completely independent of the rest of LPython) and users are
@@ -26,13 +26,13 @@ features that are being implemented.
2626
[Developer Tutorial](https://docs.lfortran.org/developer_tutorial/) documents for
2727
more details.
2828

29-
* **Create executables**
29+
* **Create executables**
3030
It can create fast optimized executables unlike other interpreted compilers.
3131

32-
* **Runs on Linux, Mac, Windows and WebAssembly**
32+
* **Runs on Linux, Mac, Windows and WebAssembly**
3333
All four platforms are regularly tested by our CI.
3434

35-
* **Several backends**
35+
* **Several backends**
3636
The LLVM can be used to compile to binaries and for interactive usage. The
3737
C/C++ backend translates Python code to a readable C/C++ code. The x86 backend
3838
allows very fast compilation directly to x86 machine code. The WebAssembly
@@ -43,20 +43,20 @@ features that are being implemented.
4343

4444
These features are under development:
4545

46-
* **Interactive, Jupyter support**
46+
* **Interactive, Jupyter support**
4747
LPython is coming soon to Jupyter. It can be used as a Jupyter kernel,
4848
allowing Python/Julia-style rapid prototyping and an exploratory
4949
workflow (`conda install jupyter lpython`).
5050
It can also be used from the command-line with an interactive prompt
5151
(REPL).
5252

53-
* **Support for diverse hardware**
53+
* **Support for diverse hardware**
5454
LLVM makes it possible to run LPython on diverse hardware.
5555
We plan to support a wide range of hardware platforms, including:
5656

57-
CPUs: compile Python code to run on CPUs of all architectures, including x86, ARM, and POWER.
58-
GPUs: compile Python code to run on GPUs from NVIDIA, AMD, and Intel.
59-
TPUs: compile Python code to run on TPUs from Google.
57+
- CPUs: compile Python code to run on CPUs of all architectures, including x86, ARM, and POWER.
58+
- GPUs: compile Python code to run on GPUs from NVIDIA, AMD, and Intel.
59+
- TPUs: compile Python code to run on TPUs from Google.
6060

6161
Please vote on issues in our [issue tracker] that you want us to prioritize
6262
(feel free to create new ones if we are missing anything).

content/blog/lpython_mvp.md

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ LPython implements several machine-independent optimisations via ASR-to-ASR pass
5858
5. Transforming division to multiplication operation
5959
6. Fused multiplication and addition
6060

61-
All optimizations are applied via one command-line argument, --fast. To select individual optimizations instead, write a command-line argument like the following:
61+
All optimizations are applied via one command-line argument, `--fast`. To select individual optimizations instead, write a command-line argument like the following:
6262

6363
`--pass=inline_function_calls,loop_unroll`
6464

@@ -95,7 +95,7 @@ print(res)
9595
./a.out 0.01s user 0.00s system 89% cpu 0.012 total
9696
```
9797

98-
You can see that it's very fast. It's still plenty fast with the C backend via the command-line argument --backend=c:
98+
You can see that it's very fast. It's still plenty fast with the C backend via the command-line argument `--backend=c`:
9999

100100
```zsh
101101
% 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
107107

108108
### Just-In-Time Compilation
109109

110-
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
110+
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
111111

112112
```python
113113
@lpython(backend="c",
114-
backend_optimization_flags=["-ffast-math",
115-
"-funroll-loops",
116-
"-O1"])
114+
backend_optimization_flags=["-ffast-math",
115+
"-funroll-loops",
116+
"-O1"])
117117
```
118118

119119
Note that by default C backend is used without any optimisation flags.
@@ -187,7 +187,7 @@ def get_email(text):
187187
lpython@lcompilers.org
188188
```
189189

190-
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.
190+
*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.
191191

192192

193193
## Benchmarks and Demos
@@ -200,8 +200,13 @@ We compare JIT compilation of LPython to Numba on **summation of all the element
200200

201201
**System Information**
202202

203-
Softwares - The numba version used is `numba-0.57.1`, LPython commit is `a39430386a0e7ea5de2f569e27229017dff78330` and Python version is `Python 3.10.4`.
203+
| Compiler | Version |
204+
|---|---|
205+
| Numba | 0.57.1 |
206+
| LPython | 0.19.0 |
207+
| Python | 3.10.4 |
204208

209+
<br/>
205210
<!-- Add your systems like System - Linux, System - Windows, etc and then add the results for your System in the tables that follow -->
206211

207212
**Summation of all the elements of a 1-D array**
@@ -261,6 +266,8 @@ test()
261266
| Numba | 0.20 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.00 |
262267
| LPython | 0.32 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.60 |
263268

269+
<br/>
270+
264271
| Compiler | Execution Time (s) | System | Relative |
265272
|---|---|---|---|
266273
| LPython | 0.013 | Apple M1 MBP 2020 | 1.00 |
@@ -272,6 +279,7 @@ test()
272279
| LPython | 0.048 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.00 |
273280
| Numba | 0.048 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.00 |
274281

282+
<br/>
275283
<!-- TODO: Write a summary of the results -->
276284

277285
**Pointwise multiplication of two 1-D arrays**
@@ -325,6 +333,8 @@ test()
325333
| Numba | 0.21 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.00 |
326334
| LPython | 0.31 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.48 |
327335

336+
<br/>
337+
328338
| Compiler | Execution Time (s) | System | Relative |
329339
|---|---|---|---|
330340
| Numba | 0.041 | Apple M1 MBP 2020 | 1.00 |
@@ -336,6 +346,7 @@ test()
336346
| Numba | 0.21 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.00 |
337347
| LPython | 0.21 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.00 |
338348

349+
<br/>
339350
<!-- TODO: Write a summary of the results -->
340351

341352
**Insertion sort on lists**
@@ -405,6 +416,8 @@ test()
405416
| Numba | 0.35 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.00 |
406417
| LPython | 0.37 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.06 |
407418

419+
<br/>
420+
408421
| Compiler | Execution Time (s) | System | Relative |
409422
|---|---|---|---|
410423
| LPython | 0.11 | Apple M1 MBP 2020 | 1.00 |
@@ -416,6 +429,7 @@ test()
416429
| LPython | 0.10 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.00 |
417430
| Numba | 0.36 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 3.60 |
418431

432+
<br/>
419433
<!-- TODO: Write a summary of the results -->
420434

421435
**Quadratic-time implementation of the Dijkstra shortest-path algorithm on a fully connected graph**
@@ -538,6 +552,8 @@ test()
538552
| LPython | 1.08 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.00 |
539553
| Numba | 1.69 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.56 |
540554

555+
<br/>
556+
541557
| Compiler | Execution Time (s) | System | Relative |
542558
|---|---|---|---|
543559
| LPython | 0.23 | Apple M1 MBP 2020 | 1.00 |
@@ -549,6 +565,7 @@ test()
549565
| LPython | 0.87 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 1.00 |
550566
| Numba | 1.95 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 2.24 |
551567

568+
<br/>
552569
<!-- TODO: Write a summary of the results -->
553570

554571
### Ahead-of-Time (AoT) Compilation
@@ -557,7 +574,15 @@ Next, we see how LPython compares to other AoT compilers and to the standard CPy
557574

558575
**System Information**
559576

560-
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`.
577+
578+
| Compiler | Version |
579+
|---|---|
580+
| clang++ | 14.0.3 |
581+
| g++ | 11.3.0 |
582+
| LPython | 0.19.0 |
583+
| Python | 3.10.4 |
584+
585+
<br/>
561586

562587
**Quadratic-time implementation of the Dijkstra shortest-path algorithm on a fully connected graph**
563588

@@ -697,6 +722,8 @@ int main() {
697722
| g++ | 1.358 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 2.21 |
698723
| Python | 7.365 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 12.01 |
699724
725+
<br/>
726+
700727
Note the optimization flags furnished to each compiler.
701728
702729
| Compiler/Interpreter | Optimization flags used |
@@ -706,6 +733,8 @@ Note the optimization flags furnished to each compiler.
706733
| g++ | `-ffast-math -funroll-loops -O3`|
707734
| Python | - |
708735
736+
<br/>
737+
709738
<!-- TODO: Write a summary of the results -->
710739
711740
**Floyd-Warshall algorithm on array representation of graphs**
@@ -806,7 +835,7 @@ int main() {
806835
| LPython | 2.933 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 4.22 |
807836
| Python | 440.588 | AMD Ryzen 5 2500U (Ubuntu 22.04) | 633.94 |
808837
809-
838+
<br/>
810839
<!-- TODO: Remove above line if the following table looks good.-->
811840
812841
Note the optimization flags furnished to each compiler.
@@ -818,6 +847,7 @@ Note the optimization flags furnished to each compiler.
818847
| g++ | `-ffast-math -funroll-loops -O3`|
819848
| Python | - |
820849
850+
<br/>
821851
<!-- TODO: Write a summary of the results -->
822852
823853
### Interoperability with CPython

0 commit comments

Comments
 (0)