Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
fluiddyn
transonic
Commits
7dbe51bab3c4
Commit
6eab956c
authored
Sep 20, 2019
by
Pierre Augier
Browse files
Update doc packaging
parent
96f865185015
Changes
19
Hide whitespace changes
Inline
Side-by-side
.hgignore
View file @
7dbe51ba
...
...
@@ -27,6 +27,7 @@ doc/ipynb/*.rst
.mypy_cache
*.egg-info/*
**/.eggs/*
**/__pythran__/*
**/__cython__/*
...
...
README.rst
View file @
7dbe51ba
...
...
@@ -403,8 +403,8 @@ setup.py like this:
Note that :code:`make_backend_files` does not compile the backend files. The
compilation has to be done after the call of this function (see for example how
it is done in the example package
`pack_using_transonic
<https://bitbucket.org/fluiddyn/transonic/src/default/doc/examples/pack
_using_transonic
/>`_
it is done in the
`
example package
s
<https://bitbucket.org/fluiddyn/transonic/src/default/doc/examples/pack
ages
/>`_
or in `fluidsim's setup.py
<https://bitbucket.org/fluiddyn/fluidsim/src/default/setup.py>`_).
...
...
ROADMAP.rst
View file @
7dbe51ba
Short term (Milestones for 0.4.0)
---------------------------------
- alternative make_header_from_fdef_annotations for Cython
Short term (Milestone for 0.4.0)
--------------------------------
setup.py & more than one backend at runtime
-------------------------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Good example: https://github.com/martibosch/pylandstats/pull/1
- [done?] ``make_backend_files(backend_default="cython")``
- [done?] More than one backend at runtime
- [done] "python" backend (equivalent to NO_REPLACE)
- [done] ``make_backend_files(backend_default="cython")``
- [done] More than one backend at runtime
- [done] "python" backend
- [done] ``TRANSONIC_BACKEND`` changes only ``backend_default``
- [done] Examples setup.py in documentation
- Warnings if file not compiled
- [done?] ``TRANSONIC_BACKEND`` changes only ``backend_default``
- Examples setup.py in documentation
- "compilation" of "numba pure-python files"?
[done?] Specify backend in code
-------------------------------
Short term (Milestone for 0.4.1)
-------------------------------
-
.. code:: python
def func():
return 1
func_pythran = @jit(backend="pythran")(func)
func_cython = @jit(backend="cython")(func)
func_numba = @jit(backend="numba")(func)
And same with ``boost``.
- alternative make_header_from_fdef_annotations for Cython
- [done] Rewrite the comparison Numba / Pythran with Transonic
Cython backend (beta version)
-----------------------------
...
...
doc/examples/inlined/txt.rst
View file @
7dbe51ba
...
...
@@ -7,9 +7,9 @@ Compiled with:
.. code:: bash
TRANSONIC_BACKEND="pythran" transonic
add.py
TRANSONIC_BACKEND="numba"
transonic add.py
TRANSONIC_BACKEND="cython" transonic
add.py
transonic -b pythran
add.py
transonic
-b numba
add.py
transonic -b cython
add.py
Gives:
...
...
doc/examples/packages/package_cythran/README.txt
0 → 100644
View file @
7dbe51ba
# A package using Transonic (for extensions using Pythran and Cython)
```
virtualenv /tmp/venv_package_cythran
. /tmp/venv_package_cythran/bin/activate
pip install -e .
```
doc/examples/packages/package_cythran/check.py
0 → 100644
View file @
7dbe51ba
import
numpy
as
np
from
transonic.aheadoftime
import
modules_backends
from
package_cythran.calcul
import
laplace
from
package_cythran.util
import
func
laplace
(
np
.
ones
((
2
,
2
),
dtype
=
np
.
int32
))
func
(
1
)
func
(
2.
)
ts
=
modules_backends
[
"pythran"
][
"package_cythran.calcul"
]
assert
ts
.
backend
.
name
==
"pythran"
ts
=
modules_backends
[
"cython"
][
"package_cythran.util"
]
assert
ts
.
backend
.
name
==
"cython"
print
(
"everything looks alright!"
)
doc/examples/pack
_using_transonic/pack_using_transonic
/_version.py
→
doc/examples/pack
ages/package_cythran/package_cythran
/_version.py
View file @
7dbe51ba
File moved
doc/examples/packages/package_cythran/package_cythran/calcul.py
0 → 100644
View file @
7dbe51ba
import
numpy
as
np
from
transonic
import
boost
,
Type
,
Array
,
NDim
,
set_backend_for_this_module
set_backend_for_this_module
(
"pythran"
)
T
=
Type
(
np
.
int32
,
np
.
float64
,
np
.
float32
)
A
=
Array
[
T
,
NDim
(
2
)]
@
boost
def
laplace
(
image
:
A
):
"""Laplace operator in NumPy for 2D images."""
laplacian
=
(
image
[:
-
2
,
1
:
-
1
]
+
image
[
2
:,
1
:
-
1
]
+
image
[
1
:
-
1
,
:
-
2
]
+
image
[
1
:
-
1
,
2
:]
-
4
*
image
[
1
:
-
1
,
1
:
-
1
]
)
thresh
=
np
.
abs
(
laplacian
)
>
0.05
return
thresh
doc/examples/packages/package_cythran/package_cythran/util.py
0 → 100644
View file @
7dbe51ba
import
numpy
as
np
import
matplotlib.pyplot
as
plt
from
transonic
import
boost
,
Type
,
set_backend_for_this_module
set_backend_for_this_module
(
"cython"
)
T
=
Type
(
float
,
int
)
@
boost
def
func
(
a
:
T
):
b
=
1
return
a
*
np
.
sin
(
b
)
doc/examples/pack
_using_transonic
/setup.cfg
→
doc/examples/pack
ages/package_cythran
/setup.cfg
View file @
7dbe51ba
[metadata]
name = pack
_using_transonic
name =
my
pack
description = A package using Transonic
long_description = file: README.rst
classifiers =
...
...
doc/examples/pack
_using_transonic
/setup
_alt
.py
→
doc/examples/pack
ages/package_cythran
/setup.py
View file @
7dbe51ba
...
...
@@ -30,14 +30,14 @@ import numpy as np
here
=
Path
(
__file__
).
parent
.
absolute
()
pack_name
=
"pack
_using_transonic
"
pack_name
=
"pack
age_cythran
"
pack_dir
=
here
/
pack_name
# Get the version from the relevant file
version
=
run_path
(
pack_name
+
"/_version.py"
)
__version__
=
version
[
"__version__"
]
install_requires
=
[
"transonic"
]
install_requires
=
[
"transonic"
,
"numpy"
,
"matplotlib"
]
relative_paths
=
[
"calcul.py"
]
make_backend_files
([
pack_dir
/
path
for
path
in
relative_paths
],
backend
=
"pythran"
)
...
...
doc/examples/pack
_using_transonic
/README.txt
→
doc/examples/pack
ages/package_simple
/README.txt
View file @
7dbe51ba
# A package using Transonic (for extensions using Pythran or Cython)
```
virtualenv /tmp/venv_package_simple
. /tmp/venv_package_simple/bin/activate
pip install -e .
```
doc/examples/packages/package_simple/check.py
0 → 100644
View file @
7dbe51ba
import
numpy
as
np
from
transonic.aheadoftime
import
modules_backends
from
package_simple.calcul
import
laplace
from
package_simple.util
import
func
laplace
(
np
.
ones
((
2
,
2
),
dtype
=
np
.
int32
))
func
(
1
)
func
(
2.
)
modules
=
modules_backends
[
"pythran"
]
ts
=
modules
[
"package_simple.calcul"
]
assert
ts
.
backend
.
name
==
"pythran"
ts
=
modules
[
"package_simple.util"
]
assert
ts
.
backend
.
name
==
"pythran"
print
(
"everything looks alright!"
)
doc/examples/packages/package_simple/package_simple/_version.py
0 → 100644
View file @
7dbe51ba
__version__
=
"0.0.1"
\ No newline at end of file
doc/examples/pack
_using_transonic/pack_using_transonic
/calcul.py
→
doc/examples/pack
ages/package_simple/package_simple
/calcul.py
View file @
7dbe51ba
...
...
@@ -8,7 +8,7 @@ A = Array[T, NDim(2)]
@
boost
def
laplace
_pythran
(
image
:
A
):
def
laplace
(
image
:
A
):
"""Laplace operator in NumPy for 2D images."""
laplacian
=
(
image
[:
-
2
,
1
:
-
1
]
...
...
doc/examples/pack
_using_transonic/pack_using_transonic
/util.py
→
doc/examples/pack
ages/package_simple/package_simple
/util.py
View file @
7dbe51ba
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
h5netcdf
from
transonic
import
boost
,
Type
...
...
doc/examples/packages/package_simple/setup.cfg
0 → 100644
View file @
7dbe51ba
[metadata]
name = package_simple
description = A package using Transonic
long_description = file: README.rst
classifiers =
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
[options]
python_requires = >= 3.6
setup_requires =
setuptools
numpy
transonic
pythran
doc/examples/pack
_using_transonic
/setup.py
→
doc/examples/pack
ages/package_simple
/setup.py
View file @
7dbe51ba
...
...
@@ -30,14 +30,14 @@ import numpy as np
here
=
Path
(
__file__
).
parent
.
absolute
()
pack_name
=
"pack
_using_transonic
"
pack_name
=
"pack
age_simple
"
pack_dir
=
here
/
pack_name
# Get the version from the relevant file
version
=
run_path
(
pack_name
+
"/_version.py"
)
__version__
=
version
[
"__version__"
]
install_requires
=
[
"transonic"
]
install_requires
=
[
"transonic"
,
"numpy"
,
"matplotlib"
]
relative_paths
=
[
"util.py"
,
"calcul.py"
]
make_backend_files
([
pack_dir
/
path
for
path
in
relative_paths
])
...
...
doc/examples/row_sum/txt.rst
View file @
7dbe51ba
...
...
@@ -25,10 +25,10 @@ To compile this file with different backends, one can run:
.. code:: bash
TRANSONIC_BACKEND="python" transonic
row_sum_boost.py
TRANSONIC_BACKEND="cython" transonic
row_sum_boost.py
TRANSONIC_BACKEND="numba"
transonic row_sum_boost.py
TRANSONIC_BACKEND="pythran" transonic
row_sum_boost.py -pf "-march=native -DUSE_XSIMD"
transonic -b python
row_sum_boost.py
transonic -b cython
row_sum_boost.py
transonic
-b numba
row_sum_boost.py
transonic -b pythran
row_sum_boost.py -pf "-march=native -DUSE_XSIMD"
Then, on my PC (meige8pcpa79), I get::
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment