Commit ee9b3dfc87e by Pierre Augier

Documentation and 1 more warning

parent 7f4be3e7f95
......@@ -6,6 +6,11 @@ See the `ROADMAP.rst file
- Python 3.8 support (with gast>=0.3.0 and beniget>=0.2.0)
0.4.2 (?)
---------
- Improve usability (warnings, exceptions, API for benchmarks, ...)
0.4.1 (2019-10-08)
------------------
......
......@@ -64,7 +64,9 @@ The long-term project
.. note ::
The context of the creation of Transonic is presented in these slices:
The context of the creation of Transonic is presented in these documents:
- `Transonic Vision <https://fluiddyn.bitbucket.io/transonic-vision.html>`_
- `Make your numerical Python code fly at transonic speed (EuroScipy 2019)
<http://www.legi.grenoble-inp.fr/people/Pierre.Augier/docs/ipynbslides/20190904-euroscipy-transonic/pres.slides.html#/>`_,
......@@ -130,13 +132,11 @@ What we have now
----------------
We start to have a good API to accelerate Python-Numpy code (functions, methods
and blocks of code).
The default Transonic backend uses Pythran and works well. `Here, we explain
why Pythran is so great for Python users and why Transonic is great for Pythran
users <https://transonic.readthedocs.io/en/latest/backends/pythran.html>`_
There are also (more experimental) backends for Cython and Numba.
and blocks of code). The default Transonic backend uses Pythran and works well.
`Here, we explain why Pythran is so great for Python users and why Transonic is
great for Pythran users
<https://transonic.readthedocs.io/en/latest/backends/pythran.html>`_ There are
also (more experimental) backends for Cython and Numba.
.. note ::
......@@ -148,7 +148,7 @@ There are also (more experimental) backends for Cython and Numba.
Installation and configuration
------------------------------
.. code ::
.. code :: bash
pip install transonic
......@@ -175,8 +175,11 @@ Transonic is sensible to environment variables:
"cython", "numba" and "python" (prototypes).
A short tour of Transonic syntaxes
----------------------------------
A short tour of Transonic public API
------------------------------------
Transonic supports both ahead-of-time and just-in-time compilations. When using
the API for AOT compilation, the files need to be "compiled_" to get speedup.
Decorator :code:`boost` and command :code:`# transonic def`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -297,7 +300,6 @@ file is compiled at the first call of the function and the compiled version is
used as soon as it is ready. The warmup can be quite long but the compiled
version is saved and can be reused (without warmup!) by another process.
Define accelerated blocks
~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -393,18 +395,28 @@ More examples on how to use Transonic for Object Oriented Programing are given
`here <https://transonic.readthedocs.io/en/latest/examples/methods.html>`__.
Make the Pythran/Cython/Numba files
-----------------------------------
.. _compiled:
Make the Pythran/Cython/Numba files and compile the extensions
--------------------------------------------------------------
There is a command-line tool :code:`transonic` which makes the associated
Pythran/Cython/Numba files from Python files with annotations and transonic
code. By default and if the Python compiler is available, the files are
Pythran/Cython/Numba files from a Python file. For example one can run:
.. code :: bash
# Pythran is the default backend
transonic myfile.py -af "-march=native -DUSE_XSIMD -Ofast"
# Now using Cython
transonic myfile.py -b cython
By default and if the Python compiler is available, the produced files are
compiled.
There is also a function :code:`make_backend_files` that can be used in a
setup.py like this:
.. code ::
.. code :: python
from pathlib import Path
......
Short term (milestone for 0.4.1)
--------------------------------
- Use Cython for Windows and Pythran for Linux/macOS
(on this example https://github.com/martibosch/pylandstats/pull/2)
- alternative make_header_from_fdef_annotations for Cython
- More warnings if a file is not transpiled / compiled
Cython backend (beta version)
-----------------------------
......
......@@ -33,4 +33,4 @@ There are different methods to choose which backend is used:
examples/bench_row_sum/txt
backends/pythran
backends/cython
backends/other
backends/numba
# Numba backend
This backend is currently minimalist: Transonic only creates Python files using
the decorator `numba.njit`.
- No proper ahead-of-time compilation is done even with the `boost` decorator.
- The types in annotations are not used for this backend.
Other accelerators
==================
There are many projects which are able to accelerate Python-Numpy code. We'd
like to focus first on Numba, Cython and Cupy.
Transonic has to do different things for different accelerators:
- For Pythran:
.. code ::
.py -(transonify)-> .py -(pythranize)-> .so
- For Cython:
.. code ::
.py -(transonify)-> (.py + .pxd) -(cythonize)-> .so
- For Numba and Cupy:
.. code ::
.py -(transonify)-> .py
......@@ -30,7 +30,7 @@ Our code for a benchmark in JIT mode:
gives:
.. code::
.. code:: bash
transonic 0.4.0
pythran 0.9.3post1
......@@ -71,7 +71,7 @@ Ahead-of-time compilation
The results are:
.. code::
.. code:: bash
transonic 0.4.0
pythran 0.9.3post1
......
......@@ -23,7 +23,7 @@ Bye the way, for performance, it is important to configure Pythran with a file
For Linux, I use:
.. code::
.. code:: raw
[pythran]
complex_hook = True
......
......@@ -16,7 +16,6 @@ from glob import glob
import sys
from transonic import __version__
from transonic.analyses import analyse_aot
from transonic.compiler import wait_for_all_extensions
......@@ -85,7 +84,14 @@ def run():
backend = backends[args.backend]
backend.make_backend_files(paths, force=args.force)
if not can_import_accelerator(backend.name) or args.no_compile:
if args.no_compile:
return
if not can_import_accelerator(backend.name):
logger.warning(
f"Since {backend.name_capitalized} is not importable, "
"Transonic cannot properly compile a file."
)
return
# find pythran files not already compiled
......
......@@ -123,8 +123,6 @@ class TemplateVar:
if name_calling_module is None:
name_calling_module = get_name_calling_module()
else:
name_calling_module = name_calling_module
if name_calling_module not in names_template_variables:
names_template_variables[name_calling_module] = {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment